Spidery
Spidery

Reputation: 43

GCC compilation : malformed generated ASM at the end of the file

Using Meson build and GCC on a personal C11 project with GLib on Linux Fedora, I keep randomly getting the following error when compiling :

movie.s: Assembler messages:
movie.s:6916: Error: no such instruction: `te.gnu-stack,"",@progbits'
ninja: build stopped: subcommand failed.

After inspecting the faulty file, the generated ASM ending is malformed (the last instruction look ill-copied ?)

Incorrect version :

.LASF52:
    .string "GClassInitFunc"
    .ident  "GCC: (GNU) 10.3.1 20210422 (Red Hat 10.3.1-1)"
    .section    .note.GNU-stack,"",@progbits
te.GNU-stack,"",@progbits

Correct version :

.LASF52:
    .string "GClassInitFunc"
    .ident  "GCC: (GNU) 10.3.1 20210422 (Red Hat 10.3.1-1)"
    .section    .note.GNU-stack,"",@progbits

As you can see on the last line of the faulty ASM, this output line is appended :

te.GNU-stack,"",@progbits

When this error occur, I basically relaunch the compilation process, and sometimes it just 'magically' work (without any modifications to any files).

My compiler versions :

Does anyone have any idea what could be causing this?


EDIT:
Solved the issue : Posted the issue on Meson Github : github.com/mesonbuild/meson/issues/8862 ; it was "save-temps" causing the harm, because ninja use parallel compilation which caused the intermediate files to be overwritten on the same time. You could either disable "-save-temps" or use "-j1" option to limit to one process

In summary : save-temps is not full parallel-safe when building multiple objects/executable with a common source file.

Upvotes: 1

Views: 299

Answers (1)

Spidery
Spidery

Reputation: 43

Meson build here ; basically I have two "executable" target with a shared source, and it seems the first overlap the second for some reason although it should be sequentially.

Example :

executable('app',
    sources: [
        'main.c',
        'movie.c',
    ],
    dependencies: [depglib, depgtk, deplibcurl],
)

executable('convert',
    sources: [
        'convert.c',
        'movie.c',
    ],
    dependencies: [depglib, depgio],
)

This answer suggest linking against a shared library : https://stackoverflow.com/a/47725711/7776411 ; I'll try that!

Thanks!

Upvotes: 2

Related Questions