[all-commits] [llvm/llvm-project] 22e13e: [Flang] Fix device-side module lookup (#200863)
Michael Kruse via All-commits
all-commits at lists.llvm.org
Mon Jun 1 16:48:18 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 22e13e71ed46f0d47f90ae5e6cea2956db892be3
https://github.com/llvm/llvm-project/commit/22e13e71ed46f0d47f90ae5e6cea2956db892be3
Author: Michael Kruse <llvm-project at meinersbur.de>
Date: 2026-06-02 (Tue, 02 Jun 2026)
Changed paths:
M clang/include/clang/Options/FlangOptions.td
M clang/lib/Driver/ToolChains/Flang.cpp
M flang/include/flang/Support/LangOptions.def
M flang/lib/Frontend/CompilerInvocation.cpp
M flang/lib/Semantics/mod-file.cpp
M flang/lib/Semantics/semantics.cpp
A flang/test/Semantics/Inputs/device_modfile01_a.mod
A flang/test/Semantics/device-modfile01.f90
A flang/test/Semantics/device-modfile02.f90
Log Message:
-----------
[Flang] Fix device-side module lookup (#200863)
When invoking flang with device-offloading (eg. `flang modfile.f90
-fopenmp --offload-arch=gfx90a`), it will invoke the frontend twice:
once for the host architecture, and a second time for the architecture
specified with `--offload-arch`. However, both frontend invocations are
going to write `modfile.mod` (or whatever the module name in
`modfile.f90`), and as a result the second one for gfx90a will be what
the file contains after the driver invocation returns. Until #171515
both version of the file were identical, but now both files are using a
different set of builtin modules. Since Flang's mod files store the
checksums of used module files in them, this can result in a checksum
mismatch error. For instance, modfile.mod being the gfx90a version, and
then using it to compile with `flang modfile.f90
--target=x86_64-linux-gnu`) will have a checksum mismath.
flang -fc1 host x86_64 --> modfile.mod --> lib/clang/23/finclude/flang/x86_64-linux-gnu/iso_fortran_env.mod
/ / \ \
flang -fc1 -foffload-device nvptx / \ lib/clang/23/finclude/flang/nvptx64-nvidia-cuda/iso_fortran_env.mod
/ \
flang -fc1 -foffload-device amdgcn lib/clang/23/finclude/flang/amdgcn-amd-amdhsa/iso_fortran_env.mod
We fix this by
1. Not overwriting the `--target` host module file with the
`--offload-arch` module; the auxiliary target is the canonical version
for its contents; and
2. Ignore checksum errors when using an intrinsic module during
offloading. The device version should be compatible with the host
version, just with definitions which the .mod file will eventually
import from the intrinsic module at compile-time.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list