[flang-commits] [clang] [flang] [flang][Driver] Enables lto-partitions and fat-lto-object. (PR #158125)

Tarun Prabhu via flang-commits flang-commits at lists.llvm.org
Tue Sep 16 17:29:56 PDT 2025


================
@@ -182,6 +182,29 @@ void Flang::addCodegenOptions(const ArgList &Args,
     CmdArgs.push_back("-fcoarray");
 }
 
+void Flang::addLTOOptions(const ArgList &Args, ArgStringList &CmdArgs) const {
+  const ToolChain &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");
----------------
tarunprabhu wrote:

Is the default of 8 here taken from clang? If so, we should probably mention that in a comment, or, better still, share this value between clang and flang. If it is specific to flang, it may be worth mentioning why 8, or pointing to some documentation where this choice is described.

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


More information about the flang-commits mailing list