Skip to content

Conversation

@anchuraj
Copy link
Contributor

@anchuraj anchuraj commented Sep 11, 2025

flto-partition helps in performing parallel lto and ffat-lto-objects allows bit code to be embedded in object files generated. This PR enables the support of these flags in flang.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' flang:driver flang Flang issues not falling into any other category labels Sep 11, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 11, 2025

@llvm/pr-subscribers-flang-driver
@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Anchu Rajendran S (anchuraj)

Changes

lto-partition helps in performing parallel lto and fat-lto-objects allows bit code to be embedded in object files generated.


Full diff: https://github.com/llvm/llvm-project/pull/158125.diff

8 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+3-2)
  • (modified) clang/lib/Driver/ToolChains/Flang.cpp (+24-11)
  • (modified) clang/lib/Driver/ToolChains/Flang.h (+8)
  • (modified) flang/include/flang/Frontend/CodeGenOptions.def (+1)
  • (modified) flang/lib/Frontend/CompilerInvocation.cpp (+4)
  • (modified) flang/lib/Frontend/FrontendActions.cpp (+3-1)
  • (added) flang/test/Driver/lto-fatlto.f90 (+20)
  • (added) flang/test/Driver/lto-lld-flags.f90 (+18)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 902a28d60b349..4e19137c91881 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3171,10 +3171,11 @@ def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
   MarshallingInfoString<CodeGenOpts<"ThinLinkBitcodeFile">>;
 defm fat_lto_objects : BoolFOption<"fat-lto-objects",
   CodeGenOpts<"FatLTO">, DefaultFalse,
-  PosFlag<SetTrue, [], [ClangOption, CC1Option], "Enable">,
-  NegFlag<SetFalse, [], [ClangOption, CC1Option], "Disable">,
+  PosFlag<SetTrue, [], [ClangOption, CC1Option, FlangOption, FC1Option], "Enable">,
+  NegFlag<SetFalse, [], [ClangOption, CC1Option, FlangOption, FC1Option], "Disable">,
   BothFlags<[], [ClangOption, CC1Option], " fat LTO object support">>;
 def flto_partitions_EQ : Joined<["-"], "flto-partitions=">, Group<f_Group>,
+  Visibility<[ClangOption, FlangOption, CC1Option, FC1Option]>,
   HelpText<"Number of partitions to use for parallel full LTO codegen, ld.lld only.">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
   Group<f_Group>, Visibility<[ClangOption, CC1Option, CLOption]>,
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 1535f4cebf436..f14a654cedaa3 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -182,6 +182,29 @@ void Flang::addCodegenOptions(const ArgList &Args,
     CmdArgs.push_back("-fcoarray");
 }
 
