Skip to content

[flang-rt][CMake] Avoid 'use, intrinsic ::' - #205634

Merged
Meinersbur merged 6 commits into
llvm:mainfrom
Meinersbur:flangrt_fix-mod-build
Jun 25, 2026
Merged

[flang-rt][CMake] Avoid 'use, intrinsic ::'#205634
Meinersbur merged 6 commits into
llvm:mainfrom
Meinersbur:flangrt_fix-mod-build

Conversation

@Meinersbur

@Meinersbur Meinersbur commented Jun 24, 2026

Copy link
Copy Markdown
Member

Two build failures reported after #204260

  • Unix Makefiles generator stops working: The cause is that the rules for building each OBJECT library lands in its own Makefile, e.g. flang_rt.mod.fortran.builtins.dir/build.make and libomp-mod.dir/build.make. Trying to inject dependencies directly for build rules in the other file does not work.

  • __ppc_types.f90 not tracked: Forgotten in [flang-rt][openmp] Add file-level dependencies for builtin mod files #204260 due to being only conditionally enabled for PowerPC targets.

The solution for both is to just remove the workaround for CMake not recognizing modules uses declared using intrinsic which caused these problems. This PR promotes the use constructs in the module sources to normal dependencies that are not ignored by CMake.

The intrinsic modifier changes the search path to only look for such a module in -fintrinsic-modules-path. The difference is only theoretical:

  1. When compiling the intrinsic modules, there are no other search paths than for the intrinsics anyway
  2. Users should strongly avoid naming their modules the same as an intrinsic module
  3. Most of our intrinsic sources don't even use the intrinsic modifier in the first place (e.g.
    use __fortran_builtins, only: &
    ). That is, if there was a problem with lookup ambiguity, these would have already been a problem for those.
  4. The checksum of used modules is only added into the .mod file (the only reason why modules would need to be transitively rebuilt) when a use statement appears. Many intrinsic modules don't explicitly use the modules that are added implicitly by the compiler, such as __fortran_builtins, and hence do not even need to be rebuilt.

I started this PR with a tested-working fix (71c5e7f0ffcf2ebd58812d2e2812b22663be1631) to the workaround code. But given the points above, there seems to be no benefit of keeping the workaround code handling CMake version < 4.5 around just for some intrinsic modules to keep the intrinsic modifier with no practical effect. A non-workaround path using CMake's Fortran_BUILDING_IN(S)TRINSIC_MODULES setting had to be added in any case for Unix Makefile generators (reported issue 1.) because injecting dependencies is not possible with Unix Makefiles as stated, but Fortran_BUILDING_IN(S)TRINSIC_MODULES also does not work with the Ninja generator. Avoiding use, intrinsic keeps just one configuration path.

I tested that modules are properly updated with Ninja and Unix Makefiles:

  • Build from scratch
  • Modifying __fortran_builtins.f90 rebuilds its dependent modules
  • Modifying iso_c_binding.f90 rebuilds its dependent modules (omp_lib.mod)

@Meinersbur Meinersbur changed the title [flang-rt][CMake] Fix module file build [flang-rt][CMake] Fix Fortran modules build Jun 24, 2026
@Meinersbur Meinersbur changed the title [flang-rt][CMake] Fix Fortran modules build [flang-rt][CMake] Avoid 'use, intrinsic ::' Jun 24, 2026
@Meinersbur
Meinersbur force-pushed the flangrt_fix-mod-build branch from e213418 to bb67b75 Compare June 24, 2026 21:14
@Meinersbur
Meinersbur marked this pull request as ready for review June 24, 2026 22:33
@Meinersbur
Meinersbur requested a review from a team as a code owner June 24, 2026 22:33
@llvmorg-github-actions llvmorg-github-actions Bot added cmake Build system in general and CMake in particular openmp:libomp OpenMP host runtime flang-rt labels Jun 24, 2026
PROPERTIES
Fortran_BUILDING_INTRINSIC_MODULES ON
Fortran_BUILDING_INSTRINSIC_MODULES ON
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the other changes, is this needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, not strictly. However, I thought we may keep it because it is the behaviour we actually want from CMake, just not all versions implement it yet.

@nikic nikic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very reasonable to me, but I don't know enough about Fortran to approve it...

@pawosm-arm

Copy link
Copy Markdown
Contributor

@david-arm could it be addressing the problem you're facing recently?

@DanielCChen

Copy link
Copy Markdown
Contributor

This patch indeed fixed the could not find __ppc_types.mod issue on powerpc.

@Meinersbur

Copy link
Copy Markdown
Member Author

This patch indeed fixed the could not find __ppc_types.mod issue on powerpc.

Sorry, I just forgot about it.

@DavidTruby DavidTruby left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me. I can't immediately see any issues with not explicitly declaring these intrinsic since there's nothing on the module path except intrinsics anyway. Users of these modules should still be able to declare their imports intrinsic if they need to.

@Meinersbur
Meinersbur merged commit c1869ff into llvm:main Jun 25, 2026
21 of 24 checks passed
@kkwli

kkwli commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

I still hit an issue when doing a build. It is a scratch build. It fails in the first time. If I do ninja -j140 again, the build is successful.

$ ninja -j140
[8155/8197] Performing configure step for 'runtimes'
Not searching for unused variables given on the command line.
loading initial cache file /scratch/kli/wrk/f/build-flang-local/projects/runtimes/tmp/runtimes-cache-Release.cmake
-- Performing bootstrapping runtimes build.
-- The C compiler identification is Clang 23.0.0
-- The CXX compiler identification is Clang 23.0.0
-- The ASM compiler identification is Clang with GNU-like command-line
-- Found assembler: /scratch/kli/wrk/f/build-flang-local/./bin/clang
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /scratch/kli/wrk/f/build-flang-local/./bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /scratch/kli/wrk/f/build-flang-local/./bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.11")  
-- Found zstd: /usr/lib64/libzstd.so  
-- Found LibXml2: /usr/lib64/libxml2.so (found version "2.9.7") 
-- Performing Test CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG
-- Performing Test CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG - Success
-- Performing Test C_SUPPORTS_START_NO_UNUSED_ARGUMENTS
-- Performing Test C_SUPPORTS_START_NO_UNUSED_ARGUMENTS - Success
-- Performing Test CXX_SUPPORTS_NOSTDLIBXX_FLAG
-- Performing Test CXX_SUPPORTS_NOSTDLIBXX_FLAG - Success
-- Performing Test CXX_SUPPORTS_NOSTDINCXX_FLAG
-- Performing Test CXX_SUPPORTS_NOSTDINCXX_FLAG - Success
-- Linker detection: GNU ld
...
-- Looking for backtrace
-- Looking for backtrace - found
-- backtrace facility detected in default set of libraries
-- Found Backtrace: /usr/include  
-- Looking for sinf128 in m
-- Looking for sinf128 in m - found
-- Configuring done (19.1s)
-- Generating done (0.1s)
-- Build files have been written to: /scratch/kli/wrk/f/build-flang-local/runtimes/runtimes-bins
[8194/8197] Performing build step for 'runtimes'
[103/197] Building CXX object openmp/runti.../CMakeFiles/obj.omp.dir/z_Linux_util.cpp.o
/scratch/kli/llvm-project/openmp/runtime/src/z_Linux_util.cpp:443:7: warning: unused variable 'status' [-Wunused-variable]
  443 |   int status;
      |       ^~~~~~
/scratch/kli/llvm-project/openmp/runtime/src/z_Linux_util.cpp:528:7: warning: unused variable 'status' [-Wunused-variable]
  528 |   int status, old_type, old_state;
      |       ^~~~~~
/scratch/kli/llvm-project/openmp/runtime/src/z_Linux_util.cpp:528:15: warning: unused variable 'old_type' [-Wunused-variable]
  528 |   int status, old_type, old_state;
      |               ^~~~~~~~
/scratch/kli/llvm-project/openmp/runtime/src/z_Linux_util.cpp:528:25: warning: unused variable 'old_state' [-Wunused-variable]
  528 |   int status, old_type, old_state;
      |                         ^~~~~~~~~
