[clang] [flang] [Flang][Driver] Add per-target search path for modules (PR #196558)
Michael Kruse via cfe-commits
cfe-commits at lists.llvm.org
Tue May 19 01:14:10 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
+ // should eventually be removed.
----------------
Meinersbur wrote:
What this entire PR does is adding an additional search path where only one of them is ever needed. If you have concerns with temporary workarounds, you should have been against extracting this out of #171515. Having two search paths is the direct result of having to handle the intermediate state between landing #196558 and #171515.
https://github.com/llvm/llvm-project/pull/196558
More information about the cfe-commits
mailing list