+void Flang::addLTOOptions(const ArgList &Args, ArgStringList &CmdArgs) const {
+  const auto &TC = getToolChain();
+  const Driver &D = TC.getDriver();
+  DiagnosticsEngine &Diags = D.getDiags();
+  LTOKind LTOMode = D.getLTOMode();
+  // LTO mode is parsed by the Clang driver library.
+  assert(LTOMode != LTOK_Unknown && "Unknown LTO mode.");
+  if (LTOMode == LTOK_Full)
+    CmdArgs.push_back("-flto=full");
+  else if (LTOMode == LTOK_Thin) {
+    Diags.Report(
+        Diags.getCustomDiagID(DiagnosticsEngine::Warning,
+                              "the option '-flto=thin' is a work in progress"));
+    CmdArgs.push_back("-flto=thin");
+  }
+  if (Args.hasArg(options::OPT_flto_partitions_EQ)) {
+    StringRef A = Args.getLastArgValue(options::OPT_flto_partitions_EQ, "8");
+    CmdArgs.push_back(Args.MakeArgString("-flto-partitions=" + A));
+  }
+  Args.addAllArgs(CmdArgs, {options::OPT_ffat_lto_objects,
+                            options::OPT_fno_fat_lto_objects});
+}
+
 void Flang::addPicOptions(const ArgList &Args, ArgStringList &CmdArgs) const {
   // ParsePICArgs parses -fPIC/-fPIE and their variants and returns a tuple of
   // (RelocationModel, PICLevel, IsPIE).
@@ -884,17 +907,7 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
 
   handleColorDiagnosticsArgs(D, Args, CmdArgs);
 
-  // LTO mode is parsed by the Clang driver library.
-  LTOKind LTOMode = D.getLTOMode();
-  assert(LTOMode != LTOK_Unknown && "Unknown LTO mode.");
-  if (LTOMode == LTOK_Full)
-    CmdArgs.push_back("-flto=full");
-  else if (LTOMode == LTOK_Thin) {
-    Diags.Report(
-        Diags.getCustomDiagID(DiagnosticsEngine::Warning,
-                              "the option '-flto=thin' is a work in progress"));
-    CmdArgs.push_back("-flto=thin");
-  }
+  addLTOOptions(Args, CmdArgs);
 
   // -fPIC and related options.
   addPicOptions(Args, CmdArgs);
diff --git a/clang/lib/Driver/ToolChains/Flang.h b/clang/lib/Driver/ToolChains/Flang.h
index 7c24a623af393..98167e1b75e15 100644
--- a/clang/lib/Driver/ToolChains/Flang.h
+++ b/clang/lib/Driver/ToolChains/Flang.h
@@ -40,6 +40,14 @@ class LLVM_LIBRARY_VISIBILITY Flang : public Tool {
   void addPreprocessingOptions(const llvm::opt::ArgList &Args,
                                llvm::opt::ArgStringList &CmdArgs) const;
 
+  /// Extract LTO options from the driver arguments and add them to
+  /// the command arguments.
+  ///
+  /// \param [in] Args The list of input driver arguments
+  /// \param [out] CmdArgs The list of output command arguments
+  void addLTOOptions(const llvm::opt::ArgList &Args,
+                     llvm::opt::ArgStringList &CmdArgs) const;
+
   /// Extract PIC options from the driver arguments and add them to
   /// the command arguments.
   ///
diff --git a/flang/include/flang/Frontend/CodeGenOptions.def b/flang/include/flang/Frontend/CodeGenOptions.def
index cdeea93c9aecb..fa29b8ed79532 100644
--- a/flang/include/flang/Frontend/CodeGenOptions.def
+++ b/flang/include/flang/Frontend/CodeGenOptions.def
@@ -35,6 +35,7 @@ CODEGENOPT(InstrumentFunctions, 1, 0) ///< Set when -finstrument_functions is
 
 CODEGENOPT(IsPIE, 1, 0) ///< PIE level is the same as PIC Level.
 CODEGENOPT(PICLevel, 2, 0) ///< PIC level of the LLVM module.
+CODEGENOPT(PrepareForFatLTO , 1, 0) ///<  Set when -ffat-lto-objects is enabled.
 CODEGENOPT(PrepareForFullLTO , 1, 0) ///< Set when -flto is enabled on the
                                      ///< compile step.
 CODEGENOPT(PrepareForThinLTO , 1, 0) ///< Set when -flto=thin is enabled on the
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index fb3a132cae30e..6cca1337d4333 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -325,6 +325,10 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
   if (args.hasArg(clang::driver::options::OPT_finstrument_functions))
     opts.InstrumentFunctions = 1;
 
+  if (args.hasArg(clang::driver::options::OPT_ffat_lto_objects)) {
+    opts.PrepareForFatLTO = true;
+  }
+
   // -flto=full/thin option.
   if (const llvm::opt::Arg *a =
           args.getLastArg(clang::driver::options::OPT_flto_EQ)) {
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 3bef6b1c31825..bcce9f6ede62e 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -995,7 +995,9 @@ void CodeGenAction::runOptimizationPipeline(llvm::raw_pwrite_stream &os) {
 
   // Create the pass manager.
   llvm::ModulePassManager mpm;
-  if (opts.PrepareForFullLTO)
+  if (opts.PrepareForFatLTO)
+    mpm = pb.buildFatLTODefaultPipeline(level, opts.PrepareForThinLTO, true);
+  else if (opts.PrepareForFullLTO)
     mpm = pb.buildLTOPreLinkDefaultPipeline(level);
   else if (opts.PrepareForThinLTO)
     mpm = pb.buildThinLTOPreLinkDefaultPipeline(level);
diff --git a/flang/test/Driver/lto-fatlto.f90 b/flang/test/Driver/lto-fatlto.f90
new file mode 100644
index 0000000000000..4602cf8f38890
--- /dev/null
+++ b/flang/test/Driver/lto-fatlto.f90
@@ -0,0 +1,20 @@
+! REQUIRES: x86-registered-target
+! checks fatlto objects: that valid bitcode is included in the object file generated. 
+
+! RUN: %flang -fc1 -triple x86_64-unknown-linux-gnu -flto -ffat-lto-objects -emit-obj %s -o %t.o
+! RUN: llvm-readelf -S %t.o | FileCheck %s --check-prefixes=ELF
+! RUN: llvm-objcopy --dump-section=.llvm.lto=%t.bc %t.o
+! RUN: llvm-dis %t.bc -o - | FileCheck %s --check-prefixes=DIS
+
+! ELF: .llvm.lto
+! DIS: define void @_QQmain()
+! DIS-NEXT:  ret void
+! DIS-NEXT: }
+
+! RUN: %flang -fc1 -triple x86_64-unknown-linux-gnu -flto -ffat-lto-objects -S %s -o - | FileCheck %s --check-prefixes=ASM
+
+!      ASM: .section        .llvm.lto,"e",@llvm_lto
+! ASM-NEXT: .Lllvm.embedded.object:
+! ASM-NEXT:        .asciz  "BC
+! ASM-NEXT: .size   .Lllvm.embedded.object
+end program
diff --git a/flang/test/Driver/lto-lld-flags.f90 b/flang/test/Driver/lto-lld-flags.f90
new file mode 100644
index 0000000000000..4176e27b89d42
--- /dev/null
+++ b/flang/test/Driver/lto-lld-flags.f90
@@ -0,0 +1,18 @@
+! check flto-partitions is passed to lld, fc1
+! RUN: %flang -### -fuse-ld=lld -flto=full -flto-partitions=16 %s 2>&1 | FileCheck %s --check-prefixes=LLD-PART,FC1-PART
+
+! FC1-PART: "-fc1"
+! FC1-PART-SAME: "-flto=full"
+! FC1-PART-SAME: "-flto-partitions=16"
+! LLD-PART: ld.lld
+! LLD-PART-SAME: "--lto-partitions=16"
+
+! check fat-lto-objects is passed to lld, fc1
+! RUN: %flang -### -fuse-ld=lld -flto -ffat-lto-objects %s 2>&1 | FileCheck %s --check-prefixes=LLD-FAT,FC1-FAT
+
+! FC1-FAT: "-fc1"
+! FC1-FAT-SAME: "-flto=full"
+! FC1-FAT-SAME: "-ffat-lto-objects"
+! LLD-FAT: ld.lld
+! LLD-FAT-SAME: "--fat-lto-objects"
+end program
\ No newline at end of file

@anchuraj anchuraj force-pushed the lto-flags branch 4 times, most recently from 128bb9f to 52c3055 Compare September 12, 2025 17:25
@anchuraj anchuraj changed the title Enables lto-partitions and fat-lto-object. [flang][Driver] Enables lto-partitions and fat-lto-object. Sep 12, 2025
@anchuraj anchuraj requested a review from abidh September 12, 2025 17:27
lto-partition helps in performing parallel lto and fat-lto-objects
allows bit code to be embedded in object files generated.
Copy link
Contributor

@tarunprabhu tarunprabhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Looks like I missed a couple of things the first time around. Just some clarifications.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that this isn't part of this PR, but do you know what flto=thin does in flang? Does it do anything at all or do we just accept this option, then ignore it? This warning is not very informative, and I wonder if it is worth providing something different.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://reviews.llvm.org/D142420 is the changes I can see. It adds the pipeline buildThinLTOPreLinkDefaultPipeline(level) in FrontendAction.cpp. It does not ignore the option but says further development is required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for bringing this up. There are TODOs mentioned in the above PR:

The TODOs would be:

Add support for -f[no]split-lto-unit
Emit LTO summary
Use ThinLTOBitcodeWriterPass for thin lto

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this. It looks like there were some concerns about that commit message even back then. Did you have plans to work on any of these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I plan to work on enabling module summary.

Copy link
Contributor

@abidh abidh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Apart from a few minor nits, it looks good to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No new line at the end of the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be add a comment why this llvm::Triple::Apple check is required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Updated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like other places in the PR, you may want to add && "Unknown LTO mode" here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove the Braces for this if.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@anchuraj anchuraj force-pushed the lto-flags branch 2 times, most recently from 3375fc4 to 7034c46 Compare September 17, 2025 18:10
Copy link
Contributor

@tarunprabhu tarunprabhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes and investigations. LGTM, but wait for @abidh to take a look.

Copy link
Contributor

@abidh abidh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes. LGTM.

@anchuraj anchuraj merged commit 5b2af16 into llvm:main Sep 18, 2025
9 checks passed
anchuraj added a commit that referenced this pull request Sep 18, 2025
#158125 resulted in CI failure
as `llvm-readelf` and `llvm-objcopy` were not listed in flang test deps.
This PR fixes it.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Sep 18, 2025
llvm/llvm-project#158125 resulted in CI failure
as `llvm-readelf` and `llvm-objcopy` were not listed in flang test deps.
This PR fixes it.
@klausler
Copy link
Contributor

I'm seeing failures downstream in flang/test/Driver/lto-lld-flags.f90 on both x86-64 and aarch64 Linux. I build with shared libraries, in case that matters.

FAIL: Flang :: Driver/lto-lld-flags.f90 (3831 of 3838)
******************** TEST 'Flang :: Driver/lto-lld-flags.f90' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 3
/home/pklausler/llvm-project/build/x86/gcc/9.3.0/Release/shared/bin/flang -### -fuse-ld=lld -flto=full -flto-partitions=16 /home/pklausler/llvm-project/flang/te
st/Driver/lto-lld-flags.f90 2>&1 | /home/pklausler/llvm-project/build/x86/gcc/9.3.0/Release/shared/bin/FileCheck /home/pklausler/llvm-project/flang/test/Driver/
lto-lld-flags.f90 --check-prefixes=LLD-PART,FC1-PART
# executed command: /home/pklausler/llvm-project/build/x86/gcc/9.3.0/Release/shared/bin/flang '-###' -fuse-ld=lld -flto=full -flto-partitions=16 /home/pklausler
/llvm-project/flang/test/Driver/lto-lld-flags.f90
# note: command had no output on stdout or stderr
# error: command failed with exit status: 1
# executed command: /home/pklausler/llvm-project/build/x86/gcc/9.3.0/Release/shared/bin/FileCheck /home/pklausler/llvm-project/flang/test/Driver/lto-lld-flags.f
90 --check-prefixes=LLD-PART,FC1-PART
# .---command stderr------------
# | /home/pklausler/llvm-project/flang/test/Driver/lto-lld-flags.f90:8:13: error: LLD-PART: expected string not found in input
# | ! LLD-PART: ld.lld
# |             ^
# | <stdin>:8:156: note: scanning from here
# |  "/local/home/pklausler/build/llvm-project/x86/gcc/9.3.0/Release/shared/bin/flang" "-fc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc" "-flto=full"
"-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "x86-64" "-resource-dir" "/local/home/pklausler/build/llvm-project/x86/gcc/9.3.0/Release
/shared/lib/clang/22" "-mframe-pointer=all" "-o" "/tmp/lit-tmp-y0dj4a88/lto-lld-flags-5333c9.o" "-x" "f95" "/home/pklausler/llvm-project/flang/test/Driver/lto-l
ld-flags.f90"
# |                                                                                                                                                            ^
# | <stdin>:8:280: note: possible intended match here
# |  "/local/home/pklausler/build/llvm-project/x86/gcc/9.3.0/Release/shared/bin/flang" "-fc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc" "-flto=full"
"-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "x86-64" "-resource-dir" "/local/home/pklausler/build/llvm-project/x86/gcc/9.3.0/Release
/shared/lib/clang/22" "-mframe-pointer=all" "-o" "/tmp/lit-tmp-y0dj4a88/lto-lld-flags-5333c9.o" "-x" "f95" "/home/pklausler/llvm-project/flang/test/Driver/lto-l
ld-flags.f90"
# |

@luporl
Copy link
Contributor

luporl commented Sep 22, 2025

flang/test/Driver/lto-lld-flags.f90 fails on macOS too, when lld is not enabled:

FAIL: Flang :: Driver/lto-lld-flags.f90 (1 of 1)
******************** TEST 'Flang :: Driver/lto-lld-flags.f90' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 3
/Users/leandro.lupori/home/git/flang/build/bin/flang -### -fuse-ld=lld -flto=full -flto-partitions=16 /Users/leandro.lupori/home/git/flang/llvm-project/flang/test/Driver/lto-lld-flags.f90 2>&1 | /Users/leandro.lupori/home/git/flang/build/bin/FileCheck /Users/leandro.lupori/home/git/flang/llvm-project/flang/test/Driver/lto-lld-flags.f90 --check-prefixes=LLD-PART,FC1-PART
# executed command: /Users/leandro.lupori/home/git/flang/build/bin/flang '-###' -fuse-ld=lld -flto=full -flto-partitions=16 /Users/leandro.lupori/home/git/flang/llvm-project/flang/test/Driver/lto-lld-flags.f90
# note: command had no output on stdout or stderr
# error: command failed with exit status: 1
# executed command: /Users/leandro.lupori/home/git/flang/build/bin/FileCheck /Users/leandro.lupori/home/git/flang/llvm-project/flang/test/Driver/lto-lld-flags.f90 --check-prefixes=LLD-PART,FC1-PART
# .---command stderr------------
# | /Users/leandro.lupori/home/git/flang/llvm-project/flang/test/Driver/lto-lld-flags.f90:8:13: error: LLD-PART: expected string not found in input
# | ! LLD-PART: ld.lld
# |             ^
# | <stdin>:7:129: note: scanning from here
# |  "/Users/leandro.lupori/home/git/flang/build/bin/flang" "-fc1" "-triple" "arm64-apple-macosx15.0.0" "-emit-llvm-bc" "-flto=full" "-mrelocation-model" "pic" "-pic-level" "2" "-target-cpu" "apple-m1" "-target-feature" "+v8.4a" "-target-feature" "+aes" "-target-feature" "+altnzcv" "-target-feature" "+ccdp" "-target-feature" "+ccpp" "-target-feature" "+complxnum" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" "+flagm" "-target-feature" "+fp-armv8" "-target-feature" "+fp16fml" "-target-feature" "+fptoint" "-target-feature" "+fullfp16" "-target-feature" "+jsconv" "-target-feature" "+lse" "-target-feature" "+neon" "-target-feature" "+pauth" "-target-feature" "+perfmon" "-target-feature" "+predres" "-target-feature" "+ras" "-target-feature" "+rcpc" "-target-feature" "+rdm" "-target-feature" "+sb" "-target-feature" "+sha2" "-target-feature" "+sha3" "-target-feature" "+specrestrict" "-target-feature" "+ssbs" "-resource-dir" "/Users/leandro.lupori/home/git/flang/build/lib/clang/22" "-mframe-pointer=non-leaf" "-o" "/var/folders/dn/0khgdg49685fyvmj1tfyp13c0000gp/T/lit-tmp-oazpj6yh/lto-lld-flags-df2d88.o" "-x" "f95" "/Users/leandro.lupori/home/git/flang/llvm-project/flang/test/Driver/lto-lld-flags.f90"
# |                                                                                                                                 ^
# | <stdin>:7:995: note: possible intended match here
# |  "/Users/leandro.lupori/home/git/flang/build/bin/flang" "-fc1" "-triple" "arm64-apple-macosx15.0.0" "-emit-llvm-bc" "-flto=full" "-mrelocation-model" "pic" "-pic-level" "2" "-target-cpu" "apple-m1" "-target-feature" "+v8.4a" "-target-feature" "+aes" "-target-feature" "+altnzcv" "-target-feature" "+ccdp" "-target-feature" "+ccpp" "-target-feature" "+complxnum" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" "+flagm" "-target-feature" "+fp-armv8" "-target-feature" "+fp16fml" "-target-feature" "+fptoint" "-target-feature" "+fullfp16" "-target-feature" "+jsconv" "-target-feature" "+lse" "-target-feature" "+neon" "-target-feature" "+pauth" "-target-feature" "+perfmon" "-target-feature" "+predres" "-target-feature" "+ras" "-target-feature" "+rcpc" "-target-feature" "+rdm" "-target-feature" "+sb" "-target-feature" "+sha2" "-target-feature" "+sha3" "-target-feature" "+specrestrict" "-target-feature" "+ssbs" "-resource-dir" "/Users/leandro.lupori/home/git/flang/build/lib/clang/22" "-mframe-pointer=non-leaf" "-o" "/var/folders/dn/0khgdg49685fyvmj1tfyp13c0000gp/T/lit-tmp-oazpj6yh/lto-lld-flags-df2d88.o" "-x" "f95" "/Users/leandro.lupori/home/git/flang/llvm-project/flang/test/Driver/lto-lld-flags.f90"
# |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ^
# |
# | Input file: <stdin>
# | Check file: /Users/leandro.lupori/home/git/flang/llvm-project/flang/test/Driver/lto-lld-flags.f90
# |
# | -dump-input=help explains the following input dump.
# |
# | Input was:
# | <<<<<<
# |            1: flang version 22.0.0git ([email protected]:luporl/llvm-project.git 2ab5186a9373df5ff64c00b5a33aeb78a2ffd564)
# |            2: Target: arm64-apple-darwin24.6.0
# |            3: Thread model: posix
# |            4: InstalledDir: /Users/leandro.lupori/home/git/flang/build/bin
# |            5: Build config: +assertions
# |            6: flang-22: error: invalid linker name in argument '-fuse-ld=lld'
# |            7:  "/Users/leandro.lupori/home/git/flang/build/bin/flang" "-fc1" "-triple" "arm64-apple-macosx15.0.0" "-emit-llvm-bc" "-flto=full" "-mrelocation-model" "pic" "-pic-level" "2" "-target-cpu" "apple-m1" "-target-feature" "+v8.4a" "-target-feature" "+aes" "-target-feature" "+altnzcv" "-target-feature" "+ccdp" "-target-feature" "+ccpp" "-target-feature" "+complxnum" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" "+flagm" "-target-feature" "+fp-armv8" "-target-feature" "+fp16fml" "-target-feature" "+fptoint" "-target-feature" "+fullfp16" "-target-feature" "+jsconv" "-target-feature" "+lse" "-target-feature" "+neon" "-target-feature" "+pauth" "-target-feature" "+perfmon" "-target-feature" "+predres" "-target-feature" "+ras" "-target-feature" "+rcpc" "-target-feature" "+rdm" "-target-feature" "+sb" "-target-feature" "+sha2" "-target-feature" "+sha3" "-target-feature" "+specrestrict" "-target-feature" "+ssbs" "-resource-dir" "/Users/leandro.lupori/home/git/flang/build/lib/clang/22" "-mframe-pointer=non-leaf" "-o" "/var/folders/dn/0khgdg49685fyvmj1tfyp13c0000gp/T/lit-tmp-oazpj6yh/lto-lld-flags-df2d88.o" "-x" "f95" "/Users/leandro.lupori/home/git/flang/llvm-project/flang/test/Driver/lto-lld-flags.f90"
# | check:8'0                                                                                                                                     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# | check:8'1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ?                                                                                                                                                                                                                                               possible intended match
# |            8:  "/usr/bin/ld" "-demangle" "-object_path_lto" "/var/folders/dn/0khgdg49685fyvmj1tfyp13c0000gp/T/lit-tmp-oazpj6yh/cc-b14622.o" "-lto_library" "/Users/leandro.lupori/home/git/flang/build/lib/libLTO.dylib" "-no_deduplicate" "-dynamic" "-arch" "arm64" "-platform_version" "macos" "15.0.0" "15.0.0" "-syslibroot" "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" "-mllvm" "-enable-linkonceodr-outlining" "-o" "a.out" "/var/folders/dn/0khgdg49685fyvmj1tfyp13c0000gp/T/lit-tmp-oazpj6yh/lto-lld-flags-df2d88.o" "-L/Users/leandro.lupori/home/git/flang/build/lib/clang/22/lib/darwin" "-L/Users/leandro.lupori/home/git/flang/build/lib" "-lflang_rt.runtime" "-lSystem" "/Users/leandro.lupori/home/git/flang/build/lib/clang/22/lib/darwin/libclang_rt.osx.a"
# | check:8'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

@luporl
Copy link
Contributor

luporl commented Sep 22, 2025

This change also broke https://lab.llvm.org/buildbot/#/builders/130/builds/15415.
This bot uses gcc/ld instead of clang/lld.
It seems to me flang/test/Driver/lto-lld-flags.f90 should only be run if lld is enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category flang:driver flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants