[clang] [flang][driver] Don't use -whole-archive on Darwin (PR #75393)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 13 14:08:27 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-driver
@llvm/pr-subscribers-clang
Author: Andrzej WarzyĆski (banach-space)
<details>
<summary>Changes</summary>
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
---
Full diff: https://github.com/llvm/llvm-project/pull/75393.diff
1 Files Affected:
- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+9-5)
``````````diff
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");
``````````
</details>
https://github.com/llvm/llvm-project/pull/75393
More information about the cfe-commits
mailing list