-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FreeBSD] Support -stdlib=libstdc++ #126302
[FreeBSD] Support -stdlib=libstdc++ #126302
Conversation
Created using spr 1.3.6-beta.1
@llvm/pr-subscribers-clang Author: Alexander Richardson (arichardson) ChangesThe experimental-library-flag.cpp test was failing on FreeBSD builders, Full diff: https://github.com/llvm/llvm-project/pull/126302.diff 3 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index a6d859f0ebfec23..bd6ab0f8aba5768 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -452,12 +452,12 @@ void FreeBSD::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
+ Generic_ELF::AddCXXStdlibLibArgs(Args, CmdArgs);
unsigned Major = getTriple().getOSMajorVersion();
- bool Profiling = Args.hasArg(options::OPT_pg) && Major != 0 && Major < 14;
-
- CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
- if (Args.hasArg(options::OPT_fexperimental_library))
- CmdArgs.push_back("-lc++experimental");
+ bool SuffixedLib = Args.hasArg(options::OPT_pg) && Major != 0 && Major < 14;
+ if (SuffixedLib && GetCXXStdlibType(Args) == CST_Libcxx)
+ llvm::replace(CmdArgs, static_cast<const char *>("-lc++"),
+ static_cast<const char *>("-lc++_p"));
}
void FreeBSD::AddCudaIncludeArgs(const ArgList &DriverArgs,
diff --git a/clang/test/Driver/experimental-library-flag.cpp b/clang/test/Driver/experimental-library-flag.cpp
index db6a90b50f2553c..62b007516897e4b 100644
--- a/clang/test/Driver/experimental-library-flag.cpp
+++ b/clang/test/Driver/experimental-library-flag.cpp
@@ -9,6 +9,11 @@
// RUN: %clangxx -fexperimental-library -stdlib=libstdc++ -### %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-LIBSTDCXX %s
// RUN: %clangxx -fexperimental-library -stdlib=libc++ -nostdlib++ -### %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-NOSTDLIB %s
+/// The FreeBSD driver did not support -stdlib=libstdc++ previously, check that it does the right thing here.
+// RUN: %clangxx --target=x86_64-unknown-freebsd -fexperimental-library -stdlib=libc++ -### %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-LIBCXX %s
+// RUN: %clangxx --target=x86_64-unknown-freebsd -fexperimental-library -stdlib=libstdc++ -### %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-LIBSTDCXX %s
+// RUN: %clangxx --target=x86_64-unknown-freebsd -fexperimental-library -stdlib=libc++ -nostdlib++ -### %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-NOSTDLIB %s
+
// -fexperimental-library must be passed to CC1.
// CHECK: -fexperimental-library
diff --git a/clang/test/Driver/freebsd.cpp b/clang/test/Driver/freebsd.cpp
index dc8c98d3c3cb749..af6b873a387f13c 100644
--- a/clang/test/Driver/freebsd.cpp
+++ b/clang/test/Driver/freebsd.cpp
@@ -1,9 +1,13 @@
// 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: | FileCheck --check-prefix=CHECK-DEFAULT %s
+// RUN: %clangxx %s -### -o %t.o --target=amdf64-unknown-freebsd -stdlib=libc++ 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-DEFAULT %s
+// RUN: %clangxx %s -### -o %t.o --target=amd64-unknown-freebsd -stdlib=libstdc++ 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-STDLIBCXX %s
// CHECK-DEFAULT: "-lc++" "-lm"
-// CHECK-TEN: "-lc++" "-lm"
+// CHECK-STDLIBCXX: "-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
|
@llvm/pr-subscribers-clang-driver Author: Alexander Richardson (arichardson) ChangesThe experimental-library-flag.cpp test was failing on FreeBSD builders, Full diff: https://github.com/llvm/llvm-project/pull/126302.diff 3 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index a6d859f0ebfec23..bd6ab0f8aba5768 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -452,12 +452,12 @@ void FreeBSD::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
+ Generic_ELF::AddCXXStdlibLibArgs(Args, CmdArgs);
unsigned Major = getTriple().getOSMajorVersion();
- bool Profiling = Args.hasArg(options::OPT_pg) && Major != 0 && Major < 14;
-
- CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
- if (Args.hasArg(options::OPT_fexperimental_library))
- CmdArgs.push_back("-lc++experimental");
+ bool SuffixedLib = Args.hasArg(options::OPT_pg) && Major != 0 && Major < 14;
+ if (SuffixedLib && GetCXXStdlibType(Args) == CST_Libcxx)
+ llvm::replace(CmdArgs, static_cast<const char *>("-lc++"),
+ static_cast<const char *>("-lc++_p"));
}
void FreeBSD::AddCudaIncludeArgs(const ArgList &DriverArgs,
diff --git a/clang/test/Driver/experimental-library-flag.cpp b/clang/test/Driver/experimental-library-flag.cpp
index db6a90b50f2553c..62b007516897e4b 100644
--- a/clang/test/Driver/experimental-library-flag.cpp
+++ b/clang/test/Driver/experimental-library-flag.cpp
@@ -9,6 +9,11 @@
// RUN: %clangxx -fexperimental-library -stdlib=libstdc++ -### %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-LIBSTDCXX %s
// RUN: %clangxx -fexperimental-library -stdlib=libc++ -nostdlib++ -### %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-NOSTDLIB %s
+/// The FreeBSD driver did not support -stdlib=libstdc++ previously, check that it does the right thing here.
+// RUN: %clangxx --target=x86_64-unknown-freebsd -fexperimental-library -stdlib=libc++ -### %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-LIBCXX %s
+// RUN: %clangxx --target=x86_64-unknown-freebsd -fexperimental-library -stdlib=libstdc++ -### %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-LIBSTDCXX %s
+// RUN: %clangxx --target=x86_64-unknown-freebsd -fexperimental-library -stdlib=libc++ -nostdlib++ -### %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-NOSTDLIB %s
+
// -fexperimental-library must be passed to CC1.
// CHECK: -fexperimental-library
diff --git a/clang/test/Driver/freebsd.cpp b/clang/test/Driver/freebsd.cpp
index dc8c98d3c3cb749..af6b873a387f13c 100644
--- a/clang/test/Driver/freebsd.cpp
+++ b/clang/test/Driver/freebsd.cpp
@@ -1,9 +1,13 @@
// 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: | FileCheck --check-prefix=CHECK-DEFAULT %s
+// RUN: %clangxx %s -### -o %t.o --target=amdf64-unknown-freebsd -stdlib=libc++ 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-DEFAULT %s
+// RUN: %clangxx %s -### -o %t.o --target=amd64-unknown-freebsd -stdlib=libstdc++ 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-STDLIBCXX %s
// CHECK-DEFAULT: "-lc++" "-lm"
-// CHECK-TEN: "-lc++" "-lm"
+// CHECK-STDLIBCXX: "-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
|
Created using spr 1.3.6-beta.1
It's not missing as in like someone forgot. It is intentional. Same goes for FreeBSD and OpenBSD's Drivers. The base OS uses libc++ and anything else is not supported. |
You can install it from ports though and it should be possible to use that? |
ping, is this ok to merge? |
You could use it with a libstdc++ from ports. GCC supports both variants for the same reason. FreeBSD's default GCC ports include libstdc++ which is used for 3rd party packages built with GCC instead of clang. I also suggested this approach to Alex for fixing the test failure. I'd really rather the option "work". I depend on the option working in the reverse when using GCC to build FreeBSD's base system (that is, -stdlib=c++). Someone using -stdlib=stdc++ should get what they have explicitly asked for. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code/test looks good for me as a driver maintainer. Needs a stamp from a FreeBSD reviewer.
Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1
The experimental-library-flag.cpp test was failing on FreeBSD builders, which turned to be caused by missing support for -stdlib=libcstdc++ (and just using a hardcoded libc++ in all cases). Simplify FreeBSD::AddCXXStdlibLibArgs() by deferring to the parent class and dealing with the FreeSBD < 14 profiling support as a special case. While touching the test file also drop the unnecessary `-o %t.o`. This is not needed since the RUN lines use -### and don't produce any output. Reviewed By: DimitryAndric, MaskRay Pull Request: llvm/llvm-project#126302 (cherry picked from commit f75126eeabba13ce2aab53c2e4296fca12b9da0d)
The experimental-library-flag.cpp test was failing on FreeBSD builders, which turned to be caused by missing support for -stdlib=libcstdc++ (and just using a hardcoded libc++ in all cases). Simplify FreeBSD::AddCXXStdlibLibArgs() by deferring to the parent class and dealing with the FreeSBD < 14 profiling support as a special case. While touching the test file also drop the unnecessary `-o %t.o`. This is not needed since the RUN lines use -### and don't produce any output. Reviewed By: DimitryAndric, MaskRay Pull Request: llvm/llvm-project#126302
The experimental-library-flag.cpp test was failing on FreeBSD builders, which turned to be caused by missing support for -stdlib=libcstdc++ (and just using a hardcoded libc++ in all cases). Simplify FreeBSD::AddCXXStdlibLibArgs() by deferring to the parent class and dealing with the FreeSBD < 14 profiling support as a special case. While touching the test file also drop the unnecessary `-o %t.o`. This is not needed since the RUN lines use -### and don't produce any output. Reviewed By: DimitryAndric, MaskRay Pull Request: llvm/llvm-project#126302 (cherry picked from commit f75126eeabba13ce2aab53c2e4296fca12b9da0d)
The experimental-library-flag.cpp test was failing on FreeBSD builders, which turned to be caused by missing support for -stdlib=libcstdc++ (and just using a hardcoded libc++ in all cases). Simplify FreeBSD::AddCXXStdlibLibArgs() by deferring to the parent class and dealing with the FreeSBD < 14 profiling support as a special case. While touching the test file also drop the unnecessary `-o %t.o`. This is not needed since the RUN lines use -### and don't produce any output. Reviewed By: DimitryAndric, MaskRay Pull Request: llvm/llvm-project#126302 (cherry picked from commit f75126eeabba13ce2aab53c2e4296fca12b9da0d)
The experimental-library-flag.cpp test was failing on FreeBSD builders,
which turned to be caused by missing support for -stdlib=libcstdc++ (and
just using a hardcoded libc++ in all cases).
Simplify FreeBSD::AddCXXStdlibLibArgs() by deferring to the parent class
and dealing with the FreeSBD < 14 profiling support as a special case.
While touching the test file also drop the unnecessary
-o %t.o
. This isnot needed since the RUN lines use -### and don't produce any output.