xgcc: fix libstdc++ not being built with -fPIC

This commit is contained in:
Matheus
2024-08-21 21:32:24 -03:00
parent 6ba346151b
commit 8afbc8911c
2 changed files with 58 additions and 36 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ hostdeps="automake autoconf xbinutils pkgconfig"
deps="mlibc-headers" deps="mlibc-headers"
build() { build() {
${source_dir}/configure --target=x86_64-astral --prefix=${prefix} --with-sysroot=${sysroot_dir} --enable-languages=c,c++ -enable-threads=posix --disable-multilib ${source_dir}/configure --target=x86_64-astral --prefix=${prefix} --with-sysroot=${sysroot_dir} --enable-languages=c,c++ -enable-threads=posix --disable-multilib --enable-shared --enable-host-shared --with-pic
make all-gcc all-target-libgcc -j ${parallelism} make all-gcc all-target-libgcc -j ${parallelism}
} }
+57 -35
View File
@@ -1,7 +1,8 @@
diff -ruN gcc-12.1.0/config.sub gcc-12.1.0-patched/config.sub diff --git gcc-clean/config.sub gcc-workdir/config.sub
--- gcc-12.1.0/config.sub 2022-05-06 04:30:56.000000000 -0300 index 38f3d03..ee981b0 100755
+++ gcc-12.1.0-patched/config.sub 2022-09-14 19:57:47.513031678 -0300 --- gcc-clean/config.sub
@@ -1749,7 +1749,7 @@ +++ gcc-workdir/config.sub
@@ -1749,7 +1749,7 @@ case $os in
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
@@ -10,10 +11,11 @@ diff -ruN gcc-12.1.0/config.sub gcc-12.1.0-patched/config.sub
;; ;;
# This one is extra strict with allowed versions # This one is extra strict with allowed versions
sco3.2v2 | sco3.2v[4-9]* | sco5v6*) sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
diff -ruN gcc-12.1.0/fixincludes/mkfixinc.sh gcc-12.1.0-patched/fixincludes/mkfixinc.sh diff --git gcc-clean/fixincludes/mkfixinc.sh gcc-workdir/fixincludes/mkfixinc.sh
--- gcc-12.1.0/fixincludes/mkfixinc.sh 2022-05-06 04:30:56.000000000 -0300 index df90720..aebfb82 100755
+++ gcc-12.1.0-patched/fixincludes/mkfixinc.sh 2022-09-14 19:59:55.153030645 -0300 --- gcc-clean/fixincludes/mkfixinc.sh
@@ -11,6 +11,8 @@ +++ gcc-workdir/fixincludes/mkfixinc.sh
@@ -11,6 +11,8 @@ target=fixinc.sh
# Check for special fix rules for particular targets # Check for special fix rules for particular targets
case $machine in case $machine in
@@ -22,9 +24,11 @@ diff -ruN gcc-12.1.0/fixincludes/mkfixinc.sh gcc-12.1.0-patched/fixincludes/mkfi
i?86-*-cygwin* | \ i?86-*-cygwin* | \
i?86-*-mingw32* | \ i?86-*-mingw32* | \
x86_64-*-mingw32* | \ x86_64-*-mingw32* | \
diff -ruN gcc-12.1.0/gcc/config/astral.h gcc-12.1.0-patched/gcc/config/astral.h diff --git gcc-workdir/gcc/config/astral.h gcc-workdir/gcc/config/astral.h
--- gcc-12.1.0/gcc/config/astral.h 1969-12-31 21:00:00.000000000 -0300 new file mode 100644
+++ gcc-12.1.0-patched/gcc/config/astral.h 2022-09-14 19:58:16.803031441 -0300 index 0000000..fe6e2e1
--- /dev/null
+++ gcc-workdir/gcc/config/astral.h
@@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
+#undef TARGET_ASTRAL +#undef TARGET_ASTRAL
+#define TARGET_ASTRAL 1 +#define TARGET_ASTRAL 1
@@ -50,10 +54,11 @@ diff -ruN gcc-12.1.0/gcc/config/astral.h gcc-12.1.0-patched/gcc/config/astral.h
+ builtin_assert ("system=unix"); \ + builtin_assert ("system=unix"); \
+ builtin_assert ("system=posix"); \ + builtin_assert ("system=posix"); \
+ } while(0); + } while(0);
diff -ruN gcc-12.1.0/gcc/config.gcc gcc-12.1.0-patched/gcc/config.gcc diff --git gcc-clean/gcc/config.gcc gcc-workdir/gcc/config.gcc
--- gcc-12.1.0/gcc/config.gcc 2022-05-06 04:30:56.000000000 -0300 index c5064dd..e151646 100644
+++ gcc-12.1.0-patched/gcc/config.gcc 2022-09-14 19:57:58.466364923 -0300 --- gcc-clean/gcc/config.gcc
@@ -773,6 +773,14 @@ +++ gcc-workdir/gcc/config.gcc
@@ -773,6 +773,14 @@ case ${target} in
tmake_file="${tmake_file} t-dragonfly" tmake_file="${tmake_file} t-dragonfly"
target_has_targetdm=yes target_has_targetdm=yes
;; ;;
@@ -68,7 +73,7 @@ diff -ruN gcc-12.1.0/gcc/config.gcc gcc-12.1.0-patched/gcc/config.gcc
*-*-freebsd*) *-*-freebsd*)
# This is the generic ELF configuration of FreeBSD. Later # This is the generic ELF configuration of FreeBSD. Later
# machine-specific sections may refine and add to this # machine-specific sections may refine and add to this
@@ -1087,6 +1093,9 @@ @@ -1087,6 +1095,9 @@ case ${target} in
esac esac
case ${target} in case ${target} in
@@ -78,10 +83,11 @@ diff -ruN gcc-12.1.0/gcc/config.gcc gcc-12.1.0-patched/gcc/config.gcc
aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*) aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*)
tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h" tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h"
tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-elf-raw.h" tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-elf-raw.h"
diff -ruN gcc-12.1.0/libgcc/config.host gcc-12.1.0-patched/libgcc/config.host diff --git gcc-clean/libgcc/config.host gcc-workdir/libgcc/config.host
--- gcc-12.1.0/libgcc/config.host 2022-05-06 04:30:59.000000000 -0300 index 8c56fca..aecb1da 100644
+++ gcc-12.1.0-patched/libgcc/config.host 2022-09-14 19:59:26.003030881 -0300 --- gcc-clean/libgcc/config.host
@@ -751,6 +751,10 @@ +++ gcc-workdir/libgcc/config.host
@@ -751,6 +751,10 @@ i[34567]86-*-openbsd*)
;; ;;
x86_64-*-openbsd*) x86_64-*-openbsd*)
;; ;;
@@ -92,10 +98,37 @@ diff -ruN gcc-12.1.0/libgcc/config.host gcc-12.1.0-patched/libgcc/config.host
i[34567]86-*-linux*) i[34567]86-*-linux*)
extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o" extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o"
tmake_file="${tmake_file} i386/t-crtpc t-crtfm i386/t-crtstuff t-dfprules" tmake_file="${tmake_file} i386/t-crtpc t-crtfm i386/t-crtstuff t-dfprules"
diff -ruN gcc-12.1.0/libstdc++-v3/crossconfig.m4 gcc-12.1.0-patched/libstdc++-v3/crossconfig.m4 diff --git gcc-clean/libgcc/libgcov.h gcc-workdir/libgcc/libgcov.h
--- gcc-12.1.0/libstdc++-v3/crossconfig.m4 2022-05-06 04:31:00.000000000 -0300 index 40e845c..cbe95b8 100644
+++ gcc-12.1.0-patched/libstdc++-v3/crossconfig.m4 2022-09-14 19:58:39.359697928 -0300 --- gcc-clean/libgcc/libgcov.h
@@ -8,7 +8,12 @@ +++ gcc-workdir/libgcc/libgcov.h
@@ -25,6 +25,8 @@
#ifndef GCC_LIBGCOV_H
#define GCC_LIBGCOV_H
+#include <stdint.h>
+
/* work around the poisoned malloc/calloc in system.h. */
#ifndef xmalloc
#define xmalloc malloc
diff --git gcc-clean/libstdc++-v3/configure.ac gcc-workdir/libstdc++-v3/configure.ac
index e59bcdb..c2ac19b 100644
--- gcc-clean/libstdc++-v3/configure.ac
+++ gcc-workdir/libstdc++-v3/configure.ac
@@ -118,7 +118,7 @@ fi
# Use glibcxx_compiler_pic_flag to designate a compile-time flags for
# creating position-independent objects. This varies with the target
# hardware and operating system, but is often: -DPIC -fPIC.
-if test "$enable_shared" = yes; then
+if test "$enable_shared" = yes || test "${with_pic+set}" = set; then
glibcxx_lt_pic_flag="-prefer-pic"
glibcxx_compiler_pic_flag="$lt_prog_compiler_pic_CXX"
glibcxx_compiler_shared_flag="-D_GLIBCXX_SHARED"
diff --git gcc-clean/libstdc++-v3/crossconfig.m4 gcc-workdir/libstdc++-v3/crossconfig.m4
index ae5283b..15d769e 100644
--- gcc-clean/libstdc++-v3/crossconfig.m4
+++ gcc-workdir/libstdc++-v3/crossconfig.m4
@@ -8,7 +8,12 @@ case "${host}" in
arm*-*-symbianelf*) arm*-*-symbianelf*)
# This is a freestanding configuration; there is nothing to do here. # This is a freestanding configuration; there is nothing to do here.
;; ;;
@@ -109,14 +142,3 @@ diff -ruN gcc-12.1.0/libstdc++-v3/crossconfig.m4 gcc-12.1.0-patched/libstdc++-v3
avr*-*-*) avr*-*-*)
AC_DEFINE(HAVE_ACOSF) AC_DEFINE(HAVE_ACOSF)
AC_DEFINE(HAVE_ASINF) AC_DEFINE(HAVE_ASINF)
--- gcc-12.1.0/libgcc/libgcov.h 2022-05-06 04:30:59.000000000 -0300
+++ gcc-12.1.0-patched/libgcc/libgcov.h 2022-09-15 17:13:09.406451175 -0300
@@ -25,6 +25,8 @@
#ifndef GCC_LIBGCOV_H
#define GCC_LIBGCOV_H
+#include <stdint.h>
+
/* work around the poisoned malloc/calloc in system.h. */
#ifndef xmalloc
#define xmalloc malloc