https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96939
Bug ID: 96939 Summary: LTO vs. different arm arch options Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- $ cat a1.c extern unsigned crc (unsigned, const void *); typedef unsigned (*fnptr) (unsigned, const void *); volatile fnptr fn; int main () { fn = crc; return 0; } $ cat a2.c #include <arm_acle.h> unsigned crc (unsigned x, const void *y) { return __crc32cw (x, *(unsigned *) y); } $ ./xgcc -B ./ -O2 -march=armv7-a -mfpu=vfpv3-d16 -mtune=generic-armv7-a -mabi=aapcs-linux -mfloat-abi=hard -c a1.c -flto $ ./xgcc -B ./ -O2 -march=armv7-a -mfpu=vfpv3-d16 -mtune=generic-armv7-a -mabi=aapcs-linux -mfloat-abi=hard -march=armv8-a+crc -c a2.c -flto $ ./xgcc -B ./ -r -march=armv7-a -mfpu=vfpv3-d16 -mtune=generic-armv7-a -mabi=aapcs-linux -mfloat-abi=hard -o a a1.o a2.o -flto results in: a2.c: In function ‘crc’: a2.c:6:10: error: this builtin is not supported for this target 6 | return __crc32cw (x, *(unsigned *) y); | ^ Adding __attribute__((target ("arch=armv8-a+crc"))) to crc function doesn't help. In gdb I see (gdb) p global_options.x_arm_arch_string $2 = 0x2a38d50 "armv8-a+crc+simd" (gdb) p arm_arch_crc $3 = 0 which means the function got proper target attribute even if it didn't have one, TARGET_OPTIONS and the like, but arm_option_reconfigure_globals wasn't really called when changing current function from the armv7 built one (or the default) and the armv8-a+crc+simd one. I'm afraid this makes LTO not work at all on arm when one mixes command line options between TUs or uses target attribute.