Skip to content

[clang][Darwin] Remove legacy framework search path logic in the frontend #75841

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

Merged

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Dec 18, 2023

This removes a long standing piece of technical debt. Most other platforms have moved all their header search path logic to the driver, but Darwin still had some logic for setting framework search paths present in the frontend. This patch moves that logic to the driver alongside existing logic that already handles part of these search paths.

This is intended to be a pure refactor without any functional change visible to users, since the search paths before and after should be the same, and in the same order. The change in the tests is necessary because we would previously add the DriverKit framework search path in the frontend regardless of whether we actually need to, which we now handle correctly because the driver checks for ld64-605.1+.

Fixes #75638

…tend

This removes a long standing piece of technical debt. Most other platforms
have moved all their header search path logic to the driver, but Darwin
still had some logic for setting framework search paths present in the
frontend. This patch moves that logic to the driver alongside existing
logic that already handles part of these search paths.

This is intended to be a pure refactor without any functional change
visible to users, since the search paths before and after should be the
same, and in the same order. The change in the tests is necessary because
we would previously add the DriverKit framework search path in the frontend
regardless of whether we actually need to, which we now handle correctly
because the driver checks for ld64-605.1+.

Fixes llvm#75638
@ldionne ldionne requested a review from yln December 18, 2023 18:43
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Dec 18, 2023
@llvmbot
Copy link
Member

llvmbot commented Dec 18, 2023

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Louis Dionne (ldionne)

Changes

This removes a long standing piece of technical debt. Most other platforms have moved all their header search path logic to the driver, but Darwin still had some logic for setting framework search paths present in the frontend. This patch moves that logic to the driver alongside existing logic that already handles part of these search paths.

This is intended to be a pure refactor without any functional change visible to users, since the search paths before and after should be the same, and in the same order. The change in the tests is necessary because we would previously add the DriverKit framework search path in the frontend regardless of whether we actually need to, which we now handle correctly because the driver checks for ld64-605.1+.

Fixes #75638


Full diff: https://github.com/llvm/llvm-project/pull/75841.diff

3 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/Darwin.cpp (+22-13)
  • (modified) clang/lib/Lex/InitHeaderSearch.cpp (+3-15)
  • (modified) clang/test/Driver/driverkit-path.c (-1)
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 65846cace461e3..f76a42d2d8e7e3 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -758,9 +758,14 @@ void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
     }
   }
 
-  // Add non-standard, platform-specific search paths, e.g., for DriverKit:
-  //  -L<sysroot>/System/DriverKit/usr/lib
-  //  -F<sysroot>/System/DriverKit/System/Library/Framework
+  // Add framework include paths and library search paths.
+  // There are two flavors:
+  // 1. The "non-standard" paths, e.g. for DriverKit:
+  //      -L<sysroot>/System/DriverKit/usr/lib
+  //      -F<sysroot>/System/DriverKit/System/Library/Frameworks
+  // 2. The "standard" paths, e.g. for macOS and iOS:
+  //      -F<sysroot>/System/Library/Frameworks
+  //      -F<sysroot>/Library/Frameworks
   {
     bool NonStandardSearchPath = false;
     const auto &Triple = getToolChain().getTriple();
@@ -771,18 +776,22 @@ void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
           (Version.getMajor() == 605 && Version.getMinor().value_or(0) < 1);
     }
 
-    if (NonStandardSearchPath) {
-      if (auto *Sysroot = Args.getLastArg(options::OPT_isysroot)) {
-        auto AddSearchPath = [&](StringRef Flag, StringRef SearchPath) {
-          SmallString<128> P(Sysroot->getValue());
-          AppendPlatformPrefix(P, Triple);
-          llvm::sys::path::append(P, SearchPath);
-          if (getToolChain().getVFS().exists(P)) {
-            CmdArgs.push_back(Args.MakeArgString(Flag + P));
-          }
-        };
+    if (auto *Sysroot = Args.getLastArg(options::OPT_isysroot)) {
+      auto AddSearchPath = [&](StringRef Flag, StringRef SearchPath) {
+        SmallString<128> P(Sysroot->getValue());
+        AppendPlatformPrefix(P, Triple);
+        llvm::sys::path::append(P, SearchPath);
+        if (getToolChain().getVFS().exists(P)) {
+          CmdArgs.push_back(Args.MakeArgString(Flag + P));
+        }
+      };
+
+      if (NonStandardSearchPath) {
         AddSearchPath("-L", "/usr/lib");
         AddSearchPath("-F", "/System/Library/Frameworks");
+      } else if (!Triple.isDriverKit()) {
+        AddSearchPath("-F", "/System/Library/Frameworks");
+        AddSearchPath("-F", "/Library/Frameworks");
       }
     }
   }
diff --git a/clang/lib/Lex/InitHeaderSearch.cpp b/clang/lib/Lex/InitHeaderSearch.cpp
index 2218db15013d92..1350fa5f01a578 100644
--- a/clang/lib/Lex/InitHeaderSearch.cpp
+++ b/clang/lib/Lex/InitHeaderSearch.cpp
@@ -324,6 +324,9 @@ bool InitHeaderSearch::ShouldAddDefaultIncludePaths(
     break;
   }
 
+  if (triple.isOSDarwin())
+    return false;
+
   return true; // Everything else uses AddDefaultIncludePaths().
 }
 
