commit 38af228edf05fe0ec13aad9ebd296b9c5ccfd835
parent b25e7b4e260fb0d477be6d5c8ec11f507590abd3
Author: Jan Pobrislo <ccx@te2000.cz>
Date: Sun, 14 Dec 2025 15:34:48 +0000
ESETROOT support in gcc
Diffstat:
7 files changed, 103 insertions(+), 35 deletions(-)
diff --git a/filelist.sha256 b/filelist.sha256
@@ -38,6 +38,8 @@ b9236c0fd504ffbc56f65d0522d2acadcd2683380eaa6f1873e8201eaa7388a5 files/default-
1b44a63d415c48ac68d210951fec8d4761d3522f3d82d53182e66fabe5e2f2cd files/easyseccomp-configure.tar
eec15ac67403946e9d988d485f11764cf313b4798efe01d40f951ff521a23d10 files/easyseccomp_fix_includes.patch
a6ffb38364effd623e135b206ec97ff9e6826a1f285e349a3633df55db38bc9e files/elf.h
+c84acd325d75a23a74209cf15a184da7663b7eaa40048f4925ebf028ae3e16f1 files/gcc14-esetroot.patch
+f5c64eac06f454fac0dfed81e5112fa21ec12c0e78f46d25fd6aaa57ff5d311f files/gcc14-no-mangle-cflags.patch
0991a992f75396056c7d7f698fa7e87be24349ae85a195060d46e6a61881d97b files/gelf.h
cc2633ee136db0283d4faf7c27c890641e90cd835fc3adb19eaf0569e4078867 files/lh_bootstrap-x86_64-config
3b20df1d58f9a445785503415aea1188d33159327c2edab3d370dbd37bc4845e files/libelf.h
diff --git a/files/gcc14-esetroot.patch b/files/gcc14-esetroot.patch
@@ -0,0 +1,60 @@
+commit 287f90318af7e4d09f65351355f080d81e4e30d6
+Author: James Le Cuirot <chewi@gentoo.org>
+Date: Sun Aug 4 17:02:06 2024 +0100
+
+ gentoo: Allow setting target sysroot with ESYSROOT env var for cross-compilers
+
+ The variable is ignored for native compilers. The --sysroot command line
+ option takes precedence.
+
+ Signed-off-by: James Le Cuirot <chewi@gentoo.org>
+
+diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
+index b14ad30cdf2..fbec579ae32 100644
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -19027,6 +19027,10 @@ for this option. If your linker does not support this option, the
+ header file aspect of @option{--sysroot} still works, but the
+ library aspect does not.
+
++On MRRL, this option can also be set for cross-compilers using the
++@env{ESYSROOT} environmnent variable. The variable is ignored for native
++compilers. The command line option takes precedence.
++
+ @opindex no-sysroot-suffix
+ @item --no-sysroot-suffix
+ For some targets, a suffix is added to the root directory specified
+@@ -37422,6 +37426,12 @@ using GCC also uses these directories when searching for ordinary
+ libraries for the @option{-l} option (but directories specified with
+ @option{-L} come first).
+
++@vindex ESYSROOT
++@item ESYSROOT
++On MRRL, this variable sets the logical root directory for headers and
++libraries for cross-compilers. It is ignored for native compilers. The
++@option{--sysroot} option takes precedence.
++
+ @vindex LANG
+ @cindex locale definition
+ @item LANG
+diff --git a/gcc/gcc.cc b/gcc/gcc.cc
+index 825ad1cb5e7..cf42ecf5b12 100644
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -5507,6 +5507,16 @@ process_command (unsigned int decoded_options_count,
+ "BINUTILS", PREFIX_PRIORITY_LAST, 0, 1);
+ free (tooldir_prefix);
+
++ if (*cross_compile == '1' && !target_system_root_changed)
++ {
++ const char *esysroot = env.get("ESYSROOT");
++ if (esysroot && esysroot[0] != '\0' && strcmp(esysroot, "/") != 0 && (!target_system_root || strcmp(esysroot, target_system_root) != 0))
++ {
++ target_system_root = esysroot;
++ target_system_root_changed = 1;
++ }
++ }
++
+ #if defined(TARGET_SYSTEM_ROOT_RELOCATABLE) && !defined(VMS)
+ /* If the normal TARGET_SYSTEM_ROOT is inside of $exec_prefix,
+ then consider it to relocate with the rest of the GCC installation
diff --git a/templates/pkg/gcc b/templates/pkg/gcc
@@ -14,10 +14,12 @@
#+{{pkg_install_name("mpc")}}
#+{{pkg_install_name("mpfr")}}
#@sha256:{{files["mcm-"~shortname~"-"~pkg_version~"-merged.diff"]}}:merged.patch
+#@sha256:{{files["gcc14-esetroot.patch"]}}:esetroot.patch
{% endblock package_deps %}
{% block prepare %}
{{- super() }}
patch -p1 <../merged.patch
+patch -p1 <../esetroot.patch
{% endblock prepare %}
{% block configure %}
export TZ=UTC
@@ -105,16 +107,16 @@ repro="$repro -ffile-prefix-map=${src}=builddir"
# to avoid gcc or it's install scripts getting confused by unusual layout. #}
"../${src##*/}/configure" \ {#- use relative path here as it's stored in the binary #}
--enable-languages=c,c++ \
- --prefix="$prefix" \
- --bindir="$prefix/{{bindir}}" \
- --sbindir="$prefix/{{sbindir}}" \
- --infodir="$prefix/{{infodir}}" \
- --localedir="$prefix/{{localedir}}" \
- --mandir="$prefix/{{mandir}}" \
- --libdir="$prefix/lib" \
- --docdir="$prefix/{{docdir}}/{{shortname}}" \
- --datadir="$prefix/{{datadir}}" \
- --datarootdir="$prefix/{{datarootdir}}" \
+ --prefix="/" \
+ --bindir="/{{bindir}}" \
+ --sbindir="/{{sbindir}}" \
+ --infodir="/{{infodir}}" \
+ --localedir="/{{localedir}}" \
+ --mandir="/{{mandir}}" \
+ --libdir="/lib" \
+ --docdir="/{{docdir}}/{{shortname}}" \
+ --datadir="/{{datadir}}" \
+ --datarootdir="/{{datarootdir}}" \
--localstatedir='{{var_dir}}' \
--disable-bootstrap \
--disable-assembly \
@@ -162,7 +164,7 @@ with_make_vars {{make}}
{%- endblock build %}
{%- block install %}
-with_make_vars make "DESTDIR=$pthbs_destdir" install
+with_make_vars make "DESTDIR=$dest" install
cd "$pthbs_workdir"
diff --git a/variants/ccx-x86_64/gcc b/variants/ccx-x86_64/gcc
@@ -9,6 +9,7 @@
#+mpc.42c7dbd72d71e756d1d4dcb5f32ce3218ed6024e5a9a04ea791abc6d2b01fed5
#+mpfr.0c92c3445f9d01d385640a5bcebe8f42c516addc6c59a96a255e49328754a5a2
#@sha256:62eb68290502d54b16457509aa0c3995a84116408e6b593d676b9f4c03b6b160:merged.patch
+#@sha256:c84acd325d75a23a74209cf15a184da7663b7eaa40048f4925ebf028ae3e16f1:esetroot.patch
#@untar:-J:sha256:e0dc77297625631ac8e50fa92fffefe899a4eb702592da5c32ef04e2293aca3a:.
@@ -40,6 +41,7 @@ dest=${pthbs_destdir%/}${prefix}
cd 'gcc-14.3.0'
patch -p1 <../merged.patch
+patch -p1 <../esetroot.patch
export TZ=UTC
@@ -119,16 +121,16 @@ repro="$repro -ffile-prefix-map=${src}=builddir"
"../${src##*/}/configure" \
--enable-languages=c,c++ \
- --prefix="$prefix" \
- --bindir="$prefix/command" \
- --sbindir="$prefix/command" \
- --infodir="$prefix/info" \
- --localedir="$prefix/locale" \
- --mandir="$prefix/man" \
- --libdir="$prefix/lib" \
- --docdir="$prefix/doc/gcc" \
- --datadir="$prefix/data" \
- --datarootdir="$prefix/data" \
+ --prefix="/" \
+ --bindir="/command" \
+ --sbindir="/command" \
+ --infodir="/info" \
+ --localedir="/locale" \
+ --mandir="/man" \
+ --libdir="/lib" \
+ --docdir="/doc/gcc" \
+ --datadir="/data" \
+ --datarootdir="/data" \
--localstatedir='/var/pthbs' \
--disable-bootstrap \
--disable-assembly \
@@ -170,7 +172,7 @@ for tgt in configure-target all-gcc all-target-libgcc; do
done
with_make_vars make -j${JOBS:-1} -l$((1+${JOBS:-1}))
-with_make_vars make "DESTDIR=$pthbs_destdir" install
+with_make_vars make "DESTDIR=$dest" install
cd "$pthbs_workdir"
diff --git a/variants/ccx-x86_64/toolchain.environment b/variants/ccx-x86_64/toolchain.environment
@@ -1,4 +1,4 @@
#!/usr/bin/env pthbs-build
#+musl.94daa1199f58e276874a1a0bfcf66f23082039e9c2419121909a9e6405c09071
-#+gcc.8500e5a435e6ee5317a879c2843865807dbe9f9406760e2031af2f40eec9021e
+#+gcc.165ed7972a2aa8d32267e1afc5b7e04927b1098a6e3eebd8837f97a0047314de
#+binutils.b278e6c87188c63bf20864c68b02c89bda50217e79bb0ef260a0c8dc4808dee0
\ No newline at end of file
diff --git a/variants/root-x86_64/gcc b/variants/root-x86_64/gcc
@@ -9,6 +9,7 @@
#+mpc.c49a0ca0206bf91daf1dbc6f1aa06d82d9d6c19da9b4e5a4d98341d70f02b866
#+mpfr.6c584f4c5922b5c4494a52bd9a84a6e4db74f5c3e512493df59efe29356f2d20
#@sha256:62eb68290502d54b16457509aa0c3995a84116408e6b593d676b9f4c03b6b160:merged.patch
+#@sha256:c84acd325d75a23a74209cf15a184da7663b7eaa40048f4925ebf028ae3e16f1:esetroot.patch
#@untar:-J:sha256:e0dc77297625631ac8e50fa92fffefe899a4eb702592da5c32ef04e2293aca3a:.
@@ -40,6 +41,7 @@ dest=${pthbs_destdir%/}${prefix}
cd 'gcc-14.3.0'
patch -p1 <../merged.patch
+patch -p1 <../esetroot.patch
export TZ=UTC
@@ -119,16 +121,16 @@ repro="$repro -ffile-prefix-map=${src}=builddir"
"../${src##*/}/configure" \
--enable-languages=c,c++ \
- --prefix="$prefix" \
- --bindir="$prefix/command" \
- --sbindir="$prefix/command" \
- --infodir="$prefix/info" \
- --localedir="$prefix/locale" \
- --mandir="$prefix/man" \
- --libdir="$prefix/lib" \
- --docdir="$prefix/doc/gcc" \
- --datadir="$prefix/data" \
- --datarootdir="$prefix/data" \
+ --prefix="/" \
+ --bindir="/command" \
+ --sbindir="/command" \
+ --infodir="/info" \
+ --localedir="/locale" \
+ --mandir="/man" \
+ --libdir="/lib" \
+ --docdir="/doc/gcc" \
+ --datadir="/data" \
+ --datarootdir="/data" \
--localstatedir='/var/pthbs' \
--disable-bootstrap \
--disable-assembly \
@@ -170,7 +172,7 @@ for tgt in configure-target all-gcc all-target-libgcc; do
done
with_make_vars make -j${JOBS:-1} -l$((1+${JOBS:-1}))
-with_make_vars make "DESTDIR=$pthbs_destdir" install
+with_make_vars make "DESTDIR=$dest" install
cd "$pthbs_workdir"
diff --git a/variants/root-x86_64/toolchain.environment b/variants/root-x86_64/toolchain.environment
@@ -1,4 +1,4 @@
#!/usr/bin/env pthbs-build
#+musl.ea8bb1f16d8f8d43e5a131f724968612f185cfd2ce810694bac8bb7e450fac86
-#+gcc.7aa3ca9c71d4b9e9db5a743c3e72d2ca8f1c6e63b8c05805c1ee7a7dd8f4a3a9
+#+gcc.02b7589d64f7dbb65e5f397a25f2e8ea7038cd80eeac9b20a1ff93abcb8774d2
#+binutils.c110ec769847695ad17151c3e756346c7a77dc245ecad7b2ff895f721896d845
\ No newline at end of file