================
@@ -262,6 +262,18 @@ void Flang::addCodegenOptions(const ArgList &Args,
        options::OPT_fstack_repack_arrays, options::OPT_fno_stack_repack_arrays,
        options::OPT_ftime_report, options::OPT_ftime_report_EQ,
        options::OPT_funroll_loops, options::OPT_fno_unroll_loops});
+
+  const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
+  bool UseSeparateSections = isUseSeparateSections(Triple);
+  if (Args.hasFlag(options::OPT_ffunction_sections,
+                   options::OPT_fno_function_sections, UseSeparateSections))
+    CmdArgs.push_back("-ffunction-sections");
+
+  bool HasDefaultDataSections = Triple.isOSBinFormatXCOFF();
+  if (Args.hasFlag(options::OPT_fdata_sections, options::OPT_fno_data_sections,
+                   UseSeparateSections || HasDefaultDataSections))
+    CmdArgs.push_back("-fdata-sections");
+
----------------
tarunprabhu wrote:

Is think the handling of these is exactly the same as in clang? If so, we 
should consider sharing the code. There is a lot of precedent for moving these 
to `clang/lib/Driver/ToolChains/CommonArgs.cpp`. See, for instance, 
`shouldRecordCommandLine` in that file.

https://github.com/llvm/llvm-project/pull/199731
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to