[libc-commits] [clang] [compiler-rt] [flang] [libc] [libcxx] [libcxxabi] [libunwind] [llvm] [openmp] [Flang] Move builtin .mod generation into runtimes (Reapply #137828) (PR #171515)

Michael Kruse via libc-commits libc-commits at lists.llvm.org
Wed May 13 06:41:36 PDT 2026


================
@@ -1179,6 +1179,37 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
   CmdArgs.push_back("-resource-dir");
   CmdArgs.push_back(D.ResourceDir.c_str());
 
+  // Default intrinsic module dirs must be added after any user-provided
+  // -fintrinsic-modules-path to have lower precedence
+  if (std::optional<std::string> IntrModPath =
+          TC.getDefaultIntrinsicModuleDir()) {
+    CmdArgs.push_back("-fintrinsic-modules-path");
+    CmdArgs.push_back(Args.MakeArgString(*IntrModPath));
+  }
+
+  // Ideally, every target triple has its own set of builtin modules since they
+  // are compiled with platform-dependent conditionals such as `#if __x86_64__`.
+  // However, getting the builtin modules for offload targets requires building
+  // the flang-rt and openmp for those targets as well:
+  // -DLLVM_RUNTIME_TARGETS=default;amdgcn-amd-amdhsa;nvptx64-nvidia-cuda.
+  // To reduce friction when build systems have not yet been updated, we also
+  // add the host's builtin module to the search path (with lower priority), in
+  // case a module file has not been found for the offload targets itself.
+  // FIXME: This workaround may mix module files targeting different triples and
----------------
Meinersbur wrote:

Please read this PR's summary:
<img width="1047" height="327" alt="image" src="https://github.com/user-attachments/assets/c8454a8a-cfc6-410f-bc13-80c72987c04c" />

Build system is LLVM's CMake build system. That should already have been obvious because `LLVM_RUNTIME_TARGETS/LLVM_ENABLE_RUNTIMES/LLVM_ENABLE_PROJECTS` are LLVM-build-system-specific options.

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


More information about the libc-commits mailing list