[flang-rt][CMake] Unix Makefiles offload build fails for builtin module dependency; Ninja works
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
I am seeing a Unix Makefiles generator issue in an offload/flang-rt runtime build after #204260.
With Unix Makefiles, the build fails while building `flang_rt.mod.cuda.builtins`:
```text
make[5]: *** No rule to make target 'modules/./__fortran_builtins.o',
needed by 'flang_rt.mod.cuda.builtins.dir/__cuda_builtins.f90.o'. Stop.
```
The same configuration works with Ninja.
Environment:
```text
CMake: 3.28.3
Host compiler: GCC 14.3.0
Fortran compiler for runtime build: in-tree LLVMFlang (`flang`), 23.0.0git
OS: SUSE Linux Enterprise Server 15 SP7
Upstream commit tested: 1d8a54f7cf233be64ffce08a3c5697ea8f1cccb5
Suspected introducing commit: a92039c3e44e (#204260)
```
Configuration shape:
```text
LLVM_ENABLE_RUNTIMES=compiler-rt;flang-rt;openmp;offload
LLVM_RUNTIME_TARGETS=default;amdgcn-amd-amdhsa
RUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES=openmp;flang-rt
LIBOMPTARGET_DEVICE_ARCHITECTURES=gfx908
Failed generator: Unix Makefiles
Working generator: Ninja
```
From the generated Makefiles, `flang_rt.mod.cuda.builtins` depends on `modules/./__fortran_builtins.o`, but the rule that produces/touches that file appears to be in the separate `flang_rt.mod.fortran.builtins` target's `build.make`. Since Unix Makefiles uses recursive per-target makefiles, the cuda builtins sub-make does not appear to see the producer rule.
Ninja succeeds on the same setup, including a targeted build of `flang_rt.mod.cuda.builtins` and a full offload/flang-rt build.
Temporary workaround:
```text
Use the Ninja generator for this configuration.
```
Question:
Is Unix Makefiles still expected to work for this flang-rt/offload configuration? If yes, this may need a different CMake dependency expression for the builtin module object edge. If no, should this configuration document or require Ninja?
Related:
* #204260
* #203549
Note: GitHub suggested #175374 as a possible duplicate, but that appears to be a different issue. That one reports a Ninja failure involving `projects/openmp/runtime/src/omp_lib.F90`, while this issue is a Unix Makefiles failure involving `modules/./__fortran_builtins.o`; Ninja works here.
Contributor guide
Research direction
Start with the generated Makefiles for flang_rt.mod.cuda.builtins and the separate flang_rt.mod.fortran.builtins build.make, then reproduce the targeted build with Unix Makefiles. Compare the dependency edges with the working Ninja build and review #204260 and #203549. Done means the Unix Makefiles configuration builds successfully, or its Ninja-only requirement is explicitly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100