LTO: Prevent -flto being used in main system libraries.
authorzrj <rimvydas.jasinskas@gmail.com>
Wed, 12 Oct 2016 14:04:52 +0000 (17:04 +0300)
committerzrj <zrj@dragonflybsd.org>
Tue, 25 Oct 2016 16:31:32 +0000 (19:31 +0300)
There are subtle ways it can get broken specially in libc and libm.
(-plugin-opt=-pass-through=-lc)
Both libpthread.a and rtld-elf could have use of LTO but it is safer
for now not to expose internals. (affects only static libs)

lib/libc/Makefile.inc
lib/libm/Makefile
lib/libthread_xu/Makefile
libexec/rtld-elf/Makefile

index 1f0be47..5c2c9fe 100644 (file)
@@ -12,6 +12,12 @@ NOASM=
 
 WARNS=2
 
+# for now do not let the use of -flto (check -plugin-opt=-pass-through=-lc !)
+.if ${CFLAGS:M-flto}
+CFLAGS+=       -fno-lto
+LDFLAGS+=      -flto
+.endif
+
 .include "${.CURDIR}/../libc/${MACHINE_ARCH}/Makefile.inc"
 
 .include "${.CURDIR}/../libc/citrus/Makefile.inc"
index 616543a..d4dde12 100644 (file)
@@ -114,6 +114,12 @@ PAST_SRCS = imprecise.c frexp.c isfinite.c isnanf.c isnormal.c signbit.c
 SRCS=  ${COMMON_SRCS} ${PURE_SRCS}
 SRCS+= ${PAST_SRCS}
 
+# for now do not let the use of -flto
+.if ${CFLAGS:M-flto}
+CFLAGS+=       -fno-lto
+LDFLAGS+=      -flto
+.endif
+
 .if (${MACHINE_ARCH} == "x86_64")
 .PATH:         ${OPENSRC}/src/ld80
 .PATH:         ${.CURDIR}/src/amd64
index ee4aa15..da4020a 100644 (file)
@@ -2,6 +2,13 @@
 
 LIB=thread_xu
 SHLIB_MAJOR= 2
+
+# for now do not let the use of -flto
+.if ${CFLAGS:M-flto}
+CFLAGS+=       -fno-lto
+LDFLAGS+=      -flto
+.endif
+
 CFLAGS+=-DPTHREAD_KERNEL -D_THREAD_SAFE
 CFLAGS+=-I${.CURDIR}/../libc/include -I${.CURDIR}/thread \
        -I${.CURDIR}/../../include
index b06b039..6a68dae 100644 (file)
@@ -13,6 +13,12 @@ WARNS?=              2
 # To activate LD_DEBUG functionality, define ENABLE_DEBUG
 # e.g. make -DENABLE_DEBUG
 
+# for now do not let the use of -flto
+.if ${CFLAGS:M-flto}
+CFLAGS+=       -fno-lto
+LDFLAGS+=      -flto
+.endif
+
 CFLAGS+=       -DIN_RTLD
 CFLAGS+=       -I${.CURDIR}/${MACHINE_ARCH} -I${.CURDIR} -D__thread=
 CFLAGS+=       -I${.CURDIR}/../../lib/csu/common