Skip to content

fix(gcc/v8): stop cc1 SIGSEGV on every compile (mirror main gcc PIE/no-LTO flags)#13770

Merged
jhheider merged 2 commits into
pkgxdev:mainfrom
tannevaled:fix/gcc-v8-cc1-loader-crash
Jul 13, 2026
Merged

fix(gcc/v8): stop cc1 SIGSEGV on every compile (mirror main gcc PIE/no-LTO flags)#13770
jhheider merged 2 commits into
pkgxdev:mainfrom
tannevaled:fix/gcc-v8-cc1-loader-crash

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Problem

The merged gnu.org/gcc/v8 bottle is unusable: its cc1/cc1plus SIGSEGV in the dynamic loader (dl_main) before the compiler even runs, so every compile fails:

gcc: internal compiler error: Segmentation fault signal terminated program cc1

Reproduced on a real x86-64 box (Debian bullseye, glibc 2.31); gdb shows the crash is in dl_main (rtld.c) while starting cc1, not in cc1's own code. Downstream consumers (e.g. mysql.com/v5_7 #13062) die at cmake's testCCompiler step because of this.

The recipe's test (gcc --version) never caught it — that only runs the driver, not cc1.

Root cause

The recipe set only -fPIC and none of the linkage flags the main gnu.org/gcc recipe applies for old (>=6, <10) gcc. Built by the modern pkgx toolchain (gcc 16 + binutils 2.46), the compiler executables come out linked such that an older glibc loader can't start them.

Fix — mirror the main gnu.org/gcc recipe's linux handling

  • --enable-default-pie (gcc 6+)
  • --disable-lto --disable-plugin (gcc <10 — the LTO plugin dlopens objects that mix the host ld-linux libc with the bottle's libc at link time)
  • CFLAGS/CXXFLAGS: -fPIC -fPIE
  • bake gmp/mpfr/mpc/zlib RUNPATHs so cc1/cc1plus are self-contained

…and harden the test to actually compile + link + run both a C and a C++ program, so this class of breakage can't regress unnoticed.

Verification

Verified end-to-end on x86-64: full build + install, then gcc/g++ compile, link and run C and C++ programs (exit 0), including in a clean env -i (confirming the RUNPATHs make the compiler self-contained). cc1 -S no longer crashes.

Unblocks #13062 (MySQL 5.7).

🤖 Generated with Claude Code

tannevaled and others added 2 commits July 10, 2026 16:04
…lags

The merged gnu.org/gcc/v8 bottle was unusable: its cc1/cc1plus SIGSEGV in
the dynamic loader (dl_main) before the compiler runs, so EVERY compile
fails with `gcc: internal compiler error: Segmentation fault ... cc1`.
Reproduced on a real x86-64 box (Debian bullseye). Consumers like
mysql.com/v5_7 die at cmake's testCCompiler step because of it.

Root cause: the recipe only set `-fPIC` and none of the linkage flags the
main gnu.org/gcc recipe applies for old (>=6, <10) gcc, so the compiler
executables built by the modern pkgx toolchain come out linked such that
an older glibc loader can't start them. The version-only test
(`gcc --version`) never caught it because that runs the driver, not cc1.

Fix mirrors the main recipe's linux handling:
 - --enable-default-pie (gcc 6+)
 - --disable-lto --disable-plugin (gcc <10: the LTO plugin dlopens objects
   that mix the host ld-linux libc with the bottle's libc at link time)
 - CFLAGS/CXXFLAGS: -fPIC -fPIE
 - bake gmp/mpfr/mpc/zlib RUNPATHs so cc1/cc1plus are self-contained
And harden the test to actually compile+link+RUN both C and C++, so this
class of breakage can't regress unnoticed.

Verified end-to-end on x86-64: full build+install, then gcc/g++ compile,
link and run C and C++ programs (exit 0), including in a clean `env -i`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Refactor package.yml to simplify platform and build steps.
@jhheider
jhheider merged commit e3e5bf4 into pkgxdev:main Jul 13, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants