https://github.com/banach-space updated https://github.com/llvm/llvm-project/pull/75393
From 95b4db0690d5725011a741f81237f5954bc08ff8 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 1/3] [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 | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 01fb0718b4079d..ac1abd82e49768 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1132,24 +1132,29 @@ 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"); + CmdArgs.push_back("-lFortranDecimal"); } - // Perform regular linkage of the remaining runtime libraries. - CmdArgs.push_back("-lFortranRuntime"); - CmdArgs.push_back("-lFortranDecimal"); } else { if (LinkFortranMain) { unsigned RTOptionID = options::OPT__SLASH_MT; From fd2c65b26ad8233cf686af84359f9a3c88cbe3ac Mon Sep 17 00:00:00 2001 From: Andrzej Warzynski <andrzej.warzyn...@arm.com> Date: Thu, 14 Dec 2023 12:40:39 +0000 Subject: [PATCH 2/3] fixup! [flang][driver] Don't use -whole-archive on Darwin Add an extra comment --- clang/lib/Driver/ToolChains/CommonArgs.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index ac1abd82e49768..3d1df58190ce05 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1143,6 +1143,7 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args, } } + // TODO: Find an equivalent of `--whole-archive` for Darwin. if (!WholeArchiveActive && !TC.getTriple().isMacOSX()) { CmdArgs.push_back("--whole-archive"); CmdArgs.push_back("-lFortran_main"); From aed183e576c571e6927ec6f451b5cd0b798c20eb Mon Sep 17 00:00:00 2001 From: Andrzej Warzynski <andrzej.warzyn...@arm.com> Date: Thu, 14 Dec 2023 17:32:08 +0000 Subject: [PATCH 3/3] fixup! [flang][driver] Don't use -whole-archive on Darwin Disable the test on Darwin --- flang/test/Driver/no-duplicate-main.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flang/test/Driver/no-duplicate-main.f90 b/flang/test/Driver/no-duplicate-main.f90 index 12d5e46247bad2..b884e7ecd7f12a 100644 --- a/flang/test/Driver/no-duplicate-main.f90 +++ b/flang/test/Driver/no-duplicate-main.f90 @@ -1,4 +1,4 @@ -! UNSUPPORTED: system-windows +! UNSUPPORTED: system-windows, system-darwin ! RUN: %flang -x ir -o %t.c-object -c %S/Inputs/no_duplicate_main.ll ! RUN: %flang -o %t -c %s _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits