https://github.com/banach-space created https://github.com/llvm/llvm-project/pull/75393
Direct follow-up of #7312 - the linker on Darwin does not support `-whole-archive`, so that needs to be removed from the linker invocation. For context: * https://github.com/llvm/llvm-project/pull/7312 From 954ebbb19c7e0fa126cf55f34d8437a89a84010e Mon Sep 17 00:00:00 2001 From: Andrzej Warzynski <andrzej.warzyn...@arm.com> Date: Wed, 13 Dec 2023 22:05:07 +0000 Subject: [PATCH] [flang][driver] Don't use -whole-archive on Darwin Direct follow-up of #7312 - the linker on Darwin does not support `-whole-archive`, so that needs to be removed from the linker invocation. For context: * https://github.com/llvm/llvm-project/pull/7312 --- clang/lib/Driver/ToolChains/CommonArgs.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 51b336216c5653..4ce456d52c3e5e 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1128,20 +1128,24 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args, // --whole-archive flag to the link line. If it's not, add a proper // --whole-archive/--no-whole-archive bracket to the link line. bool WholeArchiveActive = false; - for (auto *Arg : Args.filtered(options::OPT_Wl_COMMA)) - if (Arg) + for (auto *Arg : Args.filtered(options::OPT_Wl_COMMA)) { + if (Arg) { for (StringRef ArgValue : Arg->getValues()) { if (ArgValue == "--whole-archive") WholeArchiveActive = true; if (ArgValue == "--no-whole-archive") WholeArchiveActive = false; } + } + } - if (!WholeArchiveActive) + if (!WholeArchiveActive && !TC.getTriple().isMacOSX()) { CmdArgs.push_back("--whole-archive"); - CmdArgs.push_back("-lFortran_main"); - if (!WholeArchiveActive) + CmdArgs.push_back("-lFortran_main"); CmdArgs.push_back("--no-whole-archive"); + } else { + CmdArgs.push_back("-lFortran_main"); + } // Perform regular linkage of the remaining runtime libraries. CmdArgs.push_back("-lFortranRuntime"); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits