Skip to content

Commit

Permalink
gccWithoutTargetLibc: enable langCC
Browse files Browse the repository at this point in the history
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 <Artturin@artturin.com>
Co-Authored-By: Arsen Arsenović <arsen@aarsen.me>
  • Loading branch information
3 people committed Jan 12, 2025
1 parent 5209768 commit d4dfeae
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkgs/development/compilers/gcc/common/configure-flags.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion pkgs/development/compilers/gcc/common/dependencies.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
which,
gettext,
gnused,
autoconf269,
patchelf,
gmp,
mpfr,
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions pkgs/development/compilers/gcc/common/pre-configure.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions pkgs/development/compilers/gcc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit d4dfeae

Please sign in to comment.