diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp b/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp index fffba0e4e50f..d8d580b8b5cc 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp @@ -1851,6 +1851,38 @@ bool FreeBSD::UseSjLjExceptions() const { } } +ToolChain::CXXStdlibType +FreeBSD::GetCXXStdlibType(const ArgList &Args) const { + if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) { + StringRef Value = A->getValue(); + if (Value == "libc++") + return ToolChain::CST_Libcxx; + if (Value == "libstdc++") + return ToolChain::CST_Libstdcxx; + getDriver().Diag(diag::err_drv_invalid_stdlib_name) + << A->getAsString(Args); + } + + return getTriple().getOSMajorVersion() >= 10 ? ToolChain::CST_Libcxx : + ToolChain::CST_Libstdcxx; +} + +void FreeBSD::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, + ArgStringList &CC1Args) const { + if (DriverArgs.hasArg(options::OPT_nostdlibinc) || + DriverArgs.hasArg(options::OPT_nostdincxx)) + return; + + if (GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx) + addSystemInclude(DriverArgs, CC1Args, + getDriver().SysRoot + "/usr/include/c++/v1"); + else + addSystemInclude(DriverArgs, CC1Args, + getDriver().SysRoot + "/usr/include/c++/4.2"); + return; + +} + /// NetBSD - NetBSD tool chain which can call as(1) and ld(1) directly. NetBSD::NetBSD(const Driver &D, const llvm::Triple& Triple, const ArgList &Args) diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains.h b/contrib/llvm/tools/clang/lib/Driver/ToolChains.h index 3afd8dd228b6..2b140c1cd0a3 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains.h +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains.h @@ -458,9 +458,14 @@ class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF { public: FreeBSD(const Driver &D, const llvm::Triple& Triple, const ArgList &Args); + virtual CXXStdlibType GetCXXStdlibType(const ArgList &Args) const; + virtual bool IsMathErrnoDefault() const { return false; } virtual bool IsObjCNonFragileABIDefault() const { return true; } + virtual void AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, + ArgStringList &CC1Args) const; + virtual bool UseSjLjExceptions() const; protected: virtual Tool *buildAssembler() const; diff --git a/gnu/lib/Makefile b/gnu/lib/Makefile index 6750403d66c5..50797fced309 100644 --- a/gnu/lib/Makefile +++ b/gnu/lib/Makefile @@ -10,7 +10,7 @@ SUBDIR+= libssp # libsupc++ uses libstdc++ headers, although 'make includes' should # have taken care of that already. -.if ${MK_CXX} != "no" +.if ${MK_GNUCXX} != "no" SUBDIR+= libstdc++ libsupc++ .endif diff --git a/gnu/usr.bin/cc/Makefile b/gnu/usr.bin/cc/Makefile index efb548aaf62e..bf6d20c79ce4 100644 --- a/gnu/usr.bin/cc/Makefile +++ b/gnu/usr.bin/cc/Makefile @@ -12,7 +12,12 @@ SUBDIR+= cpp .endif .if ${MK_CXX} != "no" -SUBDIR+= cc1plus c++ c++filt +.if ${MK_GNUCXX} != "no" +SUBDIR+= cc1plus c++ +.endif +# This should be moved into the above block once c++filt from elftoolchain or +# similar is provided. +SUBDIR+= c++filt .endif .if ${MK_GCOV} != "no" diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index da758d54cbbb..3eb8e51a6731 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -284,7 +284,6 @@ __DEFAULT_YES_OPTIONS = \ FP_LIBC \ FREEBSD_UPDATE \ GAMES \ - GCC \ GCOV \ GDB \ GNU \ @@ -400,6 +399,11 @@ __T=${TARGET_ARCH} .else __T=${MACHINE_ARCH} .endif +.if defined(TARGET) +__TT=${TARGET} +.else +__TT=${MACHINE_ARCH} +.endif # Clang is only for x86, powerpc and little-endian arm right now, by default. .if ${__T} == "amd64" || ${__T} == "i386" || ${__T:Mpowerpc*} __DEFAULT_YES_OPTIONS+=CLANG CLANG_FULL @@ -414,8 +418,30 @@ __DEFAULT_NO_OPTIONS+=CLANG CLANG_FULL .if ${__T} == "amd64" || ${__T} == "arm" || ${__T} == "armv6" || \ ${__T} == "i386" __DEFAULT_YES_OPTIONS+=CLANG_IS_CC +# The pc98 bootloader requires gcc to build and so we must leave gcc enabled +# for pc98 for now. +.if ${__TT} == "pc98" +__DEFAULT_NO_OPTIONS+=GNUCXX +__DEFAULT_YES_OPTIONS+=GCC .else +__DEFAULT_NO_OPTIONS+=GCC GNUCXX +.endif +# The libc++ headers use c++11 extensions. These are normally silenced because +# they are treated as system headers, but we explicitly disable that warning +# suppression when building the base system to catch bugs in our headers. +# Eventually we'll want to start building the base system C++ code as C++11, +# but not yet. +CXXFLAGS+= -Wno-c++11-extensions +.else +# If clang is not cc, then build gcc by default __DEFAULT_NO_OPTIONS+=CLANG_IS_CC +__DEFAULT_YES_OPTIONS+=GCC +# And if g++ is c++, build the rest of the GNU C++ stack +.if defined(WITHOUT_CXX) +__DEFAULT_NO_OPTIONS+=GNUCXX +.else +__DEFAULT_YES_OPTIONS+=GNUCXX +.endif .endif # FDT is needed only for arm, mips and powerpc .if ${__T:Marm*} || ${__T:Mpowerpc*} || ${__T:Mmips*} diff --git a/sys/sys/param.h b/sys/sys/param.h index fa3e2eb78ffe..0099a4df376b 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1000053 /* Master, propagated to newvers */ +#define __FreeBSD_version 1000054 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, diff --git a/tools/build/options/WITHOUT_GNUCXX b/tools/build/options/WITHOUT_GNUCXX new file mode 100644 index 000000000000..ce10636009e2 --- /dev/null +++ b/tools/build/options/WITHOUT_GNUCXX @@ -0,0 +1,3 @@ +.\" $FreeBSD$ +Do not build the GNU C++ stack (g++, libstdc++). +This is the default on platforms where clang is the system compiler. diff --git a/tools/build/options/WITH_GNUCXX b/tools/build/options/WITH_GNUCXX new file mode 100644 index 000000000000..c49e7cd9e1c4 --- /dev/null +++ b/tools/build/options/WITH_GNUCXX @@ -0,0 +1,3 @@ +.\" $FreeBSD$ +Build the GNU C++ stack (g++, libstdc++). +This is the default on platforms where gcc is the system compiler.