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

gcc-arm-embedded downloads a precompiled binary for linux only #11875

Closed
copumpkin opened this issue Dec 22, 2015 · 5 comments
Closed

gcc-arm-embedded downloads a precompiled binary for linux only #11875

copumpkin opened this issue Dec 22, 2015 · 5 comments
Labels
0.kind: enhancement Add something new

Comments

@copumpkin
Copy link
Member

This tripped up someone trying to use it on Darwin on IRC today. Is it not possible for it to use our extensive existing gcc machinery, which already works on Darwin?

cc @bjornfor

@copumpkin copumpkin added the 0.kind: enhancement Add something new label Dec 22, 2015
@bjornfor
Copy link
Contributor

Why not have both?

Nix still does not dominate the world, so I think it is nice to be able to use a toolchain on nix that is readily available on non-nix systems.

I'd love better cross compiler/ing support in nix though.

@cleverca22
Copy link
Contributor

when i was helping stepcut on irc i got things worked down to just this:
http://pastebin.com/YmJPSDzc + nix-build default.nix -A gccCrossStageStatic
but that only works on linux based nix, the darwin nix uses an incompatible binutils

@stepcut
Copy link
Contributor

stepcut commented Dec 25, 2015

I made some additional progress. There are two sets of problems -- things that are nix specific, and things that are related to building a GCC cross-compiler with clang.

These are the patches I have to nixpkgs files so far:

[nix-shell:~/nixpkgs]$ git diff
git diff
diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix
index fecdd85..d50b618 100644
--- a/pkgs/development/compilers/gcc/4.9/default.nix
+++ b/pkgs/development/compilers/gcc/4.9/default.nix
@@ -303,8 +303,9 @@ stdenv.mkDerivation ({
     if SDKROOT=$(/usr/bin/xcrun --show-sdk-path); then
       configureFlagsArray+=(--with-native-system-header-dir=$SDKROOT/usr/include)
       makeFlagsArray+=( \
-       CFLAGS_FOR_BUILD=-F$SDKROOT/System/Library/Frameworks \
-       CFLAGS_FOR_TARGET=-F$SDKROOT/System/Library/Frameworks \
+       CXXFLAGS="-g -O2 -fbracket-depth=1024" \
+       CFLAGS_FOR_BUILD="-F$SDKROOT/System/Library/Frameworks" \
+       CFLAGS_FOR_TARGET="-F$SDKROOT/System/Library/Frameworks" \
        FLAGS_FOR_TARGET=-F$SDKROOT/System/Library/Frameworks \
       )
     fi
@@ -398,6 +399,7 @@ stdenv.mkDerivation ({
     CC_FOR_TARGET = "${stdenv.cross.config}-gcc";
     NM_FOR_TARGET = "${stdenv.cross.config}-nm";
     CXX_FOR_TARGET = "${stdenv.cross.config}-g++";
+    CXXFLAGS_FOR_TARGET="-g -O2 -fbracket-depth=1024";
     # If we are making a cross compiler, cross != null
     NIX_CC_CROSS = if cross == null then "${stdenv.ccCross}" else "";
     dontStrip = true;
diff --git a/pkgs/development/compilers/gcc/builder.sh b/pkgs/development/compilers/gcc/builder.sh
index dd77c67..9e59d30 100644
--- a/pkgs/development/compilers/gcc/builder.sh
+++ b/pkgs/development/compilers/gcc/builder.sh
@@ -24,7 +24,11 @@ if test "$noSysDirs" = "1"; then
         # Figure out what extra flags to pass to the gcc compilers
         # being generated to make sure that they use our glibc.
         extraFlags="$(cat $NIX_CC/nix-support/libc-cflags)"
-        extraLDFlags="$(cat $NIX_CC/nix-support/libc-ldflags) $(cat $NIX_CC/nix-support/libc-ldflags-before)"
+        if [ -e $NIX_CC/nix-support/libc-ldflags-before ]; then
+            extraLDFlags="$(cat $NIX_CC/nix-support/libc-ldflags) $(cat $NIX_CC/nix-support/libc-ldflags-before)"
+        else
+            extraLDFlags="$(cat $NIX_CC/nix-support/libc-ldflags)"
+        fi

         # Use *real* header files, otherwise a limits.h is generated
         # that does not include Glibc's limits.h (notably missing
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 5917e71..621cee8 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -5469,7 +5469,7 @@ let

   binutilsCross = assert crossSystem != null; lowPrio (forceNativeDrv (
     if crossSystem.libc == "libSystem" then darwin.cctools_cross
-    else binutils.override {
+    else binutils_nogold.override {
       noSysDirs = true;
       cross = crossSystem;
     }));

However this patch is also required:

https://sourceware.org/bugzilla/show_bug.cgi?id=19222

I have not yet applied that patch so I am not sure what other issues lurk. It is possible that is the last issue though.

@dvc94ch
Copy link
Contributor

dvc94ch commented Jun 13, 2016

building cross compilers is possible now, is this issue still relevant? or can we close this issue after #15867?

@matthewbauer
Copy link
Member

Closing (see #39087)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement Add something new
Projects
None yet
Development

No branches or pull requests

6 participants