@@ -338,21 +341,6 @@ void InitHeaderSearch::AddDefaultIncludePaths(
   if (!ShouldAddDefaultIncludePaths(triple))
     return;
 
-  // NOTE: some additional header search logic is handled in the driver for
-  // Darwin.
-  if (triple.isOSDarwin()) {
-    if (HSOpts.UseStandardSystemIncludes) {
-      // Add the default framework include paths on Darwin.
-      if (triple.isDriverKit()) {
-        AddPath("/System/DriverKit/System/Library/Frameworks", System, true);
-      } else {
-        AddPath("/System/Library/Frameworks", System, true);
-        AddPath("/Library/Frameworks", System, true);
-      }
-    }
-    return;
-  }
-
   if (Lang.CPlusPlus && !Lang.AsmPreprocessor &&
       HSOpts.UseStandardCXXIncludes && HSOpts.UseStandardSystemIncludes) {
     if (HSOpts.UseLibcxx) {
diff --git a/clang/test/Driver/driverkit-path.c b/clang/test/Driver/driverkit-path.c
index 9699b9c01f4e81..43e5aa40fc6f31 100644
--- a/clang/test/Driver/driverkit-path.c
+++ b/clang/test/Driver/driverkit-path.c
@@ -31,4 +31,3 @@ int main() { return 0; }
 // INC:       [[PATH]]/System/DriverKit/usr/local/include
 // INC:       /lib{{(64)?}}/clang/{{[^/ ]+}}/include
 // INC:       [[PATH]]/System/DriverKit/usr/include
-// INC:       [[PATH]]/System/DriverKit/System/Library/Frameworks (framework directory)

// -F<sysroot>/System/DriverKit/System/Library/Frameworks
// 2. The "standard" paths, e.g. for macOS and iOS:
// -F<sysroot>/System/Library/Frameworks
// -F<sysroot>/Library/Frameworks
{
bool NonStandardSearchPath = false;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yln Note that I think this whole block could almost go away now. I think we always do the right thing in the linker on Apple platforms, so I don't think the driver needs any special logic for -F and -L anymore, but I could be wrong. I also wanted to keep this change minimal.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that ld64-605.1 is old enough / has "aged out" by now so we can drop this special case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is what I suspect.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, that would be another good cleanup! I recommend doing this as a separate PR.

@ldionne
Copy link
Member Author

ldionne commented Dec 18, 2023

@jlebar The CI seems to be failing due to a test you were the last to touch:

******************** TEST 'Clang :: Preprocessor/cuda-macos-includes.cu' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
[...]
error: CHECK-DAG: expected string not found in input
// CHECK-DAG: ignoring nonexistent directory "/var/empty/System/Library/Frameworks"
              ^
<stdin>:1:1: note: scanning from here

Long story short, that test was checking for the diagnostic output from the Frontend complaining that we can't find /var/empty/System/Library/Frameworks as a way to ensure that it would normally try searching in those paths for frameworks. This isn't the case anymore since the frontend doesn't know anything about these search paths, and the driver handles them instead.

This shouldn't be a problem if the normal linker is being used when linking object files produced for cuda targets, since the linker on Apple platforms nowadays knows about these search paths, and Clang doesn't really need to specify them explicitly. If that's the case, the test could simply be removed. But I don't know much about cuda, so I'd rather ask in case that's not the case.

…inker on Apple platforms already handles these paths
// -F<sysroot>/System/DriverKit/System/Library/Frameworks
// 2. The "standard" paths, e.g. for macOS and iOS:
// -F<sysroot>/System/Library/Frameworks
// -F<sysroot>/Library/Frameworks
{
bool NonStandardSearchPath = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, that would be another good cleanup! I recommend doing this as a separate PR.

@brad0
Copy link
Contributor

brad0 commented Dec 31, 2023

Update?

@ldionne
Copy link
Member Author

ldionne commented Dec 31, 2023

I think this can be merged. I would have liked to have @jlebar 's input on interactions with Cuda, but I think this is probably good enough.

@ldionne ldionne merged commit 61999b1 into llvm:main Dec 31, 2023
@ldionne ldionne deleted the review/refactor-darwin-driver-framework-paths branch December 31, 2023 10:16
@brad0
Copy link
Contributor

brad0 commented Dec 31, 2023

Thank you for the effort.

@petrhosek
Copy link
Member

This appears to have broken the LSan build which is now failing with the following error:

FAILED: compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o 
/Volumes/Work/s/w/ir/x/w/llvm_build/./bin/clang++ --target=x86_64-apple-darwin22.6.0 --sysroot=/Volumes/Work/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -DCOMPILER_RT_SHARED_LIB -D_DEBUG -D_GLIBCXX_ASSERTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Dclang_rt_lsan_osx_dynamic_EXPORTS -I/Volumes/Work/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/lsan/.. -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffile-prefix-map=/Volumes/Work/s/w/ir/x/w/llvm_build/runtimes/runtimes-bins=../../../llvm-llvm-project -ffile-prefix-map=/Volumes/Work/s/w/ir/x/w/llvm-llvm-project/= -no-canonical-prefixes -Wall -Wno-unused-parameter -O3 -DNDEBUG -std=c++17 -arch arm64 -arch x86_64 -isysroot /Volumes/Work/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -fPIC -stdlib=libc++ -mmacosx-version-min=10.10 -isysroot /Volumes/Work/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -fno-lto -fPIC -fno-builtin -fno-exceptions -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -O3 -g -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -nostdinc++ -fno-rtti -Wno-format -MD -MT compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o -MF compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o.d -o compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o -c /Volumes/Work/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/lsan/lsan_malloc_mac.cpp
In file included from /Volumes/Work/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/lsan/lsan_malloc_mac.cpp:57:
/Volumes/Work/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/lsan/../sanitizer_common/sanitizer_malloc_mac.inc:20:10: fatal error: 'CoreFoundation/CFBase.h' file not found
   20 | #include <CoreFoundation/CFBase.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

@aeubanks
Copy link
Contributor

aeubanks commented Jan 2, 2024

same in our stage 2 build

 [4643/5157] Building CXX object tools/dsymutil/CMakeFiles/dsymutil.dir/CFBundle.cpp.o
 FAILED: tools/dsymutil/CMakeFiles/dsymutil.dir/CFBundle.cpp.o 
 /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-bootstrap-install/bin/clang++ -DGTEST_HAS_RTTI=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/tools/dsymutil -I/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/llvm/tools/dsymutil -I/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/include -I/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/llvm/include -isystem /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build-tools/zstd-1.5.5/cmake_build/install/include -DSANITIZER_OVERRIDE_INTERCEPTORS -I/Volumes/Work/s/w/ir/cache/builder/src/tools/clang/scripts/sanitizers -DLIBXML_STATIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -fprofile-instr-use="/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-instrumented/profdata.prof" -O3 -DNDEBUG -std=c++17 -isysroot /Volumes/Work/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mmacosx-version-min=10.12  -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -MD -MT tools/dsymutil/CMakeFiles/dsymutil.dir/CFBundle.cpp.o -MF tools/dsymutil/CMakeFiles/dsymutil.dir/CFBundle.cpp.o.d -o tools/dsymutil/CMakeFiles/dsymutil.dir/CFBundle.cpp.o -c /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/llvm/tools/dsymutil/CFBundle.cpp
 /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/llvm/tools/dsymutil/CFBundle.cpp:15:10: fatal error: 'CoreFoundation/CoreFoundation.h' file not found
    15 | #include <CoreFoundation/CoreFoundation.h>
       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1 error generated.

if this is intended to be NFC but isn't, then we should probably revert

aeubanks added a commit that referenced this pull request Jan 2, 2024
…the frontend (#75841)"

This reverts commit 61999b1.

See comments on #75841. This
was intended to be NFC but actually isn't.
@aeubanks
Copy link
Contributor

aeubanks commented Jan 2, 2024

I've reverted this, hopefully the command line in the failing invocation I gave is enough to repro the regression, otherwise lmk what else I can do to help repro

@fhahn
Copy link
Contributor

fhahn commented Jan 2, 2024

@aeubanks thanks for the revert!

@ldionne
Copy link
Member Author

ldionne commented Jan 8, 2024

@aeubanks @petrhosek Can you folks share what was the top level invocations you did to get those errors? I am having trouble understanding the problem just from the pasted errors.

@aeubanks
Copy link
Contributor

is the clang invocation in the logs I posted sufficient?

@ldionne
Copy link
Member Author

ldionne commented Jan 11, 2024

No, I would like to reproduce locally (and there are too many things specific to the setup in the clang command line for me to)

@ldionne
Copy link
Member Author

ldionne commented Jan 16, 2024

Ping. I don't know how to fix the issue, I need some help.

@aeubanks
Copy link
Contributor

sorry, I keep missing notifications, will find a repro

@alanzhao1
Copy link
Contributor

Here's what I did to repro:

include.cc:

#include <CoreFoundation/CoreFoundation.h>

Build clang:

$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_LLD=False -DLLVM_CCACHE_BUILD=True -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" ../llvm
$ ninja clang

I get the following error with this patch:

$ bin/clang -c -o /dev/null ~/src/tests/include.cc -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/
/Users/ayzhao/src/tests/include.cc:1:10: fatal error: 'CoreFoundation/CoreFoundation.h' file not found
    1 | #include <CoreFoundation/CoreFoundation.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

System information:

$ xcodebuild -version
Xcode 13.4
Build version 13F17a
$ uname -a
Darwin ayzhao-macbookpro2.roam.internal 23.3.0 Darwin Kernel Version 23.3.0: Thu Jan  4 13:52:35 PST 2024; root:xnu-10002.81.5~13/RELEASE_ARM64_T6000 arm64

@alanzhao1
Copy link
Contributor

If we pass -v to Clang, we get the following include directories:

without this patch:

clang -cc1 version 18.0.0git based upon LLVM 18.0.0git default target arm64-apple-darwin23.3.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk//Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1
 /Users/ayzhao/src/llvm-project/build/lib/clang/18/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk//System/Library/Frameworks (framework directory)
End of search list.

with this patch:

clang -cc1 version 18.0.0git based upon LLVM 18.0.0git default target arm64-apple-darwin23.3.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1
 /Users/ayzhao/src/llvm-project/build/lib/clang/18/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
End of search list.

So it looks like this patch causes Clang to think that the directory /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk//Library/Frameworks exists when it doesn't.

@brad0
Copy link
Contributor

brad0 commented Jan 27, 2024

Able to look at this further?

@brad0
Copy link
Contributor

brad0 commented Feb 6, 2024

Ping.

@brad0
Copy link
Contributor

brad0 commented Feb 25, 2024

Any chance of reviving this?

@brad0
Copy link
Contributor

brad0 commented Jun 7, 2024

@ldionne Ping.

ldionne added a commit to ldionne/llvm-project that referenced this pull request Dec 16, 2024
…tend

This removes a long standing piece of technical debt. Most other platforms
have moved all their header search path logic to the driver, but Darwin
still had some logic for setting framework search paths present in the
frontend. This patch moves that logic to the driver alongside existing
logic that already handles part of these search paths.

To achieve parity with the previous search path order, this patch
introduces the -internal-iframework flag which is used to pass
system framework paths from the driver to the frontend. These paths
are handled specially in that they are added after normal framework
search paths, which preserves the old frontend behavior for system
frameworks.

This patch is a re-application of llvm#75841
which was reverted in d34901f because it broke framework search paths.
In fact, the original patch was only adding framework search paths to
the linker job, but was not adding search paths for finding headers.
That issue is resolved in this version of the patch, with added tests.

Fixes llvm#75638
@ldionne
Copy link
Member Author

ldionne commented Dec 16, 2024

@brad0 Revived as #120149

@ldionne ldionne requested review from cachemeifyoucan, cyndyishida and jhuber6 and removed request for cachemeifyoucan, cyndyishida and jhuber6 December 16, 2024 21:36
@ldionne
Copy link
Member Author

ldionne commented Dec 16, 2024

Sorry for the spurious request for review here, this is the wrong PR.

ldionne added a commit to ldionne/llvm-project that referenced this pull request Jan 7, 2025
…tend

This removes a long standing piece of technical debt. Most other platforms
have moved all their header search path logic to the driver, but Darwin
still had some logic for setting framework search paths present in the
frontend. This patch moves that logic to the driver alongside existing
logic that already handles part of these search paths.

To achieve parity with the previous search path order, this patch
introduces the -internal-iframework flag which is used to pass
system framework paths from the driver to the frontend. These paths
are handled specially in that they are added after normal framework
search paths, which preserves the old frontend behavior for system
frameworks.

This patch is a re-application of llvm#75841
which was reverted in d34901f because it broke framework search paths.
In fact, the original patch was only adding framework search paths to
the linker job, but was not adding search paths for finding headers.
That issue is resolved in this version of the patch, with added tests.

Fixes llvm#75638
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Driver][Darwin] Move the remaining bits for header path handling over to the Driver.
8 participants