8000 glibc 2.42→2.43 + C23-const FTBFS fixes (make stack + gcc) by bryan-minimal · Pull Request #238 · gominimal/pkgs · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/elfutils/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ case $(uname -m) in
aarch64) MARCH="-march=armv8-a" ;;
*) MARCH="" ;;
esac
export CFLAGS="$MARCH -O2 -pipe -gno-record-gcc-switches -Wl,--build-id=none -ffile-prefix-map=$(pwd)=/builddir"
# -Wno-error=discarded-qualifiers: glibc 2.43's ISO C23 const-preserving
# bsearch/strchr-family return const for const args; elfutils assigns those to
# plain pointers (libcpu/riscv_disasm.c known_csrs bsearch) under its default-on
# -Werror. elfutils' configure has no --disable-werror in this version, but
# automake emits `$(AM_CFLAGS) $(CFLAGS)`, so a CFLAGS flag lands after
# elfutils' AM_CFLAGS -Werror and wins. Same glibc-2.43 C23 FTBFS class as #238.
export CFLAGS="$MARCH -O2 -pipe -gno-record-gcc-switches -Wl,--build-id=none -ffile-prefix-map=$(pwd)=/builddir -Wno-error=discarded-qualifiers"
export LDFLAGS="-Wl,--build-id=none"
export ARFLAGS=Drc
export CXXFLAGS="${CFLAGS}"
Expand Down
28 changes: 28 additions & 0 deletions packages/gcc/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,34 @@ export LDFLAGS="-Wl,--build-id=none"
export CXXFLAGS="${CFLAGS}"
export ARFLAGS=Drc

8000 # glibc 2.43 implements ISO C23 const-preserving string macros: strchr,
# strrchr, strstr, memchr, etc. now return a `const char *` when given a
# `const char *`. gcc-15.2.0 predates this, so its libgomp source
# (libgomp/affinity-fmt.c: `char *q = strchr (p + 1, '}');`) assigns the
# result to a plain `char *` and trips -Werror=discarded-qualifiers, failing
# the build. The pointer is never written through (only used for `q - p`), so
# this is a source-pedantry mismatch, not a runtime bug.
#
# Downgrade ONLY that one warning (everything else stays -Werror), for gcc's
# own build only — the produced compiler is unaffected. CFLAGS_FOR_TARGET is
# the documented knob for target libraries like libgomp (BOOT_CFLAGS/CFLAGS
# don't reach them); see https://gcc.gnu.org/install/build.html. CFLAGS keeps
# it for gcc proper defensively.
#
# This is the interim escape hatch; gcc-16.1.0 fixes this upstream (it builds
# cleanly against glibc 2.43 — LFS pairs them with no workaround), so the
# clean follow-up is to bump gcc to 16. Refs:
# - glibc 2.43 C23 const-preserving macros:
# https://lists.gnu.org/archive/html/info-gnu/2026-01/msg00005.html
# - upstream gcc libgomp fix ("Fix GCC build after glibc@cd748a6"):
# https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg389139.html
# - LFS GCC-16.1.0 (builds against glibc 2.43, no const workaround):
# https://www.linuxfromscratch.org/lfs/view/development/chapter08/gcc.html
export CFLAGS="${CFLAGS} -Wno-error=discarded-qualifiers"
export CXXFLAGS="${CFLAGS}"
export CFLAGS_FOR_TARGET="${CFLAGS}"
export CXXFLAGS_FOR_TARGET="${CXXFLAGS}"

../configure \
--prefix=/usr \
--libdir=/usr/lib \
Expand Down
4 changes: 2 additions & 2 deletions packages/glibc/build.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ let all_outputs = {
}
in

let version = "2.42" in
let version = "2.43" in
{
name = "glibc",
build_deps = [
{ file = "build.sh" } | Local,
{
# Downloadable from: https://ftp.gnu.org/gnu/glibc/
url = "gs://minimal-staging-archives/glibc-%{version}.tar.xz",
sha256 = "d1775e32e4628e64ef930f435b67bb63af7599acb6be2b335b9f19f16509f17f"
sha256 = "d9c86c6b5dbddb43a3e08270c5844fc5177d19442cf5b8df4be7c07cd5fa3831"
} | Source,
# base
bash,
Expand Down
9 changes: 8 additions & 1 deletion packages/libxcrypt/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ case $(uname -m) in
aarch64) MARCH="-march=armv8-a" ;;
*) MARCH="" ;;
esac
export CFLAGS="$MARCH -O2 -pipe -gno-record-gcc-switches -ffile-prefix-map=$(pwd)=/builddir"
# -Wno-error=discarded-qualifiers: glibc 2.43's ISO C23 const-preserving
# strchr/strstr/memchr return `const char *` for a `const char *` arg, which
# libxcrypt's crypt-{gost,sm3}-yescrypt.c assign to a plain `char *` — tripping
# libxcrypt's own configure-enabled -Werror. This package has a hand-written
# build.sh (not the make stack), so the stacks/make/stack.ncl fleet lever can't
# reach it; we downgrade only that one warning here, landing after libxcrypt's
# -Werror on the compile line so the later flag wins. Same class as #238.
export CFLAGS="$MARCH -O2 -pipe -gno-record-gcc-switches -ffile-prefix-map=$(pwd)=/builddir -Wno-error=discarded-qualifiers"
export LDFLAGS="-Wl,--build-id=none"
export CXXFLAGS="${CFLAGS}"

