https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109854
Bug ID: 109854 Summary: Error: junk `(%rip)' after expression when using -flto on files compiled with and without -masm=intel Product: gcc Version: 13.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: bouanto at zoho dot com CC: marxin at gcc dot gnu.org Target Milestone: --- Hi. With those two source files: a.c: #include <stdio.h> void a(void) { puts("A"); } main.c: void a(void); int main(void) { a(); return 0; } and by running the following commands: gcc -c -flto a.c # Note the absence of -masm=intel gcc -masm=intel -O3 -flto a.o main.c -o main I get the following error: /tmp/cca9LQNs.s: Assembler messages: /tmp/cca9LQNs.s:17: Error: junk `(%rip)' after expression lto-wrapper: fatal error: gcc returned 1 exit status compilation terminated. /usr/bin/ld: error: lto-wrapper failed collect2: error: ld returned 1 exit status Compiling the a.c file with -masm=intel solves the issue. (Doing the opposite, that is compiling a.c with -masm=intel and main.c without gives a different error: /usr/bin/ld: /tmp/ccMwJTwN.ltrans0.ltrans.o: relocation R_X86_64_32S against undefined symbol `$8' can not be used when making a PIE object; recompile with -fPIE Please tell me if you want me to open a different issue for this case.) Thanks to fix this issue.