diff options
author | Ian Anderson <iana@apple.com> | 2025-01-07 21:13:49 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-07 21:13:49 -0800 |
commit | d6bfe10ac9963eb63e141d6c50e9a183c08d35da (patch) | |
tree | 26b79873bdf2b04b8c5e7c2716a612665e6ac0b1 /clang/lib/Frontend/InitPreprocessor.cpp | |
parent | 162814a7ec00e2c89693f96568b72956d1bf2f0f (diff) | |
download | llvm-d6bfe10ac9963eb63e141d6c50e9a183c08d35da.zip llvm-d6bfe10ac9963eb63e141d6c50e9a183c08d35da.tar.gz llvm-d6bfe10ac9963eb63e141d6c50e9a183c08d35da.tar.bz2 |
[Darwin][Driver][clang] apple-none-macho orders the resource directory after internal-externc-isystem when nostdlibinc is used (#122035)
Embedded development often needs to use a different C standard library,
replacing the existing one normally passed as -internal-externc-isystem.
This works fine for an apple-macos target, but apple-none-macho doesn't
work because the MachO driver doesn't implement
AddClangSystemIncludeArgs to add the resource directory as
-internal-isystem like most other drivers do. Move most of the search
path logic from Darwin and DarwinClang down into an AppleMachO toolchain
between the MachO and Darwin toolchains.
Also define __MACH__ for apple-none-macho, as Swift expects all MachO
targets to have that defined.
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
-rw-r--r-- | clang/lib/Frontend/InitPreprocessor.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 29723b5..8eba766 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -1507,6 +1507,11 @@ static void InitializePredefinedMacros(const TargetInfo &TI, // ELF targets define __ELF__ if (TI.getTriple().isOSBinFormatELF()) Builder.defineMacro("__ELF__"); + else if (TI.getTriple().isAppleMachO()) + // Apple MachO targets define __MACH__ even when not using DarwinTargetInfo. + // Hurd will also define this in some circumstances, but that's done in + // HurdTargetInfo. Windows targets don't define this. + Builder.defineMacro("__MACH__"); // Target OS macro definitions. if (PPOpts.DefineTargetOSMacros) { |