[clang] 2dec2aa - [Driver] Default to libc++ on FreeBSD

Ed Maste via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 22 13:47:26 PST 2021


Author: Jan Beich
Date: 2021-11-22T16:47:03-05:00
New Revision: 2dec2aa3ad083dbde838809f0e8c7ae31110e111

URL: https://github.com/llvm/llvm-project/commit/2dec2aa3ad083dbde838809f0e8c7ae31110e111
DIFF: https://github.com/llvm/llvm-project/commit/2dec2aa3ad083dbde838809f0e8c7ae31110e111.diff

LOG: [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

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/FreeBSD.cpp
    clang/test/Driver/freebsd.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index dc05f9893465..d08ea282f6df 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 d199f6e2367a..512d29eeb64a 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"


        


More information about the cfe-commits mailing list