4 warnings generated.
[126/197] Building Fortran object flang-rt...akeFiles/flang-rt-mod.dir/cudadevice.f90.o
FAILED: flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/cudadevice.f90.o /scratch/kli/wrk/f/build-flang-local/lib/clang/23/finclude/flang/powerpc64le-unknown-linux-gnu/cudadevice.mod 
/scratch/kli/wrk/f/build-flang-local/./bin/flang --target=powerpc64le-unknown-linux-gnu -I/scratch/kli/llvm-project/flang-rt/lib/runtime -I/scratch/kli/llvm-project/flang-rt/include -I/scratch/kli/llvm-project/flang-rt/../flang/include -I/scratch/kli/wrk/f/build-flang-local/runtimes/runtimes-bins/flang-rt -I/scratch/kli/llvm-project/cmake/Modules/../../libc -O3 -module-dir/scratch/kli/wrk/f/build-flang-local/lib/clang/23/finclude/flang/powerpc64le-unknown-linux-gnu -fPIC -cpp -mmlir -ignore-missing-type-desc -fno-lto -fintrinsic-modules-path=/scratch/kli/wrk/f/build-flang-local/lib/clang/23/finclude/flang/powerpc64le-unknown-linux-gnu -Xflang -fno-reformat --offload-host-only -xcuda -ffixed-line-length-72 -c flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/cudadevice.f90-pp.f90 -o flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/cudadevice.f90.o
error: Semantic errors in flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/cudadevice.f90-pp.f90
error: Cannot read required CUDA intrinsic module '__cuda_builtins'; check -fintrinsic-modules-path or rebuild the Fortran intrinsic modules
[184/197] Building CXX object flang-rt/lib...ng_rt.runtime.dir/extrema-maxloc-dim.cpp.o
ninja: build stopped: subcommand failed.
FAILED: runtimes/runtimes-stamps/runtimes-build /scratch/kli/wrk/f/build-flang-local/runtimes/runtimes-stamps/runtimes-build 
cd /scratch/kli/wrk/f/build-flang-local/runtimes/runtimes-bins && /compgpfs/build/xlcmpbld/bld_env/LoP/cmake-3.28.2/bin/cmake --build .
ninja: build stopped: subcommand failed.


$ ninja -j140
[0/3] Performing build step for 'runtimes'
[14/14] Building Fortran object flang-rt/l.../flang-rt-mod.dir/cooperative_groups.f90.o
[1/3] No install step for 'runtimes'
[3/3] Completed 'runtimes'

@llvm-ci

llvm-ci commented Jun 25, 2026

Copy link
Copy Markdown

LLVM Buildbot has detected a new failure on builder openmp-s390x-linux running on systemz-1 while building flang-rt,openmp,runtimes at step 6 "test-openmp".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/88/builds/23925

Here is the relevant piece of the build log for the reference
Step 6 (test-openmp) failure: test (failure)
******************** TEST 'libomp :: tasking/issue-94260-2.c' FAILED ********************
Exit Code: -11

Command Output (stdout):
--
# RUN: at line 1
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/./bin/clang -fopenmp   -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test -L /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src  -fno-omit-frame-pointer -mbackchain -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/ompt /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/tasking/issue-94260-2.c -o /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp -lm -latomic && /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp
# executed command: /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/./bin/clang -fopenmp -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test -L /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -fno-omit-frame-pointer -mbackchain -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/ompt /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/tasking/issue-94260-2.c -o /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp -lm -latomic
# executed command: /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp
# note: command had no output on stdout or stderr
# error: command failed with exit status: -11

--

********************


@Meinersbur

Copy link
Copy Markdown
Member Author

@kkwli CMake doesn't know that __cuda_builtins is used implicitly when compiling as CUDA-Fortran. Try #205895

@llvm-ci

llvm-ci commented Jun 25, 2026

Copy link
Copy Markdown

