From 2dec2aa3ad083dbde838809f0e8c7ae31110e111 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Mon, 22 Nov 2021 11:32:58 -0500 Subject: [PATCH] [Driver] Default to libc++ on FreeBSD All supported FreeBSD releases use libc++, so default to it if the target's major version is not specified. Reviewed by: dim, emaste Differential Revision: https://reviews.llvm.org/D77776 --- clang/lib/Driver/ToolChains/FreeBSD.cpp | 3 ++- clang/test/Driver/freebsd.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp index dc05f98..d08ea28 100644 --- a/clang/lib/Driver/ToolChains/FreeBSD.cpp +++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp @@ -391,7 +391,8 @@ FreeBSD::FreeBSD(const Driver &D, const llvm::Triple &Triple, } ToolChain::CXXStdlibType FreeBSD::GetDefaultCXXStdlibType() const { - if (getTriple().getOSMajorVersion() >= 10) + unsigned Major = getTriple().getOSMajorVersion(); + if (Major >= 10 || Major == 0) return ToolChain::CST_Libcxx; return ToolChain::CST_Libstdcxx; } diff --git a/clang/test/Driver/freebsd.cpp b/clang/test/Driver/freebsd.cpp index d199f6e..512d29e 100644 --- a/clang/test/Driver/freebsd.cpp +++ b/clang/test/Driver/freebsd.cpp @@ -1,16 +1,22 @@ +// RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd -stdlib=platform 2>&1 \ +// 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 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd14.0 -stdlib=platform 2>&1 \ // 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++_p" "-lm_p" // CHECK-PG-FOURTEEN: "-lc++" "-lm" // CHECK-PG-TEN: "-lc++_p" "-lm_p" // CHECK-PG-NINE: "-lstdc++_p" "-lm_p" -- 2.7.4