[clang] 3197357 - Revert "[clang] Match -isysroot behaviour with system compiler on Darwin"
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 23 14:50:10 PDT 2023
Author: Alex Lorenz
Date: 2023-08-23T14:50:02-07:00
New Revision: 3197357b7e39a58bc7eb0600eb337ac2a1c8c225
URL: https://github.com/llvm/llvm-project/commit/3197357b7e39a58bc7eb0600eb337ac2a1c8c225
DIFF: https://github.com/llvm/llvm-project/commit/3197357b7e39a58bc7eb0600eb337ac2a1c8c225.diff
LOG: Revert "[clang] Match -isysroot behaviour with system compiler on Darwin"
This reverts commit f24aa691aa4f25291db8f7c61c6e9007288859e7.
This change caused these two test failures on Darwin CI:
Clang.Tooling.clang-check-mac-libcxx-abspath.cpp
Clang.Tooling.clang-check-mac-libcxx-relpath.cpp
https://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/37169/
More info in https://reviews.llvm.org/D157283
Added:
Modified:
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-header-search-libcxx.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 5d8f006252fd9d..e45424a5f712a0 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2465,7 +2465,8 @@ void DarwinClang::AddClangCXXStdlibIncludeArgs(
// Also check whether this is used for setting library search paths.
ToolChain::AddClangCXXStdlibIncludeArgs(DriverArgs, CC1Args);
- if (DriverArgs.hasArg(options::OPT_nostdlibinc, options::OPT_nostdincxx))
+ if (DriverArgs.hasArg(options::OPT_nostdinc, options::OPT_nostdlibinc,
+ options::OPT_nostdincxx))
return;
llvm::SmallString<128> Sysroot = GetEffectiveSysroot(DriverArgs);
@@ -2473,8 +2474,8 @@ void DarwinClang::AddClangCXXStdlibIncludeArgs(
switch (GetCXXStdlibType(DriverArgs)) {
case ToolChain::CST_Libcxx: {
// On Darwin, libc++ can be installed in one of the following two places:
- // 1. In a SDK (or a custom sysroot) in <sysroot>/usr/include/c++/v1
- // 2. Alongside the compiler in <install>/include/c++/v1
+ // 1. Alongside the compiler in <install>/include/c++/v1
+ // 2. In a SDK (or a custom sysroot) in <sysroot>/usr/include/c++/v1
//
// The precendence of paths is as listed above, i.e. we take the first path
// that exists. Also note that we never include libc++ twice -- we take the
@@ -2482,17 +2483,6 @@ void DarwinClang::AddClangCXXStdlibIncludeArgs(
// include_next could break).
// Check for (1)
- llvm::SmallString<128> SysrootUsr = Sysroot;
- llvm::sys::path::append(SysrootUsr, "usr", "include", "c++", "v1");
- if (getVFS().exists(SysrootUsr)) {
- addSystemInclude(DriverArgs, CC1Args, SysrootUsr);
- return;
- } else if (DriverArgs.hasArg(options::OPT_v)) {
- llvm::errs() << "ignoring nonexistent directory \"" << SysrootUsr
- << "\"\n";
- }
-
- // Otherwise, check for (2)
// Get from '<install>/bin' to '<install>/include/c++/v1'.
// Note that InstallBin can be relative, so we use '..' instead of
// parent_path.
@@ -2507,6 +2497,17 @@ void DarwinClang::AddClangCXXStdlibIncludeArgs(
<< "\"\n";
}
+ // Otherwise, check for (2)
+ llvm::SmallString<128> SysrootUsr = Sysroot;
+ llvm::sys::path::append(SysrootUsr, "usr", "include", "c++", "v1");
+ if (getVFS().exists(SysrootUsr)) {
+ addSystemInclude(DriverArgs, CC1Args, SysrootUsr);
+ return;
+ } else if (DriverArgs.hasArg(options::OPT_v)) {
+ llvm::errs() << "ignoring nonexistent directory \"" << SysrootUsr
+ << "\"\n";
+ }
+
// Otherwise, don't add any path.
break;
}
diff --git a/clang/test/Driver/darwin-header-search-libcxx.cpp b/clang/test/Driver/darwin-header-search-libcxx.cpp
index 4929511cd00af6..cc8ec9ceb89b3a 100644
--- a/clang/test/Driver/darwin-header-search-libcxx.cpp
+++ b/clang/test/Driver/darwin-header-search-libcxx.cpp
@@ -53,7 +53,7 @@
// CHECK-LIBCXX-SYSROOT-1-NOT: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
// Check with both headers in the sysroot and headers alongside the installation
-// (the <sysroot> headers should be preferred over the headers in the toolchain).
+// (the headers in the toolchain should be preferred over the <sysroot> headers).
// Ensure that both -isysroot and --sysroot work, and that isysroot has precedence
// over --sysroot.
//
@@ -89,10 +89,10 @@
// RUN: --check-prefix=CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1 %s
//
// CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1: "-cc1"
-// CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
-// CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1-NOT: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
+// CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
+// CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
-// Make sure that using -nostdinc++ or -nostdlib will drop both the toolchain
+// Make sure that using -nostdinc, -nostdinc++ or -nostdlib will drop both the toolchain
// C++ include path and the sysroot one.
//
// RUN: %clang -### %s -fsyntax-only 2>&1 \
@@ -104,9 +104,9 @@
// RUN: -nostdinc \
// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \
// RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
-// RUN: --check-prefix=CHECK-LIBCXX-NOSTDINC %s
+// RUN: --check-prefix=CHECK-LIBCXX-NOSTDLIBINC %s
// CHECK-LIBCXX-NOSTDINC: "-cc1"
-// CHECK-LIBCXX-NOSTDINC: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
+// CHECK-LIBCXX-NOSTDINC-NOT: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
// CHECK-LIBCXX-NOSTDINC-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
//
// RUN: %clang -### %s -fsyntax-only 2>&1 \
@@ -157,8 +157,8 @@
// RUN: | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_no_libcxx \
// RUN: -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx \
// RUN: --check-prefix=CHECK-LIBCXX-MISSING-BOTH %s
-// CHECK-LIBCXX-MISSING-BOTH: ignoring nonexistent directory "[[SYSROOT]]/usr/include/c++/v1"
// CHECK-LIBCXX-MISSING-BOTH: ignoring nonexistent directory "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
+// CHECK-LIBCXX-MISSING-BOTH: ignoring nonexistent directory "[[SYSROOT]]/usr/include/c++/v1"
// Make sure that on Darwin, we use libc++ header search paths by default even when
// -stdlib= isn't passed.
More information about the cfe-commits
mailing list