LLVM Buildbot has detected a new failure on builder flang-aarch64-rel-assert running on linaro-flang-aarch64-rel-assert while building flang-rt,openmp,runtimes at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/29/builds/23999

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
123.003 [26/51/877] Building Fortran object flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/cuda_runtime_api.f90.o
123.079 [26/50/878] Building CXX object compiler-rt/lib/tsan/rtl/CMakeFiles/clang_rt.tsan-aarch64.dir/tsan_interceptors_posix.cpp.o
123.128 [25/50/879] Linking CXX static library /home/tcwg-buildbot/worker/flang-aarch64-rel-assert/build/lib/clang/23/lib/aarch64-unknown-linux-gnu/libclang_rt.tsan.a
123.197 [24/50/880] Building Fortran object flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/ieee_features.f90.o
123.342 [24/49/881] Generating exported symbols for clang_rt.tsan-aarch64
123.373 [24/48/882] Building Fortran object flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/__fortran_builtins.f90.o
123.647 [18/53/883] Linking CXX shared library openmp/libompd/src/libompd.so
123.648 [18/52/884] Building Fortran object flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/iso_fortran_env_impl.f90.o
123.830 [17/52/885] Building Fortran object flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/flang_debug.f90.o
123.833 [17/51/886] Building Fortran object flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/cudadevice.f90.o
FAILED: flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/cudadevice.f90.o /home/tcwg-buildbot/worker/flang-aarch64-rel-assert/build/lib/clang/23/finclude/flang/aarch64-unknown-linux-gnu/cudadevice.mod 
/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/build/./bin/flang --target=aarch64-unknown-linux-gnu -I/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/lib/runtime -I/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/include -I/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/../flang/include -I/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/build/runtimes/runtimes-bins/flang-rt -I/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/cmake/Modules/../../libc -O3 -module-dir/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/build/lib/clang/23/finclude/flang/aarch64-unknown-linux-gnu -fPIC -cpp -mmlir -ignore-missing-type-desc -fno-lto -fintrinsic-modules-path=/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/build/lib/clang/23/finclude/flang/aarch64-unknown-linux-gnu -Xflang -fno-reformat --offload-host-only -xcuda -ffixed-line-length-72 -c flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/cudadevice.f90-pp.f90 -o flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/cudadevice.f90.o
error: Semantic errors in flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/cudadevice.f90-pp.f90
error: Cannot read required CUDA intrinsic module '__cuda_builtins'; check -fintrinsic-modules-path or rebuild the Fortran intrinsic modules
124.131 [17/50/887] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/extensions.cpp.o
124.234 [17/49/888] Building Fortran object flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/iso_fortran_env.f90.o
124.314 [17/48/889] Building Fortran object flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/__fortran_ieee_exceptions.f90.o
124.364 [17/47/890] Building Fortran object flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/iso_c_binding.f90.o
124.551 [17/46/891] Building Fortran object flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/__fortran_type_info.f90.o
124.613 [17/45/892] Building Fortran object flang-rt/lib/runtime/CMakeFiles/flang-rt-mod.dir/__cuda_builtins.f90.o
124.870 [17/44/893] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/descriptor-io.cpp.o
125.422 [17/43/894] Building CXX object compiler-rt/lib/msan/CMakeFiles/clang_rt.msan-aarch64.dir/msan_interceptors.cpp.o
125.423 [17/42/895] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/lib/quadmath/tan.cpp.o
125.911 [17/41/896] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/reduction.cpp.o
125.913 [17/40/897] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/unit.cpp.o
126.591 [17/39/898] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/io-stmt.cpp.o
127.779 [17/38/899] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/lib/quadmath/set-exponent.cpp.o
127.790 [17/37/900] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/lib/quadmath/sinh.cpp.o
127.813 [17/36/901] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/lib/quadmath/sin.cpp.o
127.846 [17/35/902] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/lib/quadmath/rrspacing.cpp.o
127.850 [17/34/903] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/lib/quadmath/sqrt.cpp.o
128.141 [17/33/904] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/lib/quadmath/spacing.cpp.o
128.163 [17/32/905] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/io-api-server.cpp.o
128.706 [17/31/906] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/lib/quadmath/y1.cpp.o
128.867 [17/30/907] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/lib/quadmath/scale.cpp.o
128.990 [17/29/908] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/lib/quadmath/y0.cpp.o
129.098 [17/28/909] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/lib/quadmath/tanh.cpp.o
129.114 [17/27/910] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/lib/quadmath/trunc.cpp.o
129.171 [17/26/911] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/lib/quadmath/yn.cpp.o
130.491 [17/25/912] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/lib/quadmath/tgamma.cpp.o
130.501 [17/24/913] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang-rt/lib/quadmath/round.cpp.o
130.906 [17/23/914] Building CXX object compiler-rt/lib/tsan/rtl/CMakeFiles/clang_rt.tsan-dynamic-aarch64.dir/tsan_interceptors_posix.cpp.o
133.332 [17/22/915] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/extrema-value.cpp.o
134.717 [17/21/916] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/matmul-transpose-integer.cpp.o
136.004 [17/20/917] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/matmul-transpose-extypes-int16.cpp.o
136.425 [17/19/918] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/matmul-integer.cpp.o
138.770 [17/18/919] Building CXX object compiler-rt/lib/asan/CMakeFiles/RTAsan.aarch64.dir/asan_interceptors.cpp.o
138.822 [17/17/920] Building CXX object flang-rt/lib/runtime/CMakeFiles/flang_rt.runtime.static.dir/matmul-transpose-real.cpp.o
139.942 [17/16/921] Building CXX object third-party/runtimes_gtest/CMakeFiles/runtimes_gtest.dir/googletest/src/gtest-all.cc.o

