-
-
Notifications
You must be signed in to change notification settings - Fork 18k
WIP: GCC with separated runtime libraries #132343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
199c8b3
MAX WIP: gccNgPackages_11: init
Ericson2314 16d8e38
gccNgPackages_11: make evaluate to a certain extent, flesh out
sternenseemann 7ac987c
gccNgPackages_11.libstdcxx: fix path
sternenseemann b0757eb
gccNgPackages_11.libstdcxx: move patches from old location
sternenseemann c2b3b06
WIP
Ericson2314 dcd2a6b
WIP, Can build gcc but not libgcc
Ericson2314 3381374
WIP improve compiler, get farther with libgcc
Ericson2314 2e052f4
Merge branch 'gcc-ng' of github.com:alexfmpe/nixpkgs into gcc-ng
Ericson2314 bfbfd8e
gccNgPackages_11.libgcc: Fix build
Ericson2314 acee86d
Merge remote-tracking branch 'upstream/master' into gcc-ng
Ericson2314 f9904a8
Merge remote-tracking branch 'upstream/master' into gcc-ng
Ericson2314 08aae70
gccNgPackages.libatomic: Init
Ericson2314 08c8320
Merge remote-tracking branch 'upstream/master' into gcc-ng
Ericson2314 e411c82
gccPackagesNg.libgcc: Fix Musl build
Ericson2314 85dcd96
glibc: Fix evaluation when using gccNg
Ericson2314 7e5d649
libatomic: Fix build
Ericson2314 b949157
gccNgPackages.{libatomic, libstdcxx}: Simplify and improve
Ericson2314 eafee3f
libssp: Init
Ericson2314 6c23699
gccNgPackages.lib{atomic,ssp}: Add Meta
Ericson2314 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
126 changes: 126 additions & 0 deletions
126
pkgs/development/compilers/gcc-ng/11/custom-threading-model.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| diff --git a/config/gthr.m4 b/config/gthr.m4 | ||
| index 4b937306ad0..754e622f159 100644 | ||
| --- a/config/gthr.m4 | ||
| +++ b/config/gthr.m4 | ||
| @@ -5,6 +5,35 @@ dnl Public License, this file may be distributed as part of a program | ||
| dnl that contains a configuration script generated by Autoconf, under | ||
| dnl the same distribution terms as the rest of that program. | ||
|
|
||
| +dnl Define thread model | ||
| + | ||
| +dnl usage: GCC_AC_THREAD_MODEL | ||
| +AC_DEFUN([GCC_AC_THREAD_MODEL], | ||
| +[ | ||
| +# With threads | ||
| +# Pass with no value to take from compiler's metadata | ||
| +# Pass with a value to specify a thread package | ||
| +# 'single' means single threaded -- without threads. | ||
| +AC_ARG_WITH(threads, | ||
| +[AS_HELP_STRING([[--with-threads=MODEL]], | ||
| + [specify thread model for this GCC | ||
| + runtime library])],, | ||
| +[with_threads='']) | ||
| + | ||
| +if test x"$with_threads" = x'yes'; then | ||
| + AC_MSG_ERROR([Cannot pass bare --with-threads, must pass explicit --with-threads=MODEL]) | ||
| +elif test x"$with_threads" = x'no'; then | ||
| + target_thread_file=single | ||
| +elif test x"$with_threads" = x''; then | ||
| + AC_MSG_CHECKING([for thread model used by GCC]) | ||
| + target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'` | ||
| + AC_MSG_RESULT([$target_thread_file]) | ||
| +else | ||
| + target_thread_file=$with_threads | ||
| +fi | ||
| +]) | ||
| + | ||
| + | ||
| dnl Define header location by thread model | ||
|
|
||
| dnl usage: GCC_AC_THREAD_HEADER([thread_model]) | ||
| @@ -22,6 +51,9 @@ case $1 in | ||
| tpf) thread_header=config/s390/gthr-tpf.h ;; | ||
| vxworks) thread_header=config/gthr-vxworks.h ;; | ||
| win32) thread_header=config/i386/gthr-win32.h ;; | ||
| + *) | ||
| + AC_MSG_ERROR([No known header for threading model '$1'.]) | ||
| + ;; | ||
| esac | ||
| AC_SUBST(thread_header) | ||
| ]) | ||
| diff --git a/libatomic/configure.ac b/libatomic/configure.ac | ||
| index 2a371870c2f..42d2016b7a2 100644 | ||
| --- a/libatomic/configure.ac | ||
| +++ b/libatomic/configure.ac | ||
| @@ -161,9 +161,7 @@ libtool_VERSION=3:0:2 | ||
| AC_SUBST(libtool_VERSION) | ||
|
|
||
| # Check for used threading-model | ||
| -AC_MSG_CHECKING([for thread model used by GCC]) | ||
| -target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'` | ||
| -AC_MSG_RESULT([$target_thread_file]) | ||
| +GCC_AC_THREAD_MODEL | ||
|
|
||
| case "$target" in | ||
| *aarch64*) | ||
| diff --git a/libgcc/configure.ac b/libgcc/configure.ac | ||
| index 13a80b2551b..1209a0986e0 100644 | ||
| --- a/libgcc/configure.ac | ||
| +++ b/libgcc/configure.ac | ||
| @@ -298,9 +298,7 @@ AC_SUBST([use_tm_clone_registry]) | ||
|
|
||
| AC_LIB_PROG_LD_GNU | ||
|
|
||
| -AC_MSG_CHECKING([for thread model used by GCC]) | ||
| -target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'` | ||
| -AC_MSG_RESULT([$target_thread_file]) | ||
| +GCC_AC_THREAD_MODEL | ||
|
|
||
| # Check for assembler CFI support. | ||
| AC_CACHE_CHECK([whether assembler supports CFI directives], [libgcc_cv_cfi], | ||
| diff --git a/libphobos/m4/druntime/os.m4 b/libphobos/m4/druntime/os.m4 | ||
| index 351558dbcda..2b44fbca8fc 100644 | ||
| --- a/libphobos/m4/druntime/os.m4 | ||
| +++ b/libphobos/m4/druntime/os.m4 | ||
| @@ -32,7 +32,7 @@ case $1 in | ||
| # TODO: These targets need porting. | ||
| dce|mipssde|rtems|tpf|vxworks) | ||
| DCFG_THREAD_MODEL="Single" ;; | ||
| - *) as_fn_error "Thread implementation '$1' not recognised" "$LINENO" 5 ;; | ||
| + *) AC_MSG_ERROR([Thread implementation '$1' not recognised]) ;; | ||
| esac | ||
| AC_SUBST(DCFG_THREAD_MODEL) | ||
| ]) | ||
| diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 | ||
| index 1c0a4c13052..34a55d4e609 100644 | ||
| --- a/libstdc++-v3/acinclude.m4 | ||
| +++ b/libstdc++-v3/acinclude.m4 | ||
| @@ -3977,9 +3977,7 @@ dnl Substs: | ||
| dnl thread_header | ||
| dnl | ||
| AC_DEFUN([GLIBCXX_ENABLE_THREADS], [ | ||
| - AC_MSG_CHECKING([for thread model used by GCC]) | ||
| - target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'` | ||
| - AC_MSG_RESULT([$target_thread_file]) | ||
| + GCC_AC_THREAD_MODEL | ||
| GCC_AC_THREAD_HEADER([$target_thread_file]) | ||
| ]) | ||
|
|
||
| @@ -3989,7 +3987,8 @@ dnl Check if gthread implementation defines the types and functions | ||
| dnl required by the c++0x thread library. Conforming gthread | ||
| dnl implementations can define __GTHREADS_CXX0X to enable use with c++0x. | ||
| dnl | ||
| -dnl GLIBCXX_ENABLE_SYMVERS must be done before this. | ||
| +dnl GLIBCXX_ENABLE_SYMVERS and GLIBCXX_ENABLE_THREADS must be done | ||
| +dnl before this. | ||
| dnl | ||
| AC_DEFUN([GLIBCXX_CHECK_GTHREADS], [ | ||
| GLIBCXX_ENABLE(libstdcxx-threads,auto,,[enable C++11 threads support]) | ||
| @@ -4004,7 +4003,6 @@ AC_DEFUN([GLIBCXX_CHECK_GTHREADS], [ | ||
| CXXFLAGS="$CXXFLAGS -fno-exceptions \ | ||
| -I${toplevel_srcdir}/libgcc -I${toplevel_builddir}/libgcc" | ||
|
|
||
| - target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'` | ||
| case $target_thread_file in | ||
| posix) | ||
| CXXFLAGS="$CXXFLAGS -DSUPPORTS_WEAK -DGTHREAD_USE_WEAK -D_PTHREADS" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,180 @@ | ||
| { lowPrio, newScope, pkgs, lib, stdenv | ||
| , fetchzip, wrapCCWith, overrideCC | ||
| , preLibcCrossHeaders | ||
| , buildGccTools # tools, but from the previous stage, for cross | ||
| , targetGccLibraries # libraries, but from the next stage, for cross | ||
| # This is the default binutils, but with *this* version of LLD rather | ||
| # than the default LLVM verion's, if LLD is the choice. We use these for | ||
| # the `useLLVM` bootstrapping below. | ||
| , bintoolsNoLibc | ||
| , bintools | ||
| , darwin | ||
| }: | ||
|
|
||
| let | ||
| version = "11.2.0"; | ||
|
|
||
| # fetchzip to unpack makes debug cycle much better | ||
| gcc_src = fetchzip { | ||
| url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz"; | ||
| sha256 = "0aj1l0wkdbd5l2h5qybw0i5nwqbhqx89klnp7m5mwr63gmjfxwmi"; | ||
| }; | ||
|
|
||
| gcc_meta = { | ||
| description = "GNU Compiler Collection"; | ||
| longDescription = '' | ||
| The GNU Compiler Collection includes compiler front ends for C, C++, | ||
| Objective-C, Fortran, OpenMP for C/C++/Fortran, and Ada, as well as | ||
| libraries for these languages (libstdc++, libgomp,...). | ||
|
|
||
| GCC development is a part of the GNU Project, aiming to improve the | ||
| compiler used in the GNU system including the GNU/Linux variant. | ||
| ''; | ||
| homepage = "https://gcc.gnu.org/"; | ||
| maintainers = with lib.maintainers; [ ericson231 sternenseemann ]; | ||
| }; | ||
| gcc_libs_meta = gcc_meta // { | ||
| license = lib.licenses.lgpl3Plus; | ||
| platforms = lib.platforms.all; | ||
| }; | ||
| gcc_tools_meta = gcc_meta // { | ||
| license = lib.licenses.gpl3Plus; | ||
| platforms = lib.platforms.unix; | ||
| }; | ||
|
|
||
| tools = lib.makeExtensible (tools: let | ||
| callPackage = newScope (tools // { inherit version gcc_tools_meta gcc_src buildGccTools; }); | ||
|
|
||
| mkExtraBuildCommands0 = _: ""; | ||
|
|
||
| mkExtraBuildCommands = _: ""; | ||
|
|
||
| in { | ||
|
|
||
| gcc-unwrapped = callPackage ./gcc { }; | ||
|
|
||
| # TODO: support libcxx? is there even an usecase for that? | ||
| gcc = if stdenv.cc.isClang then tools.libcxxGcc else tools.libstdcxxGcc; | ||
|
|
||
| libcxxGcc = wrapCCWith rec { | ||
| cc = tools.gcc-unwrapped; | ||
| extraPackages = [ | ||
| targetGccLibraries.libgcc | ||
| ]; | ||
| extraBuildCommands = mkExtraBuildCommands cc; | ||
| }; | ||
|
|
||
| libstdcxxGcc = wrapCCWith rec { | ||
| cc = tools.gcc-unwrapped; | ||
| libcxx = targetGccLibraries.libstdcxx; | ||
| extraPackages = [ | ||
| targetGccLibraries.libgcc | ||
| ]; | ||
| extraBuildCommands = mkExtraBuildCommands cc; | ||
| }; | ||
|
|
||
| # Below, is the GCC Next Gen bootstrapping logic. It handles building a | ||
| # fully GCC toolchain from scratch via Nix. No LLVM toolchain should be | ||
| # pulled in. We should deduplicate this bootstrapping with its LLVM | ||
| # equivalence one GCC "old gen" is gone. | ||
|
|
||
| gccUseGccNg = wrapCCWith rec { | ||
| cc = tools.gcc-unwrapped; | ||
| libcxx = targetGccLibraries.libstdcxx; | ||
| extraPackages = [ | ||
| targetGccLibraries.libgcc | ||
| ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [ | ||
| targetGccLibraries.libunwind | ||
| ]; | ||
| extraBuildCommands = '' | ||
| echo "-B${targetGccLibraries.libgcc}/lib" >> $out/nix-support/cc-cflags | ||
| '' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' | ||
| echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags | ||
| '' + lib.optionalString (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false) '' | ||
| echo "-lunwind" >> $out/nix-support/cc-ldflags | ||
| '' + lib.optionalString stdenv.targetPlatform.isWasm '' | ||
| echo "-fno-exceptions" >> $out/nix-support/cc-cflags | ||
| '' + mkExtraBuildCommands cc; | ||
| }; | ||
|
|
||
| gccNoLibstdcxx = wrapCCWith rec { | ||
| cc = tools.gcc-unwrapped; | ||
| libcxx = null; | ||
| extraPackages = [ | ||
| targetGccLibraries.libgcc | ||
| ]; | ||
| extraBuildCommands = '' | ||
| echo "-B${targetGccLibraries.libgcc}/lib" >> $out/nix-support/cc-cflags | ||
| echo "-B${targetGccLibraries.libatomic}/lib" >> $out/nix-support/cc-cflags | ||
| '' + mkExtraBuildCommands cc; | ||
| }; | ||
|
|
||
| gccNoLibatomic = wrapCCWith rec { | ||
| cc = tools.gcc-unwrapped; | ||
| libcxx = null; | ||
| extraPackages = [ | ||
| targetGccLibraries.libgcc | ||
| ]; | ||
| extraBuildCommands = '' | ||
| echo "-B${targetGccLibraries.libgcc}/lib" >> $out/nix-support/cc-cflags | ||
| '' + mkExtraBuildCommands cc; | ||
| }; | ||
|
|
||
| gccNoLibc = wrapCCWith rec { | ||
| cc = tools.gcc-unwrapped; | ||
| libcxx = null; | ||
| bintools = bintoolsNoLibc; | ||
| extraPackages = [ | ||
| targetGccLibraries.libgcc | ||
| ]; | ||
| extraBuildCommands = '' | ||
| echo "-B${targetGccLibraries.libgcc}/lib" >> $out/nix-support/cc-cflags | ||
| '' + mkExtraBuildCommands cc; | ||
| }; | ||
|
|
||
| gccNoLibgcc = wrapCCWith rec { | ||
| cc = tools.gcc-unwrapped; | ||
| libcxx = null; | ||
| bintools = bintoolsNoLibc; | ||
| extraPackages = [ ]; | ||
| extraBuildCommands = '' | ||
| echo "-nostartfiles" >> $out/nix-support/cc-cflags | ||
| '' + mkExtraBuildCommands0 cc; | ||
| }; | ||
|
|
||
| }); | ||
|
|
||
| libraries = lib.makeExtensible (libraries: let | ||
| callPackage = newScope (libraries // buildGccTools // { inherit version gcc_libs_meta gcc_src; }); | ||
| in { | ||
|
|
||
| libgcc = callPackage ./libgcc { | ||
| stdenv = overrideCC stdenv buildGccTools.gccNoLibgcc; | ||
| }; | ||
|
|
||
| stdenv = overrideCC stdenv buildGccTools.gcc; | ||
|
|
||
| libstdcxxStdenv = overrideCC stdenv buildGccTools.libstdcxxGcc; | ||
|
|
||
| libada = callPackage ./libada { }; | ||
|
|
||
| libatomic = callPackage ./libatomic { | ||
| # TODO should libatomic be built before or after libc? | ||
| stdenv = overrideCC stdenv buildGccTools.gccNoLibatomic; | ||
| }; | ||
|
|
||
| libssp = callPackage ./libssp { | ||
| # TODO should libssp be built before or after libc? | ||
| stdenv = overrideCC stdenv buildGccTools.gccNoLibatomic; | ||
| }; | ||
|
|
||
| libgfortran = callPackage ./libgfortran { }; | ||
|
|
||
| libstdcxx = callPackage ./libstdcxx { | ||
| stdenv = overrideCC stdenv buildGccTools.gccNoLibstdcxx; | ||
| }; | ||
|
|
||
| # TODO add (gnu) libunwind here? can already be built separately aiui | ||
| }); | ||
|
|
||
| in { inherit tools libraries; } // libraries // tools | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.