Expand Down
14 changes: 14 additions & 0 deletions packages/or-tools/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ export CFLAGS="$MARCH -O2 -pipe -gno-record-gcc-switches -ffile-prefix-map=$(pwd
export LDFLAGS="-Wl,--build-id=none"
export CXXFLAGS="$CFLAGS"

# SCIP (FetchContent'd by or-tools under USE_SCIP=ON) bundles tinycthread, a C11
# <threads.h> shim that does `#define once_flag pthread_once_t`. glibc 2.43
# surfaces its native once_flag/call_once into SCIP's translation unit, so that
# macro corrupts glibc's `typedef __once_flag once_flag;` into a redefinition of
# pthread_once_t -> "conflicting types" FTBFS. or-tools hard-FORCEs SCIP's
# TPI=tny in its bundled cmake, so a top-level -DTPI=... can't override it; patch
# the source to use SCIP's OpenMP task interface instead (drops tinycthread,
# keeps SCIP parallel + THREADSAFE — SCIP auto-forces THREADSAFE on for any
# non-"none" TPI). libgomp is present from our gcc build. Fails fast at configure
# if OpenMP is somehow absent. glibc-2.43 toolchain-bump fallout, #238.
sed -i 's|set(TPI "tny" CACHE STRING "Scip param" FORCE)|set(TPI "omp" CACHE STRING "Scip param" FORCE)|' ../cmake/dependencies/CMakeLists.txt
grep -q 'set(TPI "omp"' ../cmake/dependencies/CMakeLists.txt \
|| { echo "ERROR: SCIP TPI patch did not apply — or-tools cmake/dependencies/CMakeLists.txt changed upstream"; exit 1; }

cmake -G Ninja \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=/usr/lib \
Expand Down
6 changes: 5 additions & 1 deletion packages/strace/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ case $(uname -m) in
aarch64) MARCH="-march=armv8-a" ;;
*) MARCH="" ;;
esac
export CFLAGS="$MARCH -O2 -pipe -gno-record-gcc-switches -ffile-prefix-map=$(pwd)=/builddir"
# -Wno-error=discarded-qualifiers: glibc 2.43's ISO C23 const-preserving bsearch
# returns const for a const arg; strace's ioctl.c assigns it to a plain pointer
# (iop = bsearch(..., ioctlent, ...)) under its default-on -Werror. Lands after
# strace's -Werror on the compile line so the later flag wins. glibc-2.43 class, #238.
export CFLAGS="$MARCH -O2 -pipe -gno-record-gcc-switches -ffile-prefix-map=$(pwd)=/builddir -Wno-error=discarded-qualifiers"
export LDFLAGS="-Wl,--build-id=none"
export CXXFLAGS="${CFLAGS}"

Expand Down
17 changes: 16 additions & 1 deletion stacks/make/stack.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,22 @@ stack {
build_env_vars = {
CC = "gcc",
CXX = "g++",
CFLAGS = "-O2 -pipe -gno-record-gcc-switches",
# glibc 2.43 implements ISO C23 const-preserving string macros: strchr,
# strrchr, strstr, memchr, etc. now return a `const char *` for a
# `const char *` argument. Pre-C23 code that assigns the result to a plain
# `char *` then trips -Werror=discarded-qualifiers and FTBFS. This is an
# ecosystem-wide wave (openssl, libxcrypt, grub, ...), not a one-off, so
# downgrade ONLY that one warning fleet-wide for every make/autotools
# build. It lands after each package's own -Werror on the compile line, so
# the later flag wins. This is DURABLE, not interim: a gcc-16 bump only
# fixes gcc's OWN source (its libgomp), so it retires packages/gcc/build.sh
# — it does NOT help the rest of the fleet, which still trips the same break
# under any gcc against glibc 2.43. This lever stays until either the
# ecosystem adopts C23-compatible source or we move it to -std=gnu17 (which
# restores the C17 prototypes so strchr returns `char *` — no warning at
# all, but a broader language-standard change).
# Ref: https://lists.gnu.org/archive/html/info-gnu/2026-01/msg00005.html
CFLAGS = "-O2 -pipe -gno-record-gcc-switches -Wno-error=discarded-qualifiers",
},

build_cmds_cmd = [
Expand Down
0