Date: Fri, 27 May 2016 23:03:44 +0000 (UTC) From: Bryan Drewery <bdrewery@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300886 - in head: . lib/libc++ lib/libcxxrt share/mk Message-ID: <201605272303.u4RN3iOR099110@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bdrewery Date: Fri May 27 23:03:44 2016 New Revision: 300886 URL: https://svnweb.freebsd.org/changeset/base/300886 Log: Move external GCC compiler hacks to bsd.sys.mk. This allows respecting -nostdinc, -nostdinc++ and -nostdlib before making the decision to add in -isystem, etc. The -isystem flags are problematic for building lib/libc++ and lib/libcxxrt which wants to only use its own headers. More information the need of these flags can be found at https://gcc.gnu.org/ml/gcc/2016-03/msg00219.html This also reverts r300873. Sponsored by: EMC / Isilon Storage Division Modified: head/Makefile.inc1 head/Makefile.libcompat head/lib/libc++/Makefile head/lib/libcxxrt/Makefile head/share/mk/bsd.sys.mk Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Fri May 27 23:03:28 2016 (r300885) +++ head/Makefile.inc1 Fri May 27 23:03:44 2016 (r300886) @@ -527,19 +527,12 @@ TARGET_ABI= gnueabihf TARGET_ABI= gnueabi .endif .endif -.if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc -# GCC requires -isystem and -L when using a cross-compiler. -XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib -# Force using libc++ for external GCC. -XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \ - -nostdinc++ -L${WORLDTMP}/../lib/libc++ -.else +.if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == "clang" TARGET_ABI?= unknown TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0 XCFLAGS+= -target ${TARGET_TRIPLE} .endif XCFLAGS+= --sysroot=${WORLDTMP} -.else .endif # ${MK_CROSS_COMPILER} == "no" .if !empty(BFLAGS) Modified: head/Makefile.libcompat ============================================================================== --- head/Makefile.libcompat Fri May 27 23:03:28 2016 (r300885) +++ head/Makefile.libcompat Fri May 27 23:03:44 2016 (r300886) @@ -72,13 +72,6 @@ LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \ # -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for # Clang/GCC. LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat} -.if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc -# GCC requires -isystem when using a cross-compiler. -LIBCOMPATCFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include -# Force using libc++ for external GCC. -LIBCOMPATCXXFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include/c++/v1 -std=c++11 \ - -nostdinc++ -L${LIBCOMPAT_OBJTREE}${.CURDIR}/lib/libc++ -.endif # Yes, the flags are redundant. LIBCOMPATWMAKEENV+= MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} \ Modified: head/lib/libc++/Makefile ============================================================================== --- head/lib/libc++/Makefile Fri May 27 23:03:28 2016 (r300885) +++ head/lib/libc++/Makefile Fri May 27 23:03:44 2016 (r300886) @@ -63,7 +63,7 @@ cxxrt_${_S}: ${_LIBCXXRTDIR}/${_S} .NOME .endfor WARNS= 0 -CFLAGS+= -isystem ${HDRDIR} -isystem ${_LIBCXXRTDIR} -nostdinc++ -nostdlib -DLIBCXXRT +CFLAGS+= -I${HDRDIR} -I${_LIBCXXRTDIR} -nostdinc++ -nostdlib -DLIBCXXRT .if empty(CXXFLAGS:M-std=*) CXXFLAGS+= -std=c++11 .endif Modified: head/lib/libcxxrt/Makefile ============================================================================== --- head/lib/libcxxrt/Makefile Fri May 27 23:03:28 2016 (r300885) +++ head/lib/libcxxrt/Makefile Fri May 27 23:03:44 2016 (r300886) @@ -21,7 +21,7 @@ SRCS+= libelftc_dem_gnu3.c\ guard.cc WARNS= 0 -CFLAGS+= -isystem ${SRCDIR} -nostdinc++ +CFLAGS+= -I${SRCDIR} -nostdinc++ .if empty(CXXFLAGS:M-std=*) CXXFLAGS+= -std=c++11 .endif Modified: head/share/mk/bsd.sys.mk ============================================================================== --- head/share/mk/bsd.sys.mk Fri May 27 23:03:28 2016 (r300885) +++ head/share/mk/bsd.sys.mk Fri May 27 23:03:44 2016 (r300886) @@ -178,6 +178,32 @@ ACFLAGS+= ${ACFLAGS.${.IMPSRC:T}} CFLAGS+= ${CFLAGS.${.IMPSRC:T}} CXXFLAGS+= ${CXXFLAGS.${.IMPSRC:T}} +# Special handling for external GCC. +.if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == "gcc" +# GCC's --sysroot support for a cross-compiler without a default +# TARGET_SYSTEM_ROOT does not add sysroot/usr/include in or the C++ +# include path of sysroot/usr/include/c++/v1. They need to be added in +# when not using -nostdinc/-nostdinc++. This is not a problem with a +# non-cross-compiler external GCC or the in-tree cross-compiler GCC which +# has a default TARGET_SYSTEM_ROOT. +.if ${CC:M--sysroot=*} || ${CFLAGS:M--sysroot=*} +.if ${CFLAGS:M-nostdinc} == "" +CFLAGS+= -isystem =/usr/include +.endif +# Add in sysroot/usr/lib to ensure that it comes before /usr/local/lib +# from ports compilers. +LDFLAGS+= -L=/usr/lib +# We want to force building the system with our in-tree libc++. Note that +# this also requires a symlink in OBJDIR/lib/libc++/libstdc++.so to +# sysroot/usr/lib/libc++.so. +.if ${CXXFLAGS:M-nostdinc++} == "" && ${CXXFLAGS:M-nostdlib} == "" +CXXFLAGS+= -std=c++11 \ + -nostdinc++ -isystem =/usr/include/c++/v1 +LDFLAGS+= -L${OBJTOP}/lib/libc++ +.endif +.endif # --sysroot +.endif # X_COMPILER_TYPE == gcc + .if defined(SRCTOP) # Prevent rebuilding during install to support read-only objdirs. .if !make(all) && make(install) && empty(.MAKE.MODE:Mmeta)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605272303.u4RN3iOR099110>