Skip to content
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

WIP: GCC with separated runtime libraries #132343

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 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
7 changes: 4 additions & 3 deletions pkgs/development/compilers/gcc-ng/11/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ let
targetGccLibraries.libunwind
];
extraBuildCommands = ''
echo "-rtlib=libgcc -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
echo "-B${targetGccLibraries.libgcc}/lib" >> $out/nix-support/cc-cflags
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
Expand All @@ -105,7 +104,6 @@ let
targetGccLibraries.libgcc
];
extraBuildCommands = ''
echo "-rtlib=libgcc" >> $out/nix-support/cc-cflags
echo "-B${targetGccLibraries.libgcc}/lib" >> $out/nix-support/cc-cflags
echo "-nostdlib++" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
Expand All @@ -119,7 +117,6 @@ let
targetGccLibraries.libgcc
];
extraBuildCommands = ''
echo "-rtlib=libgcc" >> $out/nix-support/cc-cflags
echo "-B${targetGccLibraries.libgcc}/lib" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
};
Expand Down Expand Up @@ -150,6 +147,10 @@ let

libada = callPackage ./libada { };

libatomic = callPackage ./libatomic {
stdenv = overrideCC stdenv buildGccTools.gccNoLibstdcxx;
};

libgfortran = callPackage ./libgfortran { };

libstdcxx = callPackage ./libstdcxx {
Expand Down
54 changes: 54 additions & 0 deletions pkgs/development/compilers/gcc-ng/11/libatomic/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{ lib, stdenv, buildPackages
, gcc_src, version
, glibc
, autoreconfHook269, libiberty
}:

stdenv.mkDerivation rec {
pname = "libatomic";
inherit version;

src = gcc_src;

patches = [
../custom-threading-model.patch
];

outputs = [ "out" "dev" ];

strictDeps = true;

depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ autoreconfHook269 libiberty ];

enableParallelBuilding = true;

#postUnpack = ''
# mkdir -p ./build
# buildRoot=$(readlink -e "./build")
#'';

postPatch = ''
sourceRoot=$(readlink -e "./libatomic")
'';

configurePlatforms = [ "build" "host" ];
configureFlags = [
"--disable-dependency-tracking"
"--with-threads=single"
# $CC cannot link binaries, let alone run then
"cross_compiling=true"
# Do not have dynamic linker without libc
"--enable-static"
"--disable-shared"
];

makeFlags = [ "MULTIBUILDTOP:=../" ];

postInstall = ''
moveToOutput "lib/gcc/${stdenv.hostPlatform.config}/${version}/include" "$dev"
mkdir -p "$out/lib" "$dev/include"
ln -s "$out/lib/gcc/${stdenv.hostPlatform.config}/${version}"/* "$out/lib"
ln -s "$dev/lib/gcc/${stdenv.hostPlatform.config}/${version}/include"/* "$dev/include/"
'';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meta is missing.

}
2 changes: 1 addition & 1 deletion pkgs/development/compilers/gcc-ng/11/libgcc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
src = gcc_src;

patches = [
./libgcc-custom-threading-model.patch
../custom-threading-model.patch
];

outputs = [ "out" "dev" ];
Expand Down
7 changes: 6 additions & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11053,7 +11053,9 @@ with pkgs;

crossLibcStdenv =
if stdenv.hostPlatform.useLLVM or false || stdenv.hostPlatform.isDarwin
then overrideCC stdenv buildPackages.llvmPackages.clangNoLibc
then overrideCC stdenv buildPackages.llvmPackages.clangNoLibc
else if stdenv.hostPlatform.useGccNg or false
then overrideCC stdenv buildPackages.gccNgPackages.gccNoLibc
else gccCrossLibcStdenv;

# The GCC used to build libc for the target platform. Normal gccs will be
Expand Down Expand Up @@ -11366,6 +11368,9 @@ with pkgs;

gccNgPackages_11 = recurseIntoAttrs (callPackage ../development/compilers/gcc-ng/11 ({
inherit (stdenvAdapters) overrideCC;
# These are the default arguments, but do this to avoid splicing which was
# causing infinite recursion.
inherit bintools bintoolsNoLibc;
buildGccTools = buildPackages.gccNgPackages_11.tools;
targetGccLibraries = targetPackages.gccNgPackages_11.libraries;
}));
Expand Down