[flang-commits] [flang] [Flang][bbc] Add support for -fintrinsic-module-path (PR #198565)

Michael Kruse via flang-commits flang-commits at lists.llvm.org
Wed May 20 03:18:32 PDT 2026


https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/198565

>From c3a884caeb8c683a1863eb4c1853836bf86e331b Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Tue, 19 May 2026 18:03:11 +0200
Subject: [PATCH 1/2] [Flang][bbc] Add support for -fintrinsic-module-path

---
 flang/test/Driver/Inputs/ieee_arithmetic.mod |  8 -----
 flang/test/Driver/Inputs/iso_fortran_env.mod |  8 -----
 flang/test/Driver/intrinsic-module-path.f90  | 38 +++++++++++++-------
 flang/tools/bbc/bbc.cpp                      |  5 +++
 4 files changed, 31 insertions(+), 28 deletions(-)
 delete mode 100644 flang/test/Driver/Inputs/ieee_arithmetic.mod
 delete mode 100644 flang/test/Driver/Inputs/iso_fortran_env.mod

diff --git a/flang/test/Driver/Inputs/ieee_arithmetic.mod b/flang/test/Driver/Inputs/ieee_arithmetic.mod
deleted file mode 100644
index 264ff8d035628..0000000000000
--- a/flang/test/Driver/Inputs/ieee_arithmetic.mod
+++ /dev/null
@@ -1,8 +0,0 @@
-! DUMMY module
-! Added for testing purposes. The contents of this file are currently not relevant.
-! Using this file will cause an error because of missing checksum
-module ieee_arithmetic
-type::ieee_round_type
-integer(1),private::mode=0_1
-end type
-end
diff --git a/flang/test/Driver/Inputs/iso_fortran_env.mod b/flang/test/Driver/Inputs/iso_fortran_env.mod
deleted file mode 100644
index c53375d78dec5..0000000000000
--- a/flang/test/Driver/Inputs/iso_fortran_env.mod
+++ /dev/null
@@ -1,8 +0,0 @@
-! DUMMY module
-! Added for testing purposes. The contents of this file are currently not relevant.
-! Using this file will cause an error because of missing checksum
-module iso_fortran_env
-use __fortran_builtins,only:event_type=>__builtin_event_type
-use __fortran_builtins,only:lock_type=>__builtin_lock_type
-use __fortran_builtins,only:team_type=>__builtin_team_type
-end
diff --git a/flang/test/Driver/intrinsic-module-path.f90 b/flang/test/Driver/intrinsic-module-path.f90
index c8b848f3efa9a..cf5a740dc8c5d 100644
--- a/flang/test/Driver/intrinsic-module-path.f90
+++ b/flang/test/Driver/intrinsic-module-path.f90
@@ -1,23 +1,37 @@
 ! Ensure argument -fintrinsic-modules-path works as expected.
 ! WITHOUT the option, the default location for the module is checked and no error generated.
-! With the option GIVEN, the module with the same name is PREPENDED, and considered over the
-! default one, causing an error.
+! With the option WRONG and GIVEN, find the module in the first first
+! -fintrinsic-modules-path that contains a matching file.
 
 !-----------------------------------------
 ! FRONTEND FLANG DRIVER (flang -fc1)
 !-----------------------------------------
-! RUN: %flang_fc1 -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
-! RUN: not %flang_fc1 -fsyntax-only -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
-! RUN: not %flang_fc1 -fsyntax-only -fintrinsic-modules-path=%S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: not %flang_fc1 -fsyntax-only                                                                                                     %s 2>&1 | FileCheck %s --check-prefix=WITHOUT
+! RUN: not %flang_fc1 -fsyntax-only -fintrinsic-modules-path %S/Inputs/module-dir                                                       %s 2>&1 | FileCheck %s --check-prefix=WRONG
+! RUN: not %flang_fc1 -fsyntax-only -fintrinsic-modules-path %S/Inputs/module-dir     -fintrinsic-modules-path %S/Inputs/module-dir-one %s 2>&1 | FileCheck %s --check-prefix=WRONG
+! RUN:     %flang_fc1 -fsyntax-only -fintrinsic-modules-path=%S/Inputs/module-dir-one                                                   %s 2>&1 | FileCheck %s --allow-empty --check-prefix=GIVEN
+! RUN:     %flang_fc1 -fsyntax-only -fintrinsic-modules-path %S/Inputs/module-dir-one                                                   %s 2>&1 | FileCheck %s --allow-empty --check-prefix=GIVEN
+! RUN:     %flang_fc1 -fsyntax-only -fintrinsic-modules-path %S/Inputs/module-dir-one -fintrinsic-modules-path %S/Inputs/module-dir     %s 2>&1 | FileCheck %s --allow-empty --check-prefix=GIVEN
 
-! WITHOUT-NOT: 'ieee_arithmetic.mod' was not found
-! WITHOUT-NOT: 'iso_fortran_env.mod' was not found
+!-----------------------------------------
+! BURNSIDE BRIDGE_COMPILER (bbc)
+!-----------------------------------------
+! RUN: not bbc                                                                                                     %s 2>&1 | FileCheck %s --check-prefix=WITHOUT
+! RUN: not bbc -fintrinsic-modules-path %S/Inputs/module-dir                                                       %s 2>&1 | FileCheck %s --check-prefix=WRONG
+! RUN: not bbc -fintrinsic-modules-path %S/Inputs/module-dir     -fintrinsic-modules-path %S/Inputs/module-dir-one %s 2>&1 | FileCheck %s --check-prefix=WRONG
+! RUN:     bbc -fintrinsic-modules-path=%S/Inputs/module-dir-one                                                   %s 2>&1 | FileCheck %s --allow-empty --check-prefix=GIVEN
+! RUN:     bbc -fintrinsic-modules-path %S/Inputs/module-dir-one                                                   %s 2>&1 | FileCheck %s --allow-empty --check-prefix=GIVEN
+! RUN:     bbc -fintrinsic-modules-path %S/Inputs/module-dir-one -fintrinsic-modules-path %S/Inputs/module-dir     %s 2>&1 | FileCheck %s --allow-empty --check-prefix=GIVEN
+
+
+! WITHOUT: error: Cannot parse module file for module 'basictestmoduleone': Source file 'basictestmoduleone.mod' was not found
+
+! WRONG: error: 't1' not found in module 'basictestmoduleone'
 
-! GIVEN: error: Cannot read module file for module 'ieee_arithmetic': 'ieee_arithmetic.mod' is not a module file for this compiler
-! GIVEN: error: Cannot read module file for module 'iso_fortran_env': 'iso_fortran_env.mod' is not a module file for this compiler
+! Do not emit any message about the absence of basictestmoduleone
+! GIVEN-NOT: basictestmoduleone
 
 
-program test_intrinsic_module_path
-   use ieee_arithmetic, only: ieee_round_type
-   use iso_fortran_env, only: team_type, event_type, lock_type
+program test_intrinsic_modules_path
+   use basictestmoduleone, only: t1
 end program
diff --git a/flang/tools/bbc/bbc.cpp b/flang/tools/bbc/bbc.cpp
index 5c2837a8a36b4..30b4a99c8f2d5 100644
--- a/flang/tools/bbc/bbc.cpp
+++ b/flang/tools/bbc/bbc.cpp
@@ -100,6 +100,11 @@ static llvm::cl::alias
                           llvm::cl::desc("intrinsic module directory"),
                           llvm::cl::aliasopt(intrinsicIncludeDirs));
 
