https://github.com/rorth created https://github.com/llvm/llvm-project/pull/212725
`clang++` defaults to `-stdlib=libc++` on FreeBSD. When building with both `clang` and `libcxx` included, the freshly built `clang++` uses the system version of the `libc++` headers. However, this is from the bundled `libc++` 19.1.7, thus inconsistent with the `libc++` being built. Similarly to the NetBSD case, FreeBSD has its own version of `addLibCxxIncludePaths` which just includes `/usr/include/c++/v1`. Rather than replicating the generic version in `Gnu.cpp`, this patch just calls `Generic_GCC::addLibCxxIncludePaths`. Tested on `amd64-pc-freebsd15.1`. This breaks the `Driver/freebsd.cpp` and `Driver/freebsd-include-paths.c` testcases. Once it can be confirmed the approach is sound, I'll update them accordingly. >From 6c1e69756696c56672c678a111fdb5b0f4bd2005 Mon Sep 17 00:00:00 2001 From: Rainer Orth <[email protected]> Date: Wed, 29 Jul 2026 11:27:31 +0200 Subject: [PATCH] [clang][Driver] Fix libc++ include path on FreeBSD `clang++` defaults to `-stdlib=libc++` on FreeBSD. When building with both `clang` and `libcxx` included, the freshly built `clang++` uses the system version of the `libc++` headers. However, this is from the bundled `libc++` 19.1.7, thus inconsistent with the `libc++` being built. Similarly to the NetBSD case, FreeBSD has its own version of addLibCxxIncludePaths which just includes `/usr/include/c++/v1`. Rather than replicating the generic version in `Gnu.cpp`, this patch just calls `Generic_GCC::addLibCxxIncludePaths`. Tested on `amd64-pc-freebsd15.1`. This breaks the `Driver/freebsd.cpp` and `Driver/freebsd-include-paths.c` testcases. Once it can be confirmed the approach is sound, I'll update them accordingly. --- clang/lib/Driver/ToolChains/FreeBSD.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp index 724ccbefd790f..519999a9a5bcf 100644 --- a/clang/lib/Driver/ToolChains/FreeBSD.cpp +++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp @@ -10,6 +10,7 @@ #include "Arch/ARM.h" #include "Arch/Mips.h" #include "Arch/Sparc.h" +#include "Gnu.h" #include "clang/Config/config.h" #include "clang/Driver/CommonArgs.h" #include "clang/Driver/Compilation.h" @@ -434,8 +435,7 @@ void FreeBSD::AddClangSystemIncludeArgs( void FreeBSD::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const { - addSystemInclude(DriverArgs, CC1Args, - concat(getDriver().SysRoot, "/usr/include/c++/v1")); + Generic_GCC::addLibCxxIncludePaths(DriverArgs, CC1Args); } void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args, _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
