summary refs log tree commit diff
path: root/pkgs/development/misc
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2023-11-12 06:01:07 +0000
committerGitHub <noreply@github.com>2023-11-12 06:01:07 +0000
commiteb26e06e9b4f8d9a173099699ef6b8602c22e329 (patch)
tree78ec4dbbae22af7bf9f21fe22a287f990cd045ae /pkgs/development/misc
parent597366a4aa9ecdf7d56e452098a43283ba2a67a1 (diff)
parent6f314053897165a8c629484836a45d1de1a0e965 (diff)
Merge master into staging-next
Diffstat (limited to 'pkgs/development/misc')
-rw-r--r--pkgs/development/misc/newlib/default.nix25
1 files changed, 24 insertions, 1 deletions
diff --git a/pkgs/development/misc/newlib/default.nix b/pkgs/development/misc/newlib/default.nix
index d162753608bdc..8aed144ff65c2 100644
--- a/pkgs/development/misc/newlib/default.nix
+++ b/pkgs/development/misc/newlib/default.nix
@@ -31,13 +31,36 @@ stdenv.mkDerivation (finalAttrs: {
   # newlib expects CC to build for build platform, not host platform
   preConfigure = ''
     export CC=cc
+  '' +
+  # newlib tries to disable itself when building for Linux *except*
+  # when native-compiling.  Unfortunately the check for "is cross
+  # compiling" was written when newlib was part of GCC and newlib
+  # was built along with GCC (therefore newlib was built to execute
+  # on the targetPlatform, not the hostPlatform).  Unfortunately
+  # when newlib was extracted from GCC, this "is cross compiling"
+  # logic was not fixed.  So we must disable it.
+  ''
+    substituteInPlace configure --replace 'noconfigdirs target-newlib target-libgloss' 'noconfigdirs'
   '';
 
+
   configurePlatforms = [ "build" "target" ];
   # flags copied from https://community.arm.com/support-forums/f/compilers-and-libraries-forum/53310/gcc-arm-none-eabi-what-were-the-newlib-compilation-options
   # sort alphabetically
   configureFlags = [
-    "--host=${stdenv.buildPlatform.config}"
+    "--with-newlib"
+
+    # The newlib configury uses `host` to refer to the platform
+    # which is being used to compile newlib.  Ugh.  It does this
+    # because of its history: newlib used to be distributed with and
+    # built as part of gcc.
+    #
+    # To prevent nixpkgs from going insane, this package presents the
+    # "normal" view to the outside world: the binaries in $out will
+    # execute on `stdenv.hostPlatform`.  We then fool newlib's build
+    # process into doing the right thing.
+    "--host=${stdenv.targetPlatform.config}"
+
   ] ++ (if !nanoizeNewlib then [
     "--disable-newlib-supplied-syscalls"
     "--disable-nls"