https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129154
Bug ID: 129154
Summary: Alpha libgccjit emits an invalid !gpdisp! sequence on
repeated PIC compilation
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: linmag7 at gmail dot com
Target Milestone: ---
Created attachment 66339
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=66339&action=edit
The reproducer uses five successive libgccjit contexts in one process to
compile the same Alpha PIC function to an object file. On unpatched GCC, the
first succeeds and the assembler rejects the next
Product: gcc
Component: target
Version: 17.0
Target: alphaev6-unknown-linux-gnu
Summary: Alpha libgccjit emits an invalid !gpdisp! sequence on repeated PIC
compilation
On GCC trunk 389e48d33719dba3fda447f9e2d8fedf72ccda4c, a process
using libgccjit to emit Alpha PIC objects succeeds on its first JIT
context. On the next four contexts GNU as rejects the generated assembly.
Each context is acquired and released independently. The generated
function calls an imported function and reads an imported global.
Host: x86_64 GNU/Linux. Target: alphaev6-unknown-linux-gnu (EV6).
GCC base version 17.0.0. GNU assembler 2.47.50.20261111.
Cross-GCC was configured with --enable-languages=c,jit --enable-host-shared
--enable-shared --with-cpu=ev6 --enable-checking=release and an explicit
--with-as pointing to the Alpha assembler.
Attach repeat-alpha-jit.c. With the host C compiler and the Alpha-targeting
libgccjit header and library on the include and library search paths, run:
cc repeat-alpha-jit.c -lgccjit -o repeat-alpha-jit
./repeat-alpha-jit
Expected: five successful compilations, exit status 0.
Actual: context 1 succeeds. Contexts 2 through 5 each report
"Error: Bad sequence number: !gpdisp!" from GAS and
"error invoking gcc driver" from libgccjit. The reproducer exits 1.
The Alpha relocation sequence counter has a static initializer of one
and is registered with GCC's garbage collector. JIT cleanup clears the
counter between compilations. Resetting it to one in alpha_file_start
gives each output file a fresh sequence. This reproducer needs neither
a Rust toolchain nor an Alpha execution environment.
Verified locally with the proposed reset on the same trunk revision: all
five contexts produced objects and the standalone reproducer exited 0.