]> git.ipfire.org Git - thirdparty/glibc.git/commit
Make gen-XX-const scripts work with llvm-as
authorJosh Kunz <jkz@google.com>
Wed, 7 Aug 2019 18:40:50 +0000 (11:40 -0700)
committerFangrui Song <i@maskray.me>
Sat, 28 Aug 2021 00:26:02 +0000 (17:26 -0700)
commitad41eacfb70e98e13cbfda076ded0c77b387ae8b
treec137dd765a7f4f65c315addcac10a08932ef8059
parent8d141ab782c4444a5e8f2e6eadfba7dea504f70d
Make gen-XX-const scripts work with llvm-as

The gen-as-const and gen-py-const scripts are used to generate integer constant
definitions from a list of constant C-expressions. This is achieved by
generating a C program with inline `asm` statements, that depend on
these constant expressions. During compilation, the constant expressions
are evaluated, and included in the inline asm. The build process
generates only the assembly, and then used `sed` to extract the values
from the assembly text.

This is clever. It allows the build process to extract the value of C
statements built under the target architecture. The implementation is a
bit fragile, but it is not immediately obvious to me how it could be
improved.

This change slightly modifies `gen-as-const` and `gen-py-const` to emit
valid assembly directives instead of invalid directives that were
previously emitted. Since the values are extracted via string parsing,
this has no effect on the values extracted. This is needed because the
LLVM assembler validates all statements before emitting them, whereas it
appears GCC will literally emit any `asm` directives without validation
or recognition.
Makerules
scripts/gen-as-const.awk
scripts/gen-py-const.awk