diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2022-07-24 15:11:41 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2023-02-08 19:04:38 +0000 |
commit | fcaf7f8644a9988098ac6be2165bce3ea4786e91 (patch) | |
tree | 08a554363df16b968a623d651c09d82a5a0b1c65 /contrib/llvm-project/clang/lib/Driver/ToolChains/Darwin.cpp | |
parent | 753f127f3ace09432b2baeffd71a308760641a62 (diff) | |
parent | 4b4fe385e49bd883fd183b5f21c1ea486c722e61 (diff) | |
download | src-fcaf7f8644a9988098ac6be2165bce3ea4786e91.tar.gz src-fcaf7f8644a9988098ac6be2165bce3ea4786e91.zip |
Diffstat (limited to 'contrib/llvm-project/clang/lib/Driver/ToolChains/Darwin.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Driver/ToolChains/Darwin.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/Darwin.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/Darwin.cpp index c9e773701ac3..bada811daadf 100644 --- a/contrib/llvm-project/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1141,25 +1141,38 @@ void DarwinClang::AddLinkARCArgs(const ArgList &Args, SmallString<128> P(getDriver().ClangExecutable); llvm::sys::path::remove_filename(P); // 'clang' llvm::sys::path::remove_filename(P); // 'bin' + llvm::sys::path::append(P, "lib", "arc"); // 'libarclite' usually lives in the same toolchain as 'clang'. However, the // Swift open source toolchains for macOS distribute Clang without libarclite. // In that case, to allow the linker to find 'libarclite', we point to the // 'libarclite' in the XcodeDefault toolchain instead. - if (getXcodeDeveloperPath(P).empty()) { - if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) { + if (!getVFS().exists(P)) { + auto updatePath = [&](const Arg *A) { // Try to infer the path to 'libarclite' in the toolchain from the // specified SDK path. StringRef XcodePathForSDK = getXcodeDeveloperPath(A->getValue()); - if (!XcodePathForSDK.empty()) { - P = XcodePathForSDK; - llvm::sys::path::append(P, "Toolchains/XcodeDefault.xctoolchain/usr"); - } + if (XcodePathForSDK.empty()) + return false; + + P = XcodePathForSDK; + llvm::sys::path::append(P, "Toolchains/XcodeDefault.xctoolchain/usr", + "lib", "arc"); + return getVFS().exists(P); + }; + + bool updated = false; + if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) + updated = updatePath(A); + + if (!updated) { + if (const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ)) + updatePath(A); } } CmdArgs.push_back("-force_load"); - llvm::sys::path::append(P, "lib", "arc", "libarclite_"); + llvm::sys::path::append(P, "libarclite_"); // Mash in the platform. if (isTargetWatchOSSimulator()) P += "watchsimulator"; @@ -2448,6 +2461,7 @@ void DarwinClang::AddClangCXXStdlibIncludeArgs( break; } } + void DarwinClang::AddCXXStdlibLibArgs(const ArgList &Args, ArgStringList &CmdArgs) const { CXXStdlibType Type = GetCXXStdlibType(Args); @@ -2455,6 +2469,8 @@ void DarwinClang::AddCXXStdlibLibArgs(const ArgList &Args, switch (Type) { case ToolChain::CST_Libcxx: CmdArgs.push_back("-lc++"); + if (Args.hasArg(options::OPT_fexperimental_library)) + CmdArgs.push_back("-lc++experimental"); break; case ToolChain::CST_Libstdcxx: |