mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-09-29 03:10:19 +00:00
minimal-bootstrap.gcc-latest-unwrapped: split into gcc-ng packages
minimal-bootstrap.libgcc: init at 16.1.0 minimal-bootstrap.libstdcxx: init at 16.1.0 minimal-bootstrap.glibc: Fix libgcc link paths. Remove hello-world test; glibc here is better tested by the gcc-glibc wrapper test introduced in the next commit. Keeping the test within glibc require manually setting linker flags that place libgcc and glibc into the linker search paths.
This commit is contained in:
@@ -166,18 +166,23 @@ lib.makeScope
|
||||
staticLibgcc = true;
|
||||
};
|
||||
|
||||
gcc-latest-unwrapped = callPackage ./gcc/latest.nix {
|
||||
gcc-latest-unwrapped = callPackage ./gcc/ng.nix {
|
||||
binutils-buildbuild = binutils;
|
||||
binutils-buildtarget = binutils;
|
||||
binutils-hosttarget = binutils;
|
||||
gcc = gcc10;
|
||||
gcc-buildbuild = gcc10;
|
||||
gnumake = gnumake-musl;
|
||||
gnutar = gnutar-latest;
|
||||
libc-headers = musl;
|
||||
libc = musl;
|
||||
targetPlatform = hostPlatform;
|
||||
};
|
||||
gcc-latest = callPackage ./gcc/wrapper.nix {
|
||||
bash-build = bash;
|
||||
gcc-unwrapped = gcc-latest-unwrapped;
|
||||
targetPlatform = hostPlatform;
|
||||
libc = musl;
|
||||
libgcc = gcc-latest-unwrapped;
|
||||
libstdcxx = gcc-latest-unwrapped;
|
||||
dynamicLinkerGlob = "${musl}/lib/libc.so";
|
||||
staticLibgcc = true;
|
||||
};
|
||||
@@ -317,6 +322,26 @@ lib.makeScope
|
||||
gnutar = gnutar-latest;
|
||||
};
|
||||
|
||||
libgcc = callPackage ./gcc/libgcc.nix {
|
||||
binutils-buildbuild = binutils;
|
||||
gcc-buildbuild = gcc10;
|
||||
gcc = gcc-latest-unwrapped;
|
||||
gnumake = gnumake-musl;
|
||||
gnutar = gnutar-latest;
|
||||
enableShared = false;
|
||||
libc = musl;
|
||||
libc-headers = musl;
|
||||
};
|
||||
|
||||
libstdcxx = callPackage ./gcc/libstdcxx.nix {
|
||||
gcc = gcc-latest-unwrapped;
|
||||
gnumake = gnumake-musl;
|
||||
gnutar = gnutar-latest;
|
||||
libc = musl;
|
||||
dynamicLinkerGlob = "${musl}/lib/libc.so";
|
||||
staticLibgcc = true;
|
||||
};
|
||||
|
||||
linux-headers = callPackage ./linux-headers {
|
||||
gcc = gcc-latest;
|
||||
gnumake = gnumake-musl;
|
||||
@@ -490,7 +515,6 @@ lib.makeScope
|
||||
''
|
||||
+ (lib.strings.optionalString (hostPlatform.libc == "glibc") ''
|
||||
echo ${gcc-glibc.tests.hello-world}
|
||||
echo ${glibc.tests.hello-world}
|
||||
'')
|
||||
+ ''
|
||||
mkdir ''${out}
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
buildPlatform,
|
||||
hostPlatform,
|
||||
fetchurl,
|
||||
bash,
|
||||
coreutils,
|
||||
gcc,
|
||||
musl,
|
||||
binutils,
|
||||
gnumake,
|
||||
gnused,
|
||||
gnugrep,
|
||||
gawk,
|
||||
diffutils,
|
||||
findutils,
|
||||
gnutar,
|
||||
gzip,
|
||||
bzip2,
|
||||
xz,
|
||||
}:
|
||||
let
|
||||
pname = "gcc";
|
||||
version = "16.2.0";
|
||||
|
||||
src = fetchurl {
|
||||
url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.xz";
|
||||
hash = "sha256-5nOOKVl/czJwcxqpBgDzf/3ARQed/CfsfoGSzIEIXD4=";
|
||||
};
|
||||
|
||||
gmpVersion = "6.3.0";
|
||||
gmp = fetchurl {
|
||||
url = "mirror://gnu/gmp/gmp-${gmpVersion}.tar.xz";
|
||||
hash = "sha256-o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
|
||||
};
|
||||
|
||||
mpfrVersion = "4.2.2";
|
||||
mpfr = fetchurl {
|
||||
url = "mirror://gnu/mpfr/mpfr-${mpfrVersion}.tar.xz";
|
||||
hash = "sha256-tnugOD736KhWNzTi6InvXsPDuJigHQD6CmhprYHGzgE=";
|
||||
};
|
||||
|
||||
mpcVersion = "1.4.1";
|
||||
mpc = fetchurl {
|
||||
url = "mirror://gnu/mpc/mpc-${mpcVersion}.tar.xz";
|
||||
hash = "sha256-kSBM0y8WS9O3yZLUpqjOZRlRGq2rMPeLaYLQv41z6TE=";
|
||||
};
|
||||
in
|
||||
bash.runCommand "${pname}-${version}"
|
||||
{
|
||||
inherit pname version;
|
||||
|
||||
nativeBuildInputs = [
|
||||
gcc
|
||||
binutils
|
||||
gnumake
|
||||
gnused
|
||||
gnugrep
|
||||
gawk
|
||||
diffutils
|
||||
findutils
|
||||
gnutar
|
||||
gzip
|
||||
bzip2
|
||||
xz
|
||||
];
|
||||
|
||||
passthru.tests.hello-world =
|
||||
result:
|
||||
bash.runCommand "${pname}-simple-program-${version}"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
binutils
|
||||
musl
|
||||
result
|
||||
];
|
||||
}
|
||||
''
|
||||
cat <<EOF >> test.c
|
||||
#include <stdio.h>
|
||||
int main() {
|
||||
printf("Hello World!\n");
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
musl-gcc -o test test.c
|
||||
./test
|
||||
mkdir $out
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "GNU Compiler Collection, version ${version}";
|
||||
homepage = "https://gcc.gnu.org";
|
||||
license = lib.licenses.gpl3Plus;
|
||||
teams = [ lib.teams.minimal-bootstrap ];
|
||||
platforms = lib.platforms.unix;
|
||||
mainProgram = "gcc";
|
||||
};
|
||||
}
|
||||
''
|
||||
# Unpack
|
||||
tar xf ${src}
|
||||
tar xf ${gmp}
|
||||
tar xf ${mpfr}
|
||||
tar xf ${mpc}
|
||||
cd gcc-${version}
|
||||
|
||||
ln -s ../gmp-${gmpVersion} gmp
|
||||
ln -s ../mpfr-${mpfrVersion} mpfr
|
||||
ln -s ../mpc-${mpcVersion} mpc
|
||||
|
||||
# Patch
|
||||
# force musl even if host triple is gnu
|
||||
sed -i 's|"os/gnu-linux"|"os/generic"|' libstdc++-v3/configure.host
|
||||
|
||||
# Configure
|
||||
export CC="gcc -Wl,-dynamic-linker -Wl,${musl}/lib/libc.so"
|
||||
export CXX="g++ -Wl,-dynamic-linker -Wl,${musl}/lib/libc.so"
|
||||
export CFLAGS="-O1"
|
||||
export CXXFLAGS="-O1"
|
||||
export CFLAGS_FOR_TARGET="-O0 -Wl,-dynamic-linker -Wl,${musl}/lib/libc.so"
|
||||
export CXXFLAGS_FOR_TARGET="$CFLAGS_FOR_TARGET"
|
||||
export LIBRARY_PATH="${musl}/lib"
|
||||
|
||||
bash ./configure \
|
||||
--prefix=$out \
|
||||
--build=${buildPlatform.config} \
|
||||
--host=${hostPlatform.config} \
|
||||
--with-native-system-header-dir=${musl}/include \
|
||||
--with-sysroot=/ \
|
||||
--enable-languages=c,c++ \
|
||||
--enable-checking=release \
|
||||
--enable-static \
|
||||
--disable-shared \
|
||||
--disable-bootstrap \
|
||||
--disable-dependency-tracking \
|
||||
--disable-libsanitizer \
|
||||
--disable-libssp \
|
||||
--disable-libgomp \
|
||||
--disable-libquadmath \
|
||||
--disable-libitm \
|
||||
--disable-libvtv \
|
||||
--disable-libatomic \
|
||||
--disable-libstdcxx-pch \
|
||||
--disable-lto \
|
||||
--disable-multilib \
|
||||
--disable-nls \
|
||||
--disable-plugin \
|
||||
--without-isl
|
||||
|
||||
# Build
|
||||
make -j $NIX_BUILD_CORES
|
||||
|
||||
# Install
|
||||
make -j $NIX_BUILD_CORES install-strip
|
||||
|
||||
# Header installation tools retain build-time bash and sed unnecessarily.
|
||||
rm -rf $out/libexec/gcc/*/*/install-tools $out/lib/gcc/*/*/install-tools
|
||||
|
||||
# libstdc++ gdb pretty-printers + man pages are unused downstream.
|
||||
rm -rf $out/share/gcc-*/python $out/share/man $out/share/info
|
||||
|
||||
if [ -d "$out/lib64" ]; then
|
||||
shopt -s dotglob
|
||||
for lib in $out/lib64/*; do
|
||||
mv --no-clobber "$lib" "$out/lib/"
|
||||
done
|
||||
shopt -u dotglob
|
||||
rm -rf "$out/lib64"
|
||||
ln -s lib "$out/lib64"
|
||||
fi
|
||||
''
|
||||
192
pkgs/os-specific/linux/minimal-bootstrap/gcc/libgcc.nix
Normal file
192
pkgs/os-specific/linux/minimal-bootstrap/gcc/libgcc.nix
Normal file
@@ -0,0 +1,192 @@
|
||||
{
|
||||
enableShared,
|
||||
libc-headers,
|
||||
libc ? null,
|
||||
lib,
|
||||
buildPlatform,
|
||||
hostPlatform,
|
||||
fetchurl,
|
||||
bash,
|
||||
gcc-buildbuild,
|
||||
gcc,
|
||||
libgmp,
|
||||
libmpfr,
|
||||
libmpc,
|
||||
binutils-buildbuild,
|
||||
gnumake,
|
||||
gnupatch,
|
||||
gnused,
|
||||
gnugrep,
|
||||
gawk,
|
||||
diffutils,
|
||||
findutils,
|
||||
gnutar,
|
||||
gzip,
|
||||
bzip2,
|
||||
xz,
|
||||
libiberty,
|
||||
binutils,
|
||||
}:
|
||||
let
|
||||
common = import ./common.nix {
|
||||
inherit
|
||||
lib
|
||||
bash
|
||||
fetchurl
|
||||
gnupatch
|
||||
gnutar
|
||||
xz
|
||||
;
|
||||
};
|
||||
pname = "libgcc";
|
||||
|
||||
binutilsTargetPrefix = lib.optionalString (
|
||||
buildPlatform.config != hostPlatform.config
|
||||
) "${hostPlatform.config}-";
|
||||
in
|
||||
bash.runCommand "${pname}-${common.version}"
|
||||
{
|
||||
inherit pname;
|
||||
inherit (common) version meta;
|
||||
|
||||
nativeBuildInputs = [
|
||||
gcc-buildbuild
|
||||
binutils
|
||||
binutils-buildbuild
|
||||
gnumake
|
||||
gnused
|
||||
gnugrep
|
||||
gawk
|
||||
diffutils
|
||||
findutils
|
||||
gnutar
|
||||
gzip
|
||||
bzip2
|
||||
xz
|
||||
];
|
||||
}
|
||||
''
|
||||
# Configure
|
||||
mkdir -p build-${buildPlatform.config}/libiberty/
|
||||
ln -s ${libiberty}/lib/libiberty.a build-${buildPlatform.config}/libiberty/
|
||||
|
||||
mkdir -p gcc/
|
||||
cd gcc/
|
||||
|
||||
(
|
||||
export AS_FOR_BUILD=${lib.getExe' binutils-buildbuild "as"}
|
||||
export CC_FOR_BUILD="${lib.getExe' gcc-buildbuild "gcc"} -I${libgmp}/include -I${libmpfr}/include -I${libmpc}/include"
|
||||
export CPP_FOR_BUILD="${lib.getExe' gcc-buildbuild "cpp"} -I${libgmp}/include -I${libmpfr}/include -I${libmpc}/include"
|
||||
export CXX_FOR_BUILD="${lib.getExe' gcc-buildbuild "g++"} -I${libgmp}/include -I${libmpfr}/include -I${libmpc}/include"
|
||||
export LD_FOR_BUILD="${lib.getExe' binutils-buildbuild "ld"}"
|
||||
export OBJDUMP_FOR_BUILD=${lib.getExe' binutils-buildbuild "objdump"}
|
||||
|
||||
export AS=$AS_FOR_BUILD
|
||||
export CC=$CC_FOR_BUILD
|
||||
export CPP=$CPP_FOR_BUILD
|
||||
export CXX=$CXX_FOR_BUILD
|
||||
export LD=$LD_FOR_BUILD
|
||||
export OBJDUMP=$OBJDUMP_FOR_BUILD
|
||||
|
||||
export AS_FOR_TARGET=${lib.getExe' binutils "${binutilsTargetPrefix}as"}
|
||||
export CC_FOR_TARGET="${lib.getExe' gcc "${hostPlatform.config}-gcc"}"
|
||||
export CPP_FOR_TARGET=${lib.getExe' gcc "${binutilsTargetPrefix}cpp"}
|
||||
export LD_FOR_TARGET=${lib.getExe' binutils "${binutilsTargetPrefix}ld"}
|
||||
export OBJDUMP_FOR_TARGET=${lib.getExe' binutils "${binutilsTargetPrefix}objdump"}
|
||||
|
||||
export CFLAGS_FOR_BUILD="-DGENERATOR_FILE=1"
|
||||
${common.monorepoSrc}/gcc/configure \
|
||||
--build=${buildPlatform.config} \
|
||||
--host=${buildPlatform.config} \
|
||||
--target=${hostPlatform.config} \
|
||||
--disable-bootstrap \
|
||||
--disable-multilib \
|
||||
--enable-languages=c \
|
||||
--disable-fixincludes \
|
||||
--disable-gcov \
|
||||
--disable-intl \
|
||||
--disable-lto \
|
||||
--disable-libatomic \
|
||||
--disable-libbacktrace \
|
||||
--disable-libcpp \
|
||||
--disable-libssp \
|
||||
--disable-libquadmath \
|
||||
--disable-libgomp \
|
||||
--disable-libvtv \
|
||||
--disable-vtable-verify \
|
||||
--with-sysroot=/ \
|
||||
--with-native-system-headers=${libc-headers}/include
|
||||
|
||||
sed -i 's,libgcc.mvars:.*$,libgcc.mvars:,' -i Makefile
|
||||
|
||||
make \
|
||||
config.h \
|
||||
libgcc.mvars \
|
||||
tconfig.h \
|
||||
tm.h \
|
||||
options.h \
|
||||
insn-constants.h \
|
||||
version.h
|
||||
)
|
||||
mkdir -p include
|
||||
|
||||
mkdir -p ${hostPlatform.config}/libgcc
|
||||
cd ${hostPlatform.config}/libgcc
|
||||
|
||||
export AS_FOR_BUILD=${lib.getExe' binutils-buildbuild "as"}
|
||||
export CC_FOR_BUILD=${lib.getExe' gcc-buildbuild "gcc"}
|
||||
export CPP_FOR_BUILD=${lib.getExe' gcc-buildbuild "cpp"}
|
||||
export CXX_FOR_BUILD=${lib.getExe' gcc-buildbuild "g++"}
|
||||
export LD_FOR_BUILD=${lib.getExe' binutils-buildbuild "ld"}
|
||||
|
||||
export AS=${lib.getExe' binutils "${binutilsTargetPrefix}as"}
|
||||
export CC="${lib.getExe' gcc "${hostPlatform.config}-gcc"}"
|
||||
export CPP=${lib.getExe' gcc "${binutilsTargetPrefix}cpp"}
|
||||
export LD=${lib.getExe' binutils "${binutilsTargetPrefix}ld"}
|
||||
export AS_FOR_TARGET=${lib.getExe' binutils "${binutilsTargetPrefix}as"}
|
||||
export CC_FOR_TARGET="${lib.getExe' gcc "${hostPlatform.config}-gcc"}"
|
||||
export CPP_FOR_TARGET=${lib.getExe' gcc "${binutilsTargetPrefix}-cpp"}
|
||||
export LD_FOR_TARGET=${lib.getExe' binutils "${binutilsTargetPrefix}ld"}
|
||||
|
||||
export CFLAGS="-O0 ${lib.optionalString hostPlatform.isMusl "-isystem ${gcc}/lib/gcc/${hostPlatform.config}/${common.version}/include-fixed"}"
|
||||
|
||||
${common.monorepoSrc}/libgcc/configure --disable-dependency-tracking \
|
||||
--prefix="$out" \
|
||||
--build=${buildPlatform.config} \
|
||||
--host=${hostPlatform.config} \
|
||||
gcc_cv_target_thread_file=single \
|
||||
${
|
||||
if enableShared then "--enable-shared --disable-static" else "--disable-shared --enable-static"
|
||||
} \
|
||||
cross_compiling=true
|
||||
|
||||
export CFLAGS="-O0"
|
||||
export LDFLAGS="${lib.optionalString (libc != null) "-B${libc}/lib"}"
|
||||
make -j $NIX_BUILD_CORES MULTIBUILDTOP:=../
|
||||
|
||||
make -j $NIX_BUILD_CORES install-strip MULTIBUILDTOP:=../
|
||||
mkdir -p "$out/include"
|
||||
install -c -m 644 gthr-default.h "$out/include/"
|
||||
|
||||
if [ -d "$out/lib64" ]; then
|
||||
shopt -s dotglob
|
||||
for lib in $out/lib64/*; do
|
||||
mv --no-clobber "$lib" "$out/lib/gcc/${hostPlatform.config}/${common.version}/"
|
||||
done
|
||||
shopt -u dotglob
|
||||
rm -rf "$out/lib64"
|
||||
ln -s lib "$out/lib64"
|
||||
fi
|
||||
# On 32-bit platforms, libs might be placed into $out/lib rather than lib64.
|
||||
# Move to unified directory, so that gcc-wrapper finds them
|
||||
shopt -s nullglob
|
||||
for lib in $out/lib/*.*; do
|
||||
mv --no-clobber "$lib" "$out/lib/gcc/${hostPlatform.config}/${common.version}/"
|
||||
done
|
||||
shopt -u nullglob
|
||||
|
||||
if ! [ -e "$out/lib/gcc/${hostPlatform.config}/${common.version}/libgcc_eh.a" ]; then
|
||||
ln -s "$out/lib/gcc/${hostPlatform.config}/${common.version}/libgcc.a" "$out/lib/gcc/${hostPlatform.config}/${common.version}/libgcc_eh.a"
|
||||
fi
|
||||
find "$out/lib/gcc/${hostPlatform.config}/${common.version}/" -type f -exec ${binutilsTargetPrefix}strip --strip-debug {} + || true
|
||||
''
|
||||
152
pkgs/os-specific/linux/minimal-bootstrap/gcc/libstdcxx.nix
Normal file
152
pkgs/os-specific/linux/minimal-bootstrap/gcc/libstdcxx.nix
Normal file
@@ -0,0 +1,152 @@
|
||||
{
|
||||
lib,
|
||||
buildPlatform,
|
||||
hostPlatform,
|
||||
fetchurl,
|
||||
bash,
|
||||
coreutils,
|
||||
gcc,
|
||||
libgcc,
|
||||
binutils,
|
||||
gnumake,
|
||||
gnupatch,
|
||||
gnused,
|
||||
gnugrep,
|
||||
gawk,
|
||||
diffutils,
|
||||
findutils,
|
||||
gnutar,
|
||||
gzip,
|
||||
bzip2,
|
||||
xz,
|
||||
libc,
|
||||
dynamicLinkerGlob,
|
||||
staticLibgcc,
|
||||
}:
|
||||
let
|
||||
common = import ./common.nix {
|
||||
inherit
|
||||
lib
|
||||
bash
|
||||
fetchurl
|
||||
gnupatch
|
||||
gnutar
|
||||
xz
|
||||
;
|
||||
};
|
||||
pname = "libstdcxx";
|
||||
|
||||
binutilsTargetPrefix = lib.optionalString (
|
||||
buildPlatform.config != hostPlatform.config
|
||||
) "${hostPlatform.config}-";
|
||||
|
||||
# FIXME: hack until we have a proper cross-compilation setup in minimal-bootstrap
|
||||
fakeBuildPlatform = lib.replaceString "-gnu" "-musl" buildPlatform.config;
|
||||
fakeHostPlatform = lib.replaceString "-gnu" "-musl" hostPlatform.config;
|
||||
in
|
||||
bash.runCommand "${pname}-${common.version}"
|
||||
{
|
||||
inherit pname;
|
||||
inherit (common) version meta;
|
||||
|
||||
nativeBuildInputs = [
|
||||
gcc
|
||||
binutils
|
||||
gnumake
|
||||
gnused
|
||||
gnugrep
|
||||
gawk
|
||||
diffutils
|
||||
findutils
|
||||
gnutar
|
||||
gzip
|
||||
bzip2
|
||||
xz
|
||||
];
|
||||
}
|
||||
''
|
||||
# Unpack
|
||||
pushd ${common.monorepoSrc}
|
||||
|
||||
mkdir -p "$out/gcc" "$out/libgcc"
|
||||
cp gcc/BASE-VER gcc/DATESTAMP "$out/gcc"
|
||||
cp libgcc/gthr*.h "$out/libgcc"
|
||||
cp libgcc/unwind-pe.h "$out/libgcc"
|
||||
|
||||
cp -r libstdc++-v3 "$out"
|
||||
|
||||
cp -r libiberty "$out"
|
||||
cp -r include "$out"
|
||||
cp -r contrib "$out"
|
||||
|
||||
cp -r config "$out"
|
||||
cp -r multilib.am "$out"
|
||||
|
||||
cp config.guess "$out"
|
||||
cp config.rpath "$out"
|
||||
cp config.sub "$out"
|
||||
cp config-ml.in "$out"
|
||||
cp ltmain.sh "$out"
|
||||
cp install-sh "$out"
|
||||
cp mkinstalldirs "$out"
|
||||
|
||||
[[ -f MD5SUMS ]]; cp MD5SUMS "$out"
|
||||
popd
|
||||
|
||||
# Configure
|
||||
if [[ -z '${dynamicLinkerGlob}' ]]; then
|
||||
echo "Don't know the name of the dynamic linker for platform '${hostPlatform.config}', so guessing instead."
|
||||
dynamicLinker="${libc}/lib/ld*.so.?"
|
||||
else
|
||||
dynamicLinker='${dynamicLinkerGlob}'
|
||||
fi
|
||||
dynamicLinker=($dynamicLinker)
|
||||
case ''${#dynamicLinker[@]} in
|
||||
0) echo "No dynamic linker found for platform '${hostPlatform.config}'.";;
|
||||
1) echo "Using dynamic linker: '$dynamicLinker'";;
|
||||
*) echo "Multiple dynamic linkers found for platform '${hostPlatform.config}'.";;
|
||||
esac
|
||||
|
||||
mkdir build; cd build
|
||||
export CFLAGS="-O0 -B${binutils}/bin -B${libc}/lib -B${libgcc}/lib/gcc/${hostPlatform.config}/${libgcc.version} -Wl,-dynamic-linker=$dynamicLinker"
|
||||
export CXXFLAGS="-O0 -B${binutils}/bin -B${libc}/lib -B${libgcc}/lib/gcc/${hostPlatform.config}/${libgcc.version}${lib.optionalString staticLibgcc " -static-libgcc"} -Wl,-dynamic-linker=$dynamicLinker"
|
||||
export LDFLAGS="-B${binutils}/bin -B${libc}/lib -B${libgcc}/lib/gcc/${hostPlatform.config}/${libgcc.version}${lib.optionalString staticLibgcc " -static-libgcc"} -Wl,-dynamic-linker=$dynamicLinker"
|
||||
export AR="${binutilsTargetPrefix}ar"
|
||||
export LD="${binutilsTargetPrefix}ld"
|
||||
export NM="${binutilsTargetPrefix}nm"
|
||||
export OBJCOPY="${binutilsTargetPrefix}objcopy"
|
||||
${common.monorepoSrc}/libstdc++-v3/configure \
|
||||
--build=${fakeBuildPlatform} \
|
||||
--host=${fakeHostPlatform} \
|
||||
--prefix="$out" \
|
||||
--disable-dependency-tracking \
|
||||
gcc_cv_target_thread_file=posix \
|
||||
cross_compiling=true \
|
||||
--disable-multilib \
|
||||
--enable-clocale=gnu \
|
||||
--disable-libstdcxx-pch \
|
||||
--disable-vtable-verify \
|
||||
--enable-libstdcxx-visibility \
|
||||
--with-default-libstdcxx-abi=new \
|
||||
${lib.optionalString staticLibgcc "--disable-shared"}
|
||||
|
||||
# Build
|
||||
make -j $NIX_BUILD_CORES
|
||||
chmod -R +w "$out"
|
||||
|
||||
# Install
|
||||
make -j $NIX_BUILD_CORES install-strip
|
||||
|
||||
if [ -d "$out/lib64" ]; then
|
||||
shopt -s dotglob
|
||||
for lib in $out/lib64/*; do
|
||||
mv --no-clobber "$lib" "$out/lib/"
|
||||
done
|
||||
shopt -u dotglob
|
||||
rm -rf "$out/lib64"
|
||||
ln -s lib "$out/lib64"
|
||||
fi
|
||||
|
||||
# FIXME: hack until we have a proper cross-compilation setup in minimal-bootstrap
|
||||
ln -s "$out/include/c++/${common.version}/${fakeHostPlatform}" "$out/include/c++/${common.version}/${hostPlatform.config}"
|
||||
''
|
||||
166
pkgs/os-specific/linux/minimal-bootstrap/gcc/ng.nix
Normal file
166
pkgs/os-specific/linux/minimal-bootstrap/gcc/ng.nix
Normal file
@@ -0,0 +1,166 @@
|
||||
{
|
||||
lib,
|
||||
libc,
|
||||
buildPlatform,
|
||||
hostPlatform,
|
||||
targetPlatform,
|
||||
fetchurl,
|
||||
bash,
|
||||
gcc,
|
||||
gcc-buildbuild,
|
||||
libc-headers,
|
||||
binutils-buildbuild,
|
||||
binutils-buildtarget,
|
||||
binutils-hosttarget,
|
||||
gnumake,
|
||||
gnupatch,
|
||||
gnused,
|
||||
gnugrep,
|
||||
gawk,
|
||||
diffutils,
|
||||
findutils,
|
||||
gnutar,
|
||||
gzip,
|
||||
bzip2,
|
||||
libgmp,
|
||||
libmpfr,
|
||||
libmpc,
|
||||
libbacktrace,
|
||||
libiberty,
|
||||
xz,
|
||||
}:
|
||||
let
|
||||
pname = "gcc";
|
||||
common = import ./common.nix {
|
||||
inherit
|
||||
lib
|
||||
bash
|
||||
fetchurl
|
||||
gnutar
|
||||
gnupatch
|
||||
xz
|
||||
;
|
||||
};
|
||||
|
||||
binutilsTargetPrefix = lib.optionalString (
|
||||
targetPlatform.config != hostPlatform.config
|
||||
) "${targetPlatform.config}-";
|
||||
in
|
||||
bash.runCommand "${pname}-${common.version}"
|
||||
{
|
||||
inherit (common) version meta;
|
||||
inherit pname;
|
||||
|
||||
nativeBuildInputs = [
|
||||
gcc
|
||||
gcc-buildbuild
|
||||
binutils-buildbuild
|
||||
binutils-buildtarget
|
||||
gnumake
|
||||
gnused
|
||||
gnugrep
|
||||
gawk
|
||||
diffutils
|
||||
findutils
|
||||
gnutar
|
||||
gzip
|
||||
bzip2
|
||||
xz
|
||||
];
|
||||
}
|
||||
(
|
||||
''
|
||||
# Configure
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
mkdir -p libbacktrace/.libs
|
||||
cp ${libbacktrace}/lib/libbacktrace.a libbacktrace/.libs/
|
||||
cp -r ${libbacktrace}/lib/*.la libbacktrace/
|
||||
cp -r ${libbacktrace}/include/*.h libbacktrace/
|
||||
|
||||
mkdir -p libiberty/pic
|
||||
cp ${libiberty}/lib/libiberty.a libiberty/
|
||||
cp -r ${libiberty}/lib/libiberty_pic.a libiberty/pic/
|
||||
touch libiberty/stamp-noasandir libiberty/stamp-h libiberty/stamp-picdir
|
||||
|
||||
mkdir -p build-${hostPlatform.config}
|
||||
cp -r libiberty/ build-${hostPlatform.config}/libiberty
|
||||
''
|
||||
+
|
||||
lib.optionalString (targetPlatform.config == hostPlatform.config && targetPlatform != hostPlatform)
|
||||
''
|
||||
sed -i 's@is_cross_compiler=no@is_cross_compiler=yes@' configure
|
||||
''
|
||||
+ lib.optionalString (buildPlatform.config != hostPlatform.config) ''
|
||||
# We need to allow the configure script to inspect the binutils to correctly determine
|
||||
# support for e.g. ".hidden"
|
||||
export AS_FOR_TARGET="${lib.getExe' binutils-buildtarget "${binutilsTargetPrefix}as"}"
|
||||
export LD_FOR_TARGET="${lib.getExe' binutils-buildtarget "${binutilsTargetPrefix}ld"}"
|
||||
''
|
||||
+ ''
|
||||
# Our custom hook; see common.nix.
|
||||
export gccng_skip_target_lib_config=y
|
||||
|
||||
export CFLAGS="-O1"
|
||||
export CXXFLAGS="-O1"
|
||||
export LDFLAGS="-Wl,-rpath,${libmpc}/lib,-rpath,${libmpfr}/lib,-rpath,${libgmp}/lib,-rpath-link,${libc}/lib"
|
||||
bash ${common.monorepoSrc}/configure \
|
||||
--prefix=$out \
|
||||
--build=${buildPlatform.config} \
|
||||
--host=${hostPlatform.config} \
|
||||
--target=${targetPlatform.config} \
|
||||
--enable-fast-install \
|
||||
--disable-serial-configure \
|
||||
--disable-analyzer \
|
||||
--disable-dependency-tracking \
|
||||
--disable-bootstrap \
|
||||
--disable-decimal-float \
|
||||
--disable-gcov \
|
||||
--disable-install-libiberty \
|
||||
--disable-multilib \
|
||||
--disable-nls \
|
||||
--disable-libssp \
|
||||
--enable-default-pie \
|
||||
--enable-languages=c,c++ \
|
||||
--without-headers \
|
||||
--without-included-gettext \
|
||||
--enable-linker-build-id \
|
||||
--with-as=${lib.getExe' binutils-hosttarget "${binutilsTargetPrefix}as"} \
|
||||
--with-ld=${lib.getExe' binutils-hosttarget "${binutilsTargetPrefix}ld"} \
|
||||
--with-gnu-as \
|
||||
--with-gnu-ld \
|
||||
--with-sysroot=/ \
|
||||
--with-native-system-header-dir=${libc-headers}/include \
|
||||
--with-mpfr=${libmpfr} \
|
||||
--with-gmp=${libgmp} \
|
||||
--with-mpc=${libmpc} \
|
||||
--without-isl \
|
||||
--disable-plugin \
|
||||
--disable-plugins \
|
||||
--disable-lto
|
||||
sed -e '/TOPLEVEL_CONFIGURE_ARGUMENTS=/d' -i Makefile
|
||||
|
||||
# Build
|
||||
make -j $NIX_BUILD_CORES
|
||||
|
||||
# Install
|
||||
make -j $NIX_BUILD_CORES install-strip
|
||||
if [ -d "$out/lib64" ]; then
|
||||
shopt -s dotglob
|
||||
for lib in $out/lib64/*; do
|
||||
mv --no-clobber "$lib" "$out/lib/"
|
||||
done
|
||||
shopt -u dotglob
|
||||
rm -rf "$out/lib64"
|
||||
ln -s lib "$out/lib64"
|
||||
fi
|
||||
|
||||
# Prevent references to build-time dependencies
|
||||
rm -rf $out/libexec/gcc/*/*/install-tools
|
||||
rm -rf $out/lib/gcc/*/*/install-tools
|
||||
|
||||
# libstdc++ gdb pretty-printers + man pages are unused downstream.
|
||||
rm -rf $out/share/gcc-*/python $out/share/man $out/share/info
|
||||
''
|
||||
)
|
||||
@@ -5,6 +5,7 @@
|
||||
fetchurl,
|
||||
bash,
|
||||
gcc,
|
||||
libgcc,
|
||||
binutils,
|
||||
linux-headers,
|
||||
gnumake,
|
||||
@@ -54,32 +55,6 @@ bash.runCommand "${pname}-${version}"
|
||||
xz
|
||||
];
|
||||
|
||||
passthru.tests.hello-world =
|
||||
result:
|
||||
bash.runCommand "${pname}-simple-program-${version}"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
gcc
|
||||
binutils
|
||||
];
|
||||
}
|
||||
''
|
||||
cat <<EOF >> test.c
|
||||
#include <stdio.h>
|
||||
int main() {
|
||||
printf("Hello World!\n");
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
gcc \
|
||||
-Wl,--dynamic-linker=${result}/lib/${linkerFile}.so.2 \
|
||||
-B${result}/lib \
|
||||
-I${result}/include \
|
||||
-o test test.c
|
||||
./test
|
||||
mkdir $out
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "The GNU C Library";
|
||||
homepage = "https://www.gnu.org/software/libc/";
|
||||
@@ -98,7 +73,8 @@ bash.runCommand "${pname}-${version}"
|
||||
cd build
|
||||
# libstdc++.so is built against musl and fails to link
|
||||
export CXX=false
|
||||
export CFLAGS="-O1"
|
||||
export CFLAGS="-B${libgcc}/lib -L${libgcc}/lib -Wl,-rpath,${gcc}/lib,-rpath,${libgcc} -O1 -Wno-error=attribute-alias -Wno-error=maybe-uninitialized -fexceptions"
|
||||
export LDFLAGS="-L${libgcc}/lib -L${libgcc}/lib/gcc/${hostPlatform.config}/${libgcc.version} -B${libgcc}/lib -B${libgcc}/lib/gcc/${hostPlatform.config}/${libgcc.version}"
|
||||
bash ../configure \
|
||||
--prefix=$out \
|
||||
--build=${buildPlatform.config} \
|
||||
@@ -112,7 +88,7 @@ bash.runCommand "${pname}-${version}"
|
||||
--disable-mathvec
|
||||
|
||||
# Build
|
||||
make -j $NIX_BUILD_CORES
|
||||
make -j $NIX_BUILD_CORES sysdep-LDFLAGS="$LDFLAGS"
|
||||
|
||||
# Install
|
||||
make -j $NIX_BUILD_CORES INSTALL_UNCOMPRESSED=yes install
|
||||
|
||||
Reference in New Issue
Block a user