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.