+static llvm::cl::alias
+    intrinsicModulePath("fintrinsic-modules-path",
+                        llvm::cl::desc("intrinsic module search paths"),
+                        llvm::cl::aliasopt(intrinsicIncludeDirs));
+
 static llvm::cl::opt<std::string>
     moduleDir("module", llvm::cl::desc("module output directory (default .)"),
               llvm::cl::init("."));

>From 3b60d8cd3e87f304d544339ee188b15ab6a4df49 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 20 May 2026 12:18:23 +0200
Subject: [PATCH 2/2] Apply suggeston by @tarunprabhu

Co-authored-by: Tarun Prabhu <tarun at lanl.gov>
---
 flang/test/Driver/intrinsic-module-path.f90 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/test/Driver/intrinsic-module-path.f90 b/flang/test/Driver/intrinsic-module-path.f90
index cf5a740dc8c5d..0b55454fbcd49 100644
--- a/flang/test/Driver/intrinsic-module-path.f90
+++ b/flang/test/Driver/intrinsic-module-path.f90
@@ -1,6 +1,6 @@
 ! Ensure argument -fintrinsic-modules-path works as expected.
 ! WITHOUT the option, the default location for the module is checked and no error generated.
-! With the option WRONG and GIVEN, find the module in the first first
+! With the option WRONG and GIVEN, find the module in the first
 ! -fintrinsic-modules-path that contains a matching file.
 
 !-----------------------------------------



More information about the flang-commits mailing list