https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84861
Martin Liška <marxin at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |marxin at gcc dot gnu.org Resolution|--- |INVALID --- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> --- > The only difference is "-flto". Having a top-level assembly requires to disable LTO for the compilation unit (-fno-lto). Otherwise as Andrew mentioned it can screw up LTO partitioning. > > It this a problem of LTO, or is the assembler supposed to be tweaked (how?) > so that the symbols get exported? > > Having a file containing > asm (""); > does compile, but a file containing only: > asm volatile (""); > fails with "error: expected ‘(’ before ‘volatile’". asm volatile can be used just within in a function body. The best approach you can do is to define a normal function and use asm to implement what you have written in assembly: ... " movq %rax, 0(%rdi)" "\n" " movq %rbx, 8(%rdi)" "\n" " movq %rcx, 16(%rdi)" "\n" ... Then LTO will work because the assembly will be encapsulated in a function. > > Happens with gcc 8.0.1 20180306 (experimental).