diff options
-rw-r--r-- | Makefile.inc1 | 9 | ||||
-rw-r--r-- | Makefile.libcompat | 7 | ||||
-rw-r--r-- | lib/libc++/Makefile | 2 | ||||
-rw-r--r-- | lib/libcxxrt/Makefile | 2 | ||||
-rw-r--r-- | share/mk/bsd.sys.mk | 26 |
5 files changed, 29 insertions, 17 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1 index 012ea0c..e5e29e7 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -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) diff --git a/Makefile.libcompat b/Makefile.libcompat index c966234..08d684c 100644 --- a/Makefile.libcompat +++ b/Makefile.libcompat @@ -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} \ diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile index 5db0934..984e70b 100644 --- a/lib/libc++/Makefile +++ b/lib/libc++/Makefile @@ -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 diff --git a/lib/libcxxrt/Makefile b/lib/libcxxrt/Makefile index f2efe8d..15420a6 100644 --- a/lib/libcxxrt/Makefile +++ b/lib/libcxxrt/Makefile @@ -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 diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index 4f157be..7f74de1 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -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) |