@nikic

nikic commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Unfortunately I'm still seeing The __ppc_types module was not found when building mma.f90 on PowerPC. Though the failure is intermittent now.

@Meinersbur

Copy link
Copy Markdown
Member Author

Unfortunately I'm still seeing The __ppc_types module was not found when building mma.f90 on PowerPC. Though the failure is intermittent now.

Problably another implicit dependency that CMake does not see. Let me see which files don't transitivelty include it...

@kkwli

kkwli commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

The intermittent failure also shows up in https://lab.llvm.org/buildbot/#/builders/157/builds/47911.

@Meinersbur

Copy link
Copy Markdown
Member Author

Please have a look at #206493.

Meinersbur added a commit that referenced this pull request Jun 29, 2026
The PPC-specific builtin moduls have implicit dependencies insert by
flang. For CMake to correctly setup the build order, they must be made
explicit.

This replicates the implicit module uses from

https://github.com/llvm/llvm-project/blob/12b20b36737094b1c521adff0c8f58aaaf2f41fb/flang/lib/Semantics/semantics.cpp#L680-L693
in the modules themselves. The PPC-specific modules compiled by Flang-RT
are listed here:

https://github.com/llvm/llvm-project/blob/12b20b36737094b1c521adff0c8f58aaaf2f41fb/flang-rt/lib/runtime/CMakeLists.txt#L213-L219

This should fix the intermittend build error mentioned in
#205634 (comment).
Unfortunately I do not have a PowerPC (cross-)compilation build
environment ready to test, nor does the Premerge-CI build it.
llvm-upstreamsync Bot pushed a commit to qualcomm/cpullvm-toolchain that referenced this pull request Jun 29, 2026
…493)

The PPC-specific builtin moduls have implicit dependencies insert by
flang. For CMake to correctly setup the build order, they must be made
explicit.

This replicates the implicit module uses from

https://github.com/llvm/llvm-project/blob/12b20b36737094b1c521adff0c8f58aaaf2f41fb/flang/lib/Semantics/semantics.cpp#L680-L693
in the modules themselves. The PPC-specific modules compiled by Flang-RT
are listed here:

https://github.com/llvm/llvm-project/blob/12b20b36737094b1c521adff0c8f58aaaf2f41fb/flang-rt/lib/runtime/CMakeLists.txt#L213-L219

This should fix the intermittend build error mentioned in
llvm/llvm-project#205634 (comment).
Unfortunately I do not have a PowerPC (cross-)compilation build
environment ready to test, nor does the Premerge-CI build it.
llvm-sync Bot pushed a commit to arm/arm-toolchain that referenced this pull request Jun 29, 2026
…493)

The PPC-specific builtin moduls have implicit dependencies insert by
flang. For CMake to correctly setup the build order, they must be made
explicit.

This replicates the implicit module uses from

https://github.com/llvm/llvm-project/blob/12b20b36737094b1c521adff0c8f58aaaf2f41fb/flang/lib/Semantics/semantics.cpp#L680-L693
in the modules themselves. The PPC-specific modules compiled by Flang-RT
are listed here:

https://github.com/llvm/llvm-project/blob/12b20b36737094b1c521adff0c8f58aaaf2f41fb/flang-rt/lib/runtime/CMakeLists.txt#L213-L219

This should fix the intermittend build error mentioned in
llvm/llvm-project#205634 (comment).
Unfortunately I do not have a PowerPC (cross-)compilation build
environment ready to test, nor does the Premerge-CI build it.
LouisLu060211 pushed a commit to LouisLu060211/llvm-project that referenced this pull request Jun 30, 2026
The PPC-specific builtin moduls have implicit dependencies insert by
flang. For CMake to correctly setup the build order, they must be made
explicit.

This replicates the implicit module uses from

https://github.com/llvm/llvm-project/blob/12b20b36737094b1c521adff0c8f58aaaf2f41fb/flang/lib/Semantics/semantics.cpp#L680-L693
in the modules themselves. The PPC-specific modules compiled by Flang-RT
are listed here:

https://github.com/llvm/llvm-project/blob/12b20b36737094b1c521adff0c8f58aaaf2f41fb/flang-rt/lib/runtime/CMakeLists.txt#L213-L219

This should fix the intermittend build error mentioned in
llvm#205634 (comment).
Unfortunately I do not have a PowerPC (cross-)compilation build
environment ready to test, nor does the Premerge-CI build it.
maarcosrmz pushed a commit to maarcosrmz/llvm-project that referenced this pull request Jul 1, 2026
Two build failures reported after llvm#204260

* Unix Makefiles generator stops working: The cause is that the rules
for building each OBJECT library lands in its own Makefile, e.g.
`flang_rt.mod.fortran.builtins.dir/build.make` and
`libomp-mod.dir/build.make`. Trying to inject dependencies directly for
build rules in the other file does not work.

* `__ppc_types.f90` not tracked: Forgotten in llvm#204260 due to being only
conditionally enabled for PowerPC targets.

The solution for both is to just remove the workaround for CMake not
recognizing modules uses declared using `intrinsic` which caused these
problems. This PR promotes the `use` constructs in the module sources to
normal dependencies that are not ignored by CMake.

The `intrinsic` modifier changes the search path to only look for such a
module in `-fintrinsic-modules-path`. The difference is only
theoretical:
1. When compiling the intrinsic modules, there are no other search paths
than for the intrinsics anyway
2. Users should strongly avoid naming their modules the same as an
intrinsic module
3. Most of our intrinsic sources don't even use the `intrinsic` modifier
in the first place (e.g.
https://github.com/llvm/llvm-project/blob/1c9412432ff9f897d5fb096d31b945e50fbbb61d/flang-rt/lib/runtime/__cuda_builtins.f90#L13).
That is, if there was a problem with lookup ambiguity, these would have
already been a problem for those.
4. The checksum of used modules is only added into the .mod file (the
only reason why modules would need to be transitively rebuilt) when a
`use` statement appears. Many intrinsic modules don't explicitly use the
modules that are added implicitly by the compiler, such as
`__fortran_builtins`, and hence do not even need to be rebuilt.

I started this PR with a tested-working fix
([71c5e7f](https://github.com/llvm/llvm-project/pull/205634/changes/BASE..71c5e7f0ffcf2ebd58812d2e2812b22663be1631))
to the workaround code. But given the points above, there seems to be no
benefit of keeping the workaround code handling CMake version < 4.5
around just for some intrinsic modules to keep the `intrinsic` modifier
with no practical effect. A non-workaround path using CMake's
`Fortran_BUILDING_IN(S)TRINSIC_MODULES` setting had to be added in any
case for Unix Makefile generators (reported issue 1.) because injecting
dependencies is not possible with Unix Makefiles as stated, but
`Fortran_BUILDING_IN(S)TRINSIC_MODULES` also does not work with the
Ninja generator. Avoiding `use, intrinsic` keeps just one configuration
path.

I tested that modules are properly updated with Ninja and Unix
Makefiles:
 * Build from scratch
 * Modifying `__fortran_builtins.f90` rebuilds its dependent modules
 * Modifying `iso_c_binding.f90` rebuilds its dependent modules
(omp_lib.mod)
maarcosrmz pushed a commit to maarcosrmz/llvm-project that referenced this pull request Jul 1, 2026
The PPC-specific builtin moduls have implicit dependencies insert by
flang. For CMake to correctly setup the build order, they must be made
explicit.

This replicates the implicit module uses from

https://github.com/llvm/llvm-project/blob/12b20b36737094b1c521adff0c8f58aaaf2f41fb/flang/lib/Semantics/semantics.cpp#L680-L693
in the modules themselves. The PPC-specific modules compiled by Flang-RT
are listed here:

https://github.com/llvm/llvm-project/blob/12b20b36737094b1c521adff0c8f58aaaf2f41fb/flang-rt/lib/runtime/CMakeLists.txt#L213-L219

This should fix the intermittend build error mentioned in
llvm#205634 (comment).
Unfortunately I do not have a PowerPC (cross-)compilation build
environment ready to test, nor does the Premerge-CI build it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmake Build system in general and CMake in particular flang-rt openmp:libomp OpenMP host runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants