From f661dbee816b5fc7b1b9f6d4486ada609921ad59 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Sun, 29 May 2016 06:20:15 +0000 Subject: [PATCH] GCC External: Revert r300886, r300904, r300917, r300918 The fix in r300873 is mostly enough. A fix for lib32 will be committed.separately. --- Makefile.inc1 | 8 +++++++- Makefile.libcompat | 17 +++++++++++------ lib/libc++/Makefile | 2 +- lib/libcxxrt/Makefile | 2 +- share/mk/bsd.compiler.mk | 22 +++++++--------------- share/mk/bsd.sys.mk | 30 ------------------------------ 6 files changed, 27 insertions(+), 54 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index e5e29e743b40..2503da3394bd 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -527,7 +527,13 @@ TARGET_ABI= gnueabihf TARGET_ABI= gnueabi .endif .endif -.if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == "clang" +.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 TARGET_ABI?= unknown TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0 XCFLAGS+= -target ${TARGET_TRIPLE} diff --git a/Makefile.libcompat b/Makefile.libcompat index e650266681a3..c96623467408 100644 --- a/Makefile.libcompat +++ b/Makefile.libcompat @@ -17,7 +17,7 @@ LIB32CPUFLAGS= -march=${TARGET_CPUTYPE} .endif LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \ MACHINE_CPU="i686 mmx sse sse2" -LIB32WMAKEENV+= \ +LIB32WMAKEFLAGS= \ AS="${XAS} --32" \ LD="${XLD} -m elf_i386_fbsd -Y P,${LIBCOMPATTMP}/usr/lib32" \ OBJCOPY="${XOBJCOPY}" @@ -29,7 +29,7 @@ LIB32CPUFLAGS= -mcpu=powerpc LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE} .endif LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc -LIB32WMAKEENV+= \ +LIB32WMAKEFLAGS= \ LD="${XLD} -m elf32ppc_fbsd" \ OBJCOPY="${XOBJCOPY}" .endif @@ -72,6 +72,13 @@ 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} \ @@ -84,11 +91,9 @@ LIBCOMPATWMAKEENV+= MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} \ # Don't rebuild build-tools targets during normal build. LIBCOMPATWMAKEENV+= BUILD_TOOLS_META=.NOMETA_CMP .endif -LIBCOMPATWMAKEENV+= \ - CC="${XCC} ${LIBCOMPATCFLAGS}" \ +LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \ CXX="${XCXX} ${LIBCOMPATCFLAGS} ${LIBCOMPATCXXFLAGS}" \ - CPP="${XCPP} ${LIBCOMPATCFLAGS}" -LIBCOMPATWMAKEFLAGS+= \ + CPP="${XCPP} ${LIBCOMPATCFLAGS}" \ DESTDIR=${LIBCOMPATTMP} \ -DNO_CPU_CFLAGS \ MK_CTF=no \ diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile index 603e6bf7f712..6e70cf102df9 100644 --- a/lib/libc++/Makefile +++ b/lib/libc++/Makefile @@ -63,7 +63,7 @@ cxxrt_${_S}: ${_LIBCXXRTDIR}/${_S} .NOMETA .endfor WARNS= 0 -CFLAGS+= -I${HDRDIR} -I${_LIBCXXRTDIR} -nostdinc++ -nostdlib -DLIBCXXRT +CFLAGS+= -isystem ${HDRDIR} -isystem ${_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 15420a692b9f..f2efe8db541f 100644 --- a/lib/libcxxrt/Makefile +++ b/lib/libcxxrt/Makefile @@ -21,7 +21,7 @@ SRCS+= libelftc_dem_gnu3.c\ guard.cc WARNS= 0 -CFLAGS+= -I${SRCDIR} -nostdinc++ +CFLAGS+= -isystem ${SRCDIR} -nostdinc++ .if empty(CXXFLAGS:M-std=*) CXXFLAGS+= -std=c++11 .endif diff --git a/share/mk/bsd.compiler.mk b/share/mk/bsd.compiler.mk index d7cf50ecdb26..d078dfeb2c3b 100644 --- a/share/mk/bsd.compiler.mk +++ b/share/mk/bsd.compiler.mk @@ -108,10 +108,8 @@ ccache-print-options: .PHONY # CC and COMPILER_* settings here. _exported_vars= ${X_}COMPILER_TYPE ${X_}COMPILER_VERSION \ ${X_}COMPILER_FREEBSD_VERSION -# Handle importing cached vars, but not for X_ vars. -.if ${X_} == "" -_cc_hash= ${${cc}}${MACHINE}${PATH} -_cc_hash:= ${_cc_hash:hash} +${X_}_cc_hash= ${${cc}}${MACHINE}${PATH} +${X_}_cc_hash:= ${${X_}_cc_hash:hash} # Only import if none of the vars are set somehow else. _can_export= yes .for var in ${_exported_vars} @@ -121,12 +119,11 @@ _can_export= no .endfor .if ${_can_export} == yes .for var in ${_exported_vars} -.if defined(${var}.${_cc_hash}) -${var}= ${${var}.${_cc_hash}} +.if defined(${var}.${${X_}_cc_hash}) +${var}= ${${var}.${${X_}_cc_hash}} .endif .endfor .endif -.endif # ${X_} == "" .if ${cc} == "CC" || (${cc} == "XCC" && ${XCC} != ${CC}) .if ${MACHINE} == "common" @@ -186,14 +183,9 @@ X_COMPILER_FEATURES= ${COMPILER_FEATURES} # Export the values so sub-makes don't have to look them up again, using the # hash key computed above. .for var in ${_exported_vars} -.if ${X_} == "" -${var}.${_cc_hash}:= ${${var}} -.export-env ${var}.${_cc_hash} -.undef ${var}.${_cc_hash} -.else -# Always export X_ vars. -.export-env ${var} -.endif +${var}.${${X_}_cc_hash}:= ${${var}} +.export-env ${var}.${${X_}_cc_hash} +.undef ${var}.${${X_}_cc_hash} .endfor .endif # ${cc} == "CC" || !empty(XCC) diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index ab7cb534c8f8..4f157be96005 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -178,36 +178,6 @@ 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 -# 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++ -# Need to ensure this path comes before the above -isystem =/usr/include. -# CXXFLAGS is CFLAGS with extra added in, so there's no way to fix the -# ordering otherwise. -CXX+= -isystem =/usr/include/c++/v1 -LDFLAGS+= -L${OBJTOP}/lib/libc++ -.endif -# Add in sysroot/usr/lib to ensure that it comes before /usr/local/lib -# from ports compilers. -LDFLAGS+= -L=/usr/lib -.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)