From d4dfeae62ab75d468cba76834c182cc6d3c83f71 Mon Sep 17 00:00:00 2001 From: sanana Date: Fri, 3 Jan 2025 20:50:06 +0300 Subject: [PATCH] gccWithoutTargetLibc: enable langCC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously gccWithoutTargetLibc was built with `langCC = false;`, which meant stdenvNoLibc had C++ support when not cross compiling or when the host platform toolchain is LLVM, but did not have C++ support when cross compiling for a non-Darwin and non-LLVM host platform. This patch fixes issues when cross compiling C++ packages built with stdenvNoLibc like LLVM libc and the mlibc package I'm (sanana) working on. Co-Authored-By: Artturin Co-Authored-By: Arsen Arsenović --- .../compilers/gcc/common/configure-flags.nix | 5 +++++ pkgs/development/compilers/gcc/common/dependencies.nix | 4 +++- .../development/compilers/gcc/common/pre-configure.nix | 10 ++++++++++ pkgs/development/compilers/gcc/default.nix | 2 ++ pkgs/top-level/all-packages.nix | 1 - 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/gcc/common/configure-flags.nix b/pkgs/development/compilers/gcc/common/configure-flags.nix index 25d4f1f53bae9..bd27f894fed3a 100644 --- a/pkgs/development/compilers/gcc/common/configure-flags.nix +++ b/pkgs/development/compilers/gcc/common/configure-flags.nix @@ -68,6 +68,11 @@ let "--disable-libatomic" # requires libc "--disable-decimal-float" # requires libc "--disable-libmpx" # requires libc + "--disable-hosted-libstdcxx" + "--disable-libstdcxx-backtrace" + "--disable-linux-futex" + "--disable-libvtv" + "--disable-libitm" ] ++ lib.optionals crossMingw [ "--with-headers=${lib.getDev libcCross}/include" "--with-gcc" diff --git a/pkgs/development/compilers/gcc/common/dependencies.nix b/pkgs/development/compilers/gcc/common/dependencies.nix index 0e29fd51e45bb..eb6d025b1ef68 100644 --- a/pkgs/development/compilers/gcc/common/dependencies.nix +++ b/pkgs/development/compilers/gcc/common/dependencies.nix @@ -8,6 +8,7 @@ which, gettext, gnused, + autoconf269, patchelf, gmp, mpfr, @@ -49,7 +50,8 @@ in ++ optionals langRust [ cargo ] # The builder relies on GNU sed (for instance, Darwin's `sed' fails with # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it. - ++ optionals buildPlatform.isDarwin [ gnused ]; + ++ optionals buildPlatform.isDarwin [ gnused ] + ++ optionals withoutTargetLibc [ autoconf269 ]; # For building runtime libs # same for all gcc's diff --git a/pkgs/development/compilers/gcc/common/pre-configure.nix b/pkgs/development/compilers/gcc/common/pre-configure.nix index a8594171d9098..f666a710c4dbe 100644 --- a/pkgs/development/compilers/gcc/common/pre-configure.nix +++ b/pkgs/development/compilers/gcc/common/pre-configure.nix @@ -48,6 +48,16 @@ lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' export STRIP='strip -x' '' + ++ lib.optionalString withoutTargetLibc '' + for i in */configure.ac; do + pushd "$(dirname "$i")" + echo "Running autoreconf in $PWD" + autoconf -f + popd + done +'' + # HACK: if host and target config are the same, but the platforms are # actually different we need to convince the configure script that it # is in fact building a cross compiler although it doesn't believe it. diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index 91d27aba7e2b7..a2f46c5a8a0dd 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -16,6 +16,7 @@ , texinfo ? null , perl ? null # optional, for texi2pod (then pod2man) , gmp, mpfr, libmpc, gettext, which, patchelf, binutils +, autoconf269 , isl ? null # optional, for the Graphite optimization framework. , zlib ? null , libucontext ? null @@ -103,6 +104,7 @@ let # inherit generated with 'nix eval --json --impure --expr "with import ./. {}; lib.attrNames (lib.functionArgs gcc${majorVersion}.cc.override)" | jq '.[]' --raw-output' inherit apple-sdk + autoconf269 binutils buildPackages cargo diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 58f4ab07d90a0..9e26ee058f1ff 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6040,7 +6040,6 @@ with pkgs; isl = if !stdenv.hostPlatform.isDarwin then isl_0_20 else null; withoutTargetLibc = true; - langCC = false; libcCross = libcCross1; targetPackages.stdenv.cc.bintools = binutilsNoLibc; enableShared =