diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -2386,9 +2386,7 @@ return false; const llvm::Triple &Triple = getTarget().getTriple(); - if (Triple.isOSDarwin() || Triple.isPS()) - return false; - if (Triple.isOSFreeBSD() && Triple.getOSMajorVersion() >= 10) + if (Triple.isOSDarwin() || Triple.isPS() || Triple.isOSFreeBSD()) return false; return true; } diff --git a/clang/lib/Driver/ToolChains/FreeBSD.h b/clang/lib/Driver/ToolChains/FreeBSD.h --- a/clang/lib/Driver/ToolChains/FreeBSD.h +++ b/clang/lib/Driver/ToolChains/FreeBSD.h @@ -61,7 +61,14 @@ void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; - CXXStdlibType GetDefaultCXXStdlibType() const override; + + RuntimeLibType GetDefaultRuntimeLibType() const override { + return ToolChain::RLT_CompilerRT; + } + CXXStdlibType GetDefaultCXXStdlibType() const override { + return ToolChain::CST_Libcxx; + } + void addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; void diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp --- a/clang/lib/Driver/ToolChains/FreeBSD.cpp +++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp @@ -176,10 +176,8 @@ CmdArgs.push_back("/libexec/ld-elf.so.1"); } const llvm::Triple &T = ToolChain.getTriple(); - if (T.getOSMajorVersion() >= 9) { - if (Arch == llvm::Triple::arm || Arch == llvm::Triple::sparc || T.isX86()) - CmdArgs.push_back("--hash-style=both"); - } + if (Arch == llvm::Triple::arm || Arch == llvm::Triple::sparc || T.isX86()) + CmdArgs.push_back("--hash-style=both"); CmdArgs.push_back("--enable-new-dtags"); } @@ -396,17 +394,11 @@ getFilePaths().push_back(concat(getDriver().SysRoot, "/usr/lib")); } -ToolChain::CXXStdlibType FreeBSD::GetDefaultCXXStdlibType() const { - unsigned Major = getTriple().getOSMajorVersion(); - if (Major >= 10 || Major == 0) - return ToolChain::CST_Libcxx; - return ToolChain::CST_Libstdcxx; -} - unsigned FreeBSD::GetDefaultDwarfVersion() const { - if (getTriple().getOSMajorVersion() < 12) - return 2; - return 4; + unsigned Major = getTriple().getOSMajorVersion(); + if (Major >= 12 || Major == 0) + return 4; + return 2; } void FreeBSD::AddClangSystemIncludeArgs( @@ -550,8 +542,9 @@ void FreeBSD::addClangTargetOptions(const ArgList &DriverArgs, ArgStringList &CC1Args, Action::OffloadKind) const { + unsigned Major = getTriple().getOSMajorVersion(); if (!DriverArgs.hasFlag(options::OPT_fuse_init_array, options::OPT_fno_use_init_array, - getTriple().getOSMajorVersion() >= 12)) + (Major >= 12 || Major == 0))) CC1Args.push_back("-fno-use-init-array"); } diff --git a/clang/test/Driver/constructors.c b/clang/test/Driver/constructors.c --- a/clang/test/Driver/constructors.c +++ b/clang/test/Driver/constructors.c @@ -84,7 +84,11 @@ // RUN: %clang -### %s -fsyntax-only 2>&1 \ // RUN: --target=i386-unknown-freebsd11 \ // RUN: | FileCheck --check-prefix=CHECK-NO-INIT-ARRAY %s - +// +// RUN: %clang -### %s -fsyntax-only 2>&1 \ +// RUN: --target=i386-unknown-freebsd \ +// RUN: | FileCheck --check-prefix=CHECK-INIT-ARRAY %s +// // RUN: %clang -### %s -fsyntax-only 2>&1 \ // RUN: --target=i386-unknown-freebsd12 \ // RUN: | FileCheck --check-prefix=CHECK-INIT-ARRAY %s diff --git a/clang/test/Driver/freebsd.c b/clang/test/Driver/freebsd.c --- a/clang/test/Driver/freebsd.c +++ b/clang/test/Driver/freebsd.c @@ -7,18 +7,18 @@ // CHECK-ARM64: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o" // // RUN: %clang \ -// RUN: --target=powerpc-pc-freebsd8 %s \ +// RUN: --target=powerpc-pc-freebsd %s \ // RUN: --sysroot=%S/Inputs/basic_freebsd_tree -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-PPC %s -// CHECK-PPC: "-cc1" "-triple" "powerpc-pc-freebsd8" +// CHECK-PPC: "-cc1" "-triple" "powerpc-pc-freebsd" // CHECK-PPC: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-PPC: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o" // // RUN: %clang \ -// RUN: --target=powerpc64-pc-freebsd8 %s \ +// RUN: --target=powerpc64-pc-freebsd %s \ // RUN: --sysroot=%S/Inputs/basic_freebsd64_tree -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-PPC64 %s -// CHECK-PPC64: "-cc1" "-triple" "powerpc64-pc-freebsd8" +// CHECK-PPC64: "-cc1" "-triple" "powerpc64-pc-freebsd" // CHECK-PPC64: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-PPC64: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o" @@ -33,13 +33,13 @@ // // Check that -m32 properly adjusts the toolchain flags. // -// RUN: %clang --target=x86_64-pc-freebsd8 -m32 %s \ +// RUN: %clang --target=x86_64-pc-freebsd -m32 %s \ // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-LIB32 %s -// CHECK-LIB32: "-cc1" "-triple" "i386-pc-freebsd8" +// CHECK-LIB32: "-cc1" "-triple" "i386-pc-freebsd" // CHECK-LIB32: ld{{.*}}" {{.*}} "-m" "elf_i386_fbsd" // -// RUN: %clang --target=x86_64-pc-freebsd8 -m32 %s 2>&1 \ +// RUN: %clang --target=x86_64-pc-freebsd -m32 %s 2>&1 \ // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-LIB32PATHS %s // CHECK-LIB32PATHS: libraries: ={{.*:?}}/usr/lib32 @@ -81,19 +81,14 @@ // CHECK-RV64I-LD: ld{{.*}}" {{.*}} "-m" "elf64lriscv" // // Check that the new linker flags are passed to FreeBSD -// RUN: %clang --target=x86_64-pc-freebsd8 -m32 %s \ -// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ -// RUN: | FileCheck --check-prefix=CHECK-LDFLAGS8 %s -// RUN: %clang --target=x86_64-pc-freebsd9 -m32 %s \ -// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ -// RUN: | FileCheck --check-prefix=CHECK-LDFLAGS9 %s // RUN: %clang --target=x86_64-pc-freebsd10.0 -m32 %s \ // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ -// RUN: | FileCheck --check-prefix=CHECK-LDFLAGS9 %s -// CHECK-LDFLAGS8-NOT: --hash-style=both -// CHECK-LDFLAGS8: --enable-new-dtags -// CHECK-LDFLAGS9: --hash-style=both -// CHECK-LDFLAGS9: --enable-new-dtags +// RUN: | FileCheck --check-prefix=CHECK-LDFLAGS_HASH %s +// RUN: %clang --target=x86_64-pc-freebsd -m32 %s \ +// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-LDFLAGS_HASH %s +// CHECK-LDFLAGS_HASH: --hash-style=both +// CHECK-LDFLAGS_HASH: --enable-new-dtags // // Check that we do not pass --hash-style=gnu and --hash-style=both to linker // and provide correct path to the dynamic linker for MIPS platforms. @@ -123,27 +118,27 @@ // CHECK-MIPS64EL: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1" // CHECK-MIPS64EL-NOT: "--hash-style={{gnu|both}}" -// RUN: %clang --target=x86_64-pc-freebsd8 -static %s \ +// RUN: %clang --target=x86_64-pc-freebsd -static %s \ // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-STATIC %s // CHECK-STATIC: ld{{.*}}" "--eh-frame-hdr" "-Bstatic" // CHECK-STATIC: crt1.o // CHECK-STATIC: crtbeginT.o -// RUN: %clang --target=x86_64-pc-freebsd8 -shared %s \ +// RUN: %clang --target=x86_64-pc-freebsd -shared %s \ // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-SHARED %s // CHECK-SHARED: crti.o // CHECK-SHARED: crtbeginS.o -// RUN: %clang --target=x86_64-pc-freebsd8 -pie %s \ +// RUN: %clang --target=x86_64-pc-freebsd -pie %s \ // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-PIE %s // CHECK-PIE: pie // CHECK-PIE: Scrt1.o // CHECK-PIE: crtbeginS.o -// RUN: %clang --target=x86_64-pc-freebsd8 %s \ +// RUN: %clang --target=x86_64-pc-freebsd %s \ // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NORMAL %s // CHECK-NORMAL: crt1.o @@ -169,11 +164,11 @@ // CHECK-ARM-EABIHF-NOT: as{{.*}}" "-mfpu=softvfp" // CHECK-ARM-EABIHF-NOT: as{{.*}}" "-matpcs" -// RUN: %clang --target=sparc-unknown-freebsd8 -### %s -fpic -no-integrated-as 2>&1 \ +// RUN: %clang --target=sparc-unknown-freebsd -### %s -fpic -no-integrated-as 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-SPARC-PIE %s // CHECK-SPARC-PIE: as{{.*}}" "-KPIC -// RUN: %clang -mcpu=ultrasparc --target=sparc64-unknown-freebsd8 -### %s -no-integrated-as 2>&1 \ +// RUN: %clang -mcpu=ultrasparc --target=sparc64-unknown-freebsd -### %s -no-integrated-as 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-SPARC-CPU %s // CHECK-SPARC-CPU: cc1{{.*}}" "-target-cpu" "ultrasparc" // CHECK-SPARC-CPU: as{{.*}}" "-Av9a diff --git a/clang/test/Driver/freebsd.cpp b/clang/test/Driver/freebsd.cpp --- a/clang/test/Driver/freebsd.cpp +++ b/clang/test/Driver/freebsd.cpp @@ -2,11 +2,8 @@ // RUN: | FileCheck --check-prefix=CHECK-DEFAULT %s // RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd10.0 -stdlib=platform 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-TEN %s -// RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd9.2 -stdlib=platform 2>&1 \ -// RUN: | FileCheck --check-prefix=CHECK-NINE %s // CHECK-DEFAULT: "-lc++" "-lm" // CHECK-TEN: "-lc++" "-lm" -// CHECK-NINE: "-lstdc++" "-lm" // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd -stdlib=platform 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-PG-DEFAULT %s @@ -14,12 +11,9 @@ // RUN: | FileCheck --check-prefix=CHECK-PG-FOURTEEN %s // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 -stdlib=platform 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-PG-TEN %s -// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 -stdlib=platform 2>&1 \ -// RUN: | FileCheck --check-prefix=CHECK-PG-NINE %s // CHECK-PG-DEFAULT: "-lc++" "-lm" // CHECK-PG-FOURTEEN: "-lc++" "-lm" // CHECK-PG-TEN: "-lc++_p" "-lm_p" -// CHECK-PG-NINE: "-lstdc++_p" "-lm_p" // Test include paths with a sysroot. // RUN: %clangxx %s -### -fsyntax-only 2>&1 \