Toolchain+Ports: Enable threads for gcc
This enables POSIX threads for GCC and makes the -pthread argument available.
This commit is contained in:
parent
7400e3d8fc
commit
75d41657d5
Notes:
sideshowbarker
2024-07-18 19:19:46 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/75d41657d5e Pull-request: https://github.com/SerenityOS/serenity/pull/6343
5 changed files with 101 additions and 19 deletions
6
.github/workflows/cmake.yml
vendored
6
.github/workflows/cmake.yml
vendored
|
@ -67,13 +67,13 @@ jobs:
|
|||
# *and* as actual output variable, in this order.
|
||||
message(" set-output name=time::${current_date}")
|
||||
message("::set-output name=time::${current_date}")
|
||||
message(" set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/BuildIt.sh') }}")
|
||||
message("::set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/BuildIt.sh') }}")
|
||||
message(" set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/BuildIt.sh') }}")
|
||||
message("::set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/BuildIt.sh') }}")
|
||||
- name: Toolchain cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ github.workspace }}/Toolchain/Cache/
|
||||
# This assumes that *ALL* LibC headers have an impact on the Toolchain.
|
||||
# This assumes that *ALL* LibC and LibPthread headers have an impact on the Toolchain.
|
||||
# This is wrong, and causes more Toolchain rebuilds than necessary.
|
||||
# However, we want to avoid false cache hits at all costs.
|
||||
key: ${{ runner.os }}-toolchain-i686-${{ steps.stamps.outputs.libc_headers }}
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
port=gcc
|
||||
version=10.3.0
|
||||
useconfigure=true
|
||||
configopts="--target=${SERENITY_ARCH}-pc-serenity --with-sysroot=/ --with-build-sysroot=${SERENITY_INSTALL_ROOT} --with-newlib --enable-languages=c,c++ --disable-lto --disable-nls --enable-shared --enable-default-pie --enable-host-shared"
|
||||
configopts="--target=${SERENITY_ARCH}-pc-serenity --with-sysroot=/ --with-build-sysroot=${SERENITY_INSTALL_ROOT} --with-newlib --enable-languages=c,c++ --disable-lto --disable-nls --enable-shared --enable-default-pie --enable-host-shared --enable-threads=posix"
|
||||
files="https://ftpmirror.gnu.org/gnu/gcc/gcc-${version}/gcc-${version}.tar.xz gcc-${version}.tar.xz
|
||||
https://ftpmirror.gnu.org/gnu/gcc/gcc-${version}/gcc-${version}.tar.xz.sig gcc-${version}.tar.xz.sig
|
||||
https://ftpmirror.gnu.org/gnu/gnu-keyring.gpg gnu-keyring.gpg"
|
||||
configopts="--target=${SERENITY_ARCH}-pc-serenity --with-sysroot=/ --with-build-sysroot=${SERENITY_BUILD_DIR}/Root --with-newlib --enable-languages=c,c++ --disable-lto --disable-nls --enable-shared --enable-default-pie --enable-host-shared --enable-threads=posix"
|
||||
makeopts="all-gcc all-target-libgcc all-target-libstdc++-v3 -j $(nproc)"
|
||||
installopts="DESTDIR=${SERENITY_INSTALL_ROOT} install-gcc install-target-libgcc install-target-libstdc++-v3"
|
||||
depends="binutils"
|
||||
|
|
|
@ -6,7 +6,7 @@ diff -ruN a/config.sub b/config.sub
|
|||
# Copyright 1992-2019 Free Software Foundation, Inc.
|
||||
|
||||
-timestamp='2019-06-30'
|
||||
+timestamp='2020-05-16'
|
||||
+timestamp='2021-04-20'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
|
@ -102,7 +102,7 @@ diff -ruN a/gcc/config/arm/serenity-elf.h b/gcc/config/arm/serenity-elf.h
|
|||
diff -ruN a/gcc/config/serenity.h b/gcc/config/serenity.h
|
||||
--- a/gcc/config/serenity.h 1970-01-01 02:00:00.000000000 +0200
|
||||
+++ b/gcc/config/serenity.h 2020-12-12 10:43:35.280270540 +0200
|
||||
@@ -0,0 +1,41 @@
|
||||
@@ -0,0 +1,44 @@
|
||||
+/* Useful if you wish to make target-specific GCC changes. */
|
||||
+#undef TARGET_SERENITY
|
||||
+#define TARGET_SERENITY 1
|
||||
|
@ -114,7 +114,7 @@ diff -ruN a/gcc/config/serenity.h b/gcc/config/serenity.h
|
|||
+/* Default arguments you want when running your
|
||||
+ i686-serenity-gcc/x86_64-serenity-gcc toolchain */
|
||||
+#undef LIB_SPEC
|
||||
+#define LIB_SPEC "-lc" /* link against C standard library */
|
||||
+#define LIB_SPEC "%{pthread:-lpthread} -lc" /* link against C standard library */
|
||||
+
|
||||
+/* Files that are linked before user code.
|
||||
+ The %s tells GCC to look for these files in the library directory. */
|
||||
|
@ -134,6 +134,9 @@ diff -ruN a/gcc/config/serenity.h b/gcc/config/serenity.h
|
|||
+#undef CC1PLUS_SPEC
|
||||
+#define CC1PLUS_SPEC "-fno-exceptions -ftls-model=initial-exec"
|
||||
+
|
||||
+#undef CPP_SPEC
|
||||
+#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
|
||||
+
|
||||
+/* Additional predefined macros. */
|
||||
+#undef TARGET_OS_CPP_BUILTINS
|
||||
+#define TARGET_OS_CPP_BUILTINS() \
|
||||
|
@ -144,10 +147,46 @@ diff -ruN a/gcc/config/serenity.h b/gcc/config/serenity.h
|
|||
+ builtin_assert ("system=unix"); \
|
||||
+ builtin_assert ("system=posix"); \
|
||||
+ } while(0);
|
||||
diff -ruN a/gcc/config/serenity.opt b/gcc/config/serenity.opt
|
||||
--- a/gcc/config/serenity.opt 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ b/gcc/config/serenity.opt 2021-04-18 11:59:44.933484216 +0200
|
||||
@@ -0,0 +1,32 @@
|
||||
+; SerenityOS options.
|
||||
+
|
||||
+; Copyright (C) 2021 Gunnar Beutner <gunnar@beutner.name>
|
||||
+;
|
||||
+; This file is part of GCC.
|
||||
+;
|
||||
+; GCC is free software; you can redistribute it and/or modify it under
|
||||
+; the terms of the GNU General Public License as published by the Free
|
||||
+; Software Foundation; either version 3, or (at your option) any later
|
||||
+; version.
|
||||
+;
|
||||
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
+; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
+; for more details.
|
||||
+;
|
||||
+; You should have received a copy of the GNU General Public License
|
||||
+; along with GCC; see the file COPYING3. If not see
|
||||
+; <http://www.gnu.org/licenses/>.
|
||||
+
|
||||
+; See the GCC internals manual (options.texi) for a description of
|
||||
+; this file's format.
|
||||
+
|
||||
+; Please try to keep this file in ASCII collating order.
|
||||
+
|
||||
+posix
|
||||
+Driver
|
||||
+
|
||||
+pthread
|
||||
+Driver
|
||||
+
|
||||
+; This comment is to ensure we retain the blank line above.
|
||||
diff -ruN a/gcc/config.gcc b/gcc/config.gcc
|
||||
--- a/gcc/config.gcc 2020-07-23 09:35:17.316384243 +0300
|
||||
+++ b/gcc/config.gcc 2020-12-12 10:43:35.280270540 +0200
|
||||
@@ -675,6 +675,11 @@
|
||||
@@ -675,6 +675,12 @@
|
||||
|
||||
# Common parts for widely ported systems.
|
||||
case ${target} in
|
||||
|
@ -155,11 +194,12 @@ diff -ruN a/gcc/config.gcc b/gcc/config.gcc
|
|||
+ gas=yes
|
||||
+ gnu_ld=yes
|
||||
+ default_use_cxa_atexit=yes
|
||||
+ extra_options="${extra_options} serenity.opt"
|
||||
+ ;;
|
||||
*-*-darwin*)
|
||||
tmake_file="t-darwin "
|
||||
tm_file="${tm_file} darwin.h"
|
||||
@@ -1033,6 +1038,15 @@
|
||||
@@ -1063,6 +1069,15 @@
|
||||
esac
|
||||
|
||||
case ${target} in
|
||||
|
@ -224,7 +264,7 @@ diff -ruN a/libgcc/config.host b/libgcc/config.host
|
|||
diff -ruN a/libstdc++-v3/configure b/libstdc++-v3/configure
|
||||
--- a/libstdc++-v3/configure 2020-07-23 09:35:19.188404867 +0300
|
||||
+++ b/libstdc++-v3/configure 2020-12-12 10:43:35.288270409 +0200
|
||||
@@ -29846,6 +29846,5986 @@
|
||||
@@ -29217,6 +29217,5986 @@
|
||||
|
||||
# Base decisions on target environment.
|
||||
case "${host}" in
|
||||
|
|
|
@ -239,14 +239,14 @@ pushd "$DIR/Build/$ARCH"
|
|||
buildstep "binutils/install" "$MAKE" install || exit 1
|
||||
popd
|
||||
|
||||
echo "XXX serenity libc and libm headers"
|
||||
echo "XXX serenity libc, libm and libpthread headers"
|
||||
mkdir -p "$BUILD"
|
||||
pushd "$BUILD"
|
||||
mkdir -p Root/usr/include/
|
||||
SRC_ROOT=$($REALPATH "$DIR"/..)
|
||||
FILES=$(find "$SRC_ROOT"/Userland/Libraries/LibC "$SRC_ROOT"/Userland/Libraries/LibM -name '*.h' -print)
|
||||
FILES=$(find "$SRC_ROOT"/Userland/Libraries/LibC "$SRC_ROOT"/Userland/Libraries/LibM "$SRC_ROOT"/Userland/Libraries/LibPthread -name '*.h' -print)
|
||||
for header in $FILES; do
|
||||
target=$(echo "$header" | sed -e "s@$SRC_ROOT/Userland/Libraries/LibC@@" -e "s@$SRC_ROOT/Userland/Libraries/LibM@@")
|
||||
target=$(echo "$header" | sed -e "s@$SRC_ROOT/Userland/Libraries/LibC@@" -e "s@$SRC_ROOT/Userland/Libraries/LibM@@" -e "s@$SRC_ROOT/Userland/Libraries/LibPthread@@")
|
||||
buildstep "system_headers" $INSTALL -D "$header" "Root/usr/include/$target"
|
||||
done
|
||||
unset SRC_ROOT
|
||||
|
@ -289,6 +289,7 @@ pushd "$DIR/Build/$ARCH"
|
|||
--enable-languages=c,c++ \
|
||||
--enable-default-pie \
|
||||
--enable-lto \
|
||||
--enable-threads=posix \
|
||||
${TRY_USE_LOCAL_TOOLCHAIN:+"--quiet"} || exit 1
|
||||
|
||||
if [ "$STAGE" = "Userland" ]; then
|
||||
|
|
|
@ -6,7 +6,7 @@ diff -ruN a/config.sub b/config.sub
|
|||
# Copyright 1992-2019 Free Software Foundation, Inc.
|
||||
|
||||
-timestamp='2019-06-30'
|
||||
+timestamp='2020-05-16'
|
||||
+timestamp='2021-04-20'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
|
@ -102,7 +102,7 @@ diff -ruN a/gcc/config/arm/serenity-elf.h b/gcc/config/arm/serenity-elf.h
|
|||
diff -ruN a/gcc/config/serenity.h b/gcc/config/serenity.h
|
||||
--- a/gcc/config/serenity.h 1970-01-01 02:00:00.000000000 +0200
|
||||
+++ b/gcc/config/serenity.h 2020-12-12 10:43:35.280270540 +0200
|
||||
@@ -0,0 +1,41 @@
|
||||
@@ -0,0 +1,44 @@
|
||||
+/* Useful if you wish to make target-specific GCC changes. */
|
||||
+#undef TARGET_SERENITY
|
||||
+#define TARGET_SERENITY 1
|
||||
|
@ -114,7 +114,7 @@ diff -ruN a/gcc/config/serenity.h b/gcc/config/serenity.h
|
|||
+/* Default arguments you want when running your
|
||||
+ i686-serenity-gcc/x86_64-serenity-gcc toolchain */
|
||||
+#undef LIB_SPEC
|
||||
+#define LIB_SPEC "-lc" /* link against C standard library */
|
||||
+#define LIB_SPEC "%{pthread:-lpthread} -lc" /* link against C standard library */
|
||||
+
|
||||
+/* Files that are linked before user code.
|
||||
+ The %s tells GCC to look for these files in the library directory. */
|
||||
|
@ -134,6 +134,9 @@ diff -ruN a/gcc/config/serenity.h b/gcc/config/serenity.h
|
|||
+#undef CC1PLUS_SPEC
|
||||
+#define CC1PLUS_SPEC "-fno-exceptions -ftls-model=initial-exec"
|
||||
+
|
||||
+#undef CPP_SPEC
|
||||
+#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
|
||||
+
|
||||
+/* Additional predefined macros. */
|
||||
+#undef TARGET_OS_CPP_BUILTINS
|
||||
+#define TARGET_OS_CPP_BUILTINS() \
|
||||
|
@ -144,10 +147,46 @@ diff -ruN a/gcc/config/serenity.h b/gcc/config/serenity.h
|
|||
+ builtin_assert ("system=unix"); \
|
||||
+ builtin_assert ("system=posix"); \
|
||||
+ } while(0);
|
||||
diff -ruN a/gcc/config/serenity.opt b/gcc/config/serenity.opt
|
||||
--- a/gcc/config/serenity.opt 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ b/gcc/config/serenity.opt 2021-04-18 11:59:44.933484216 +0200
|
||||
@@ -0,0 +1,32 @@
|
||||
+; SerenityOS options.
|
||||
+
|
||||
+; Copyright (C) 2021 Gunnar Beutner <gunnar@beutner.name>
|
||||
+;
|
||||
+; This file is part of GCC.
|
||||
+;
|
||||
+; GCC is free software; you can redistribute it and/or modify it under
|
||||
+; the terms of the GNU General Public License as published by the Free
|
||||
+; Software Foundation; either version 3, or (at your option) any later
|
||||
+; version.
|
||||
+;
|
||||
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
+; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
+; for more details.
|
||||
+;
|
||||
+; You should have received a copy of the GNU General Public License
|
||||
+; along with GCC; see the file COPYING3. If not see
|
||||
+; <http://www.gnu.org/licenses/>.
|
||||
+
|
||||
+; See the GCC internals manual (options.texi) for a description of
|
||||
+; this file's format.
|
||||
+
|
||||
+; Please try to keep this file in ASCII collating order.
|
||||
+
|
||||
+posix
|
||||
+Driver
|
||||
+
|
||||
+pthread
|
||||
+Driver
|
||||
+
|
||||
+; This comment is to ensure we retain the blank line above.
|
||||
diff -ruN a/gcc/config.gcc b/gcc/config.gcc
|
||||
--- a/gcc/config.gcc 2020-07-23 09:35:17.316384243 +0300
|
||||
+++ b/gcc/config.gcc 2020-12-12 10:43:35.280270540 +0200
|
||||
@@ -675,6 +675,11 @@
|
||||
@@ -675,6 +675,12 @@
|
||||
|
||||
# Common parts for widely ported systems.
|
||||
case ${target} in
|
||||
|
@ -155,11 +194,12 @@ diff -ruN a/gcc/config.gcc b/gcc/config.gcc
|
|||
+ gas=yes
|
||||
+ gnu_ld=yes
|
||||
+ default_use_cxa_atexit=yes
|
||||
+ extra_options="${extra_options} serenity.opt"
|
||||
+ ;;
|
||||
*-*-darwin*)
|
||||
tmake_file="t-darwin "
|
||||
tm_file="${tm_file} darwin.h"
|
||||
@@ -1033,6 +1038,15 @@
|
||||
@@ -1063,6 +1069,15 @@
|
||||
esac
|
||||
|
||||
case ${target} in
|
||||
|
@ -224,7 +264,7 @@ diff -ruN a/libgcc/config.host b/libgcc/config.host
|
|||
diff -ruN a/libstdc++-v3/configure b/libstdc++-v3/configure
|
||||
--- a/libstdc++-v3/configure 2020-07-23 09:35:19.188404867 +0300
|
||||
+++ b/libstdc++-v3/configure 2020-12-12 10:43:35.288270409 +0200
|
||||
@@ -29846,6 +29846,5986 @@
|
||||
@@ -29217,6 +29217,5986 @@
|
||||
|
||||
# Base decisions on target environment.
|
||||
case "${host}" in
|
||||
|
|
Loading…
Add table
Reference in a new issue