https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111966
Bug ID: 111966 Summary: GCN '--with-arch=[...]' not considered for 'mkoffload' default 'elf_arch' Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: openacc, openmp Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: tschwinge at gcc dot gnu.org CC: ams at gcc dot gnu.org, jules at gcc dot gnu.org Target Milestone: --- Target: GCN I've noticed this issue long ago; it probably existed since commit r11-2178-ga4f49061b6d921f72b2faf4843144f3c75f828f7 "amdgcn: Handle early debug info in mkoffload", when GCN offloading GCC 'configure'd different from (implicit or explicit) '--with-arch=fiji', and compiling user code without explicit '-foffload-options=amdgcn-amdhsa=-march=[...]'. In that case, the compiler-side default doesn't match 'gcc/config/gcn/mkoffload.cc:uint32_t elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX803;', and 'elf_arch' isn't getting corrected by an explicit '-march'. In that case, you'll get offloading compilation failures if debugging ('-g') is enabled, for example: [-PASS:-]{+FAIL:+} libgomp.fortran/declare-target-1.f90 -O3 -g (test for excess errors) [-PASS:-]{+UNRESOLVED:+} libgomp.fortran/declare-target-1.f90 -O3 -g [-execution test-]{+compilation failed to produce executable+} ... due to: [...] ld: error: incompatible mach: /tmp/cc8pa454.mkoffload.dbg.o collect2: error: ld returned 1 exit status gcn mkoffload: fatal error: [...]/x86_64-pc-linux-gnu-accel-amdgcn-amdhsa-gcc returned 1 exit status [...] ('elf_arch' is used only in 'copy_early_debug_info'.) Not a very typical configuration that anyone but me would have used ;-) -- but I'm reporting it now, given that as of recent commit r14-4734-g56ed1055b2f40ac162ae8d382280ac07a33f789f "amdgcn: deprecate Fiji device and multilib", users are more likely to run into this: the compiler-side default is now '--with-arch=gfx900' instead of 'fiji', and generally people may specify a specific non-'fiji' '--with-arch=[...]' (for example, together with '--without-multilib-list'), and build their code without explicit '-foffload-options=amdgcn-amdhsa=-march=[...]'. We need to propagate the compiler-side default '--with-arch=[...]' into 'mkoffload' 'elf_arch' -- or change the driver to simply always pass an explicit '-march' to 'mkoffload' (and verify that, make the default 'elf_arch' invalid)?