llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[flang-rt][CMake] Unix Makefiles offload build fails for builtin module dependency; Ninja works

Open Saieiei opened this issue 5 months ago • 3 comments

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:

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:

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:

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:

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.

Saieiei avatar Jun 24 '26 06:06 Saieiei

@llvm/issue-subscribers-flang-runtime

Author: Sairudra More (Saieiei)

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:

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:

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:

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:

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.

@Saieiei , this is resolved, right?

eugeneepshteyn avatar Aug 13 '26 16:08 eugeneepshteyn

Yes, this specific Unix Makefiles issue was fixed by #205634 although I haven’t rerun my exact original offload configuration

Saieiei avatar Aug 14 '26 10:08 Saieiei