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
This commit is contained in:
parent
b945f26dce
commit
288155afbb
@ -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)
|
||||
|
@ -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} \
|
||||
|
@ -63,7 +63,7 @@ cxxrt_${_S}: ${_LIBCXXRTDIR}/${_S} .NOMETA
|
||||
.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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user