[flang-commits] [clang] [flang] [Flang][Driver] Add per-target search path for modules (PR #196558)
Michael Kruse via flang-commits
flang-commits at lists.llvm.org
Wed May 13 07:14:28 PDT 2026
================
@@ -0,0 +1,58 @@
+! Ensure argument -fintrinsic-modules-path works as expected.
+
+!-----------------------------------------
+! FLANG DRIVER
+!-----------------------------------------
+! NOTE: Depending on how Flang is built, the default intrinsics may have higher
+! or lower priority than -fintrinsic-modules-path added here. Using
+! basictestmoduleone.mod from Inputs/module-dir/ will trigger an error.
+
+! RUN: %flang -fsyntax-only --target=x86_64-unknown-linux-gnu -resource-dir %S/Inputs/resource_dir_with_per_target_subdir %s -### 2>&1 | FileCheck %s --check-prefix=DEFAULTPATH
+
+! RUN: %flang -fsyntax-only --target=x86_64-unknown-linux-gnu -resource-dir %S/Inputs/resource_dir_with_per_target_subdir %s -cpp -DINTRINSICS_DEFAULT
+! RUN: not %flang -fsyntax-only --target=x86_64-unknown-linux-gnu -resource-dir %S/Inputs/resource_dir_with_per_target_subdir %s -cpp -DINTRINSICS_INPUTONE 2>&1 | FileCheck %s --check-prefix=NOINPUTONE
+! RUN: not %flang -fsyntax-only --target=x86_64-unknown-linux-gnu -resource-dir %S/Inputs/resource_dir_with_per_target_subdir %s -cpp -DINTRINSICS_INPUTTWO 2>&1 | FileCheck %s --check-prefix=NOINPUTTWO
+! RUN: %flang -fsyntax-only --target=x86_64-unknown-linux-gnu -resource-dir %S/Inputs/resource_dir_with_per_target_subdir %s -cpp -DINTRINSICS_DEFAULT -DINTRINSICS_INPUTTWO -fintrinsic-modules-path=%S/Inputs/module-dir/
+! RUN: %flang -fsyntax-only --target=x86_64-unknown-linux-gnu -resource-dir %S/Inputs/resource_dir_with_per_target_subdir %s -cpp -DINTRINSICS_INPUTONE -fintrinsic-modules-path=%S/Inputs/module-dir-one/
+! RUN: %flang -fsyntax-only --target=x86_64-unknown-linux-gnu -resource-dir %S/Inputs/resource_dir_with_per_target_subdir %s -cpp -DINTRINSICS_INPUTONE -DINTRINSICS_INPUTTWO -fintrinsic-modules-path=%S/Inputs/module-dir-one/ -fintrinsic-modules-path=%S/Inputs/module-dir/
+! RUN: not %flang -fsyntax-only --target=x86_64-unknown-linux-gnu -resource-dir %S/Inputs/resource_dir_with_per_target_subdir %s -cpp -DINTRINSICS_INPUTONE -DINTRINSICS_INPUTTWO -fintrinsic-modules-path=%S/Inputs/module-dir/ -fintrinsic-modules-path=%S/Inputs/module-dir-one/ 2>&1 | FileCheck %s --check-prefix=WRONGINPUTONE
+
+
+!-----------------------------------------
+! FLANG FRONTEND (flang -fc1)
+!-----------------------------------------
+! NOTE: %flang_cc1 the default intrinsics path always has higher priority than
----------------
Meinersbur wrote:
Because the test is skipping the driver which would add the `-fintrinsic-modules-path` for the intrinsics at the end of it, `%flang_fc1` will be something like `/path/to/flang -fintrinsic-modules-path=/path/to/intrinsic/mods`. This unfortunately changes the search order compared to the "real" driver.
For this reason #171515 changes every test with `flang -fc1` to `%flang_fc1`. Alternatively, a different symbol such as `%flang_fc1_trailing_cmdargs` would need to be added to every such `RUN: ` line which could easily be forgotten or made the last option for contributors who don't know why. I think it is better to just account for this this difference in the only test that checks module search order.
https://github.com/llvm/llvm-project/pull/196558
More information about the flang-commits
mailing list