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

libgcc: Init at 7.3.0 #44069

Merged
merged 2 commits into from Jul 25, 2018
Merged

libgcc: Init at 7.3.0 #44069

merged 2 commits into from Jul 25, 2018

Conversation

Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented Jul 25, 2018

Motivation for this change

I want to start from this, and work towards packaging all the libraries this way. Then we can:

  1. Go from 2 cross compilers ("stage static" "stage final") to just 1
  2. Easier LLVM cross compilation without needing to work around the 2 GCC dance.
  3. Radically simplify CC wrapper (compiler-rt is already built separately)
  4. Simplify native and cross boostrapping (as libraries and tools can always be built separately during bootstrapping)
  5. Help with @angerman's windows improvements (where custom bootstrapping is needed as some more GCC libraries require libc).
  6. Radically simplify GCC derivation. There might be net more code, as at least libgcc is hard to build on its own, but the each derivation will be much simpler
  7. Build libstdc++ separately for libstdcxxClang

This is analogous to @kirelagin and @matthewbauer's work rebuilding GHC wired-in libraries.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • cross ->linux
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

export AS_FOR_TARGET=${stdenvNoLibs.cc}/bin/$AS_FOR_TARGET
export CC_FOR_TARGET=${stdenvNoLibs.cc}/bin/$CC_FOR_TARGET
export CPP_FOR_TARGET=${stdenvNoLibs.cc}/bin/$CPP_FOR_TARGET
export LD_FOR_TARGET=${stdenvNoLibs.cc.bintools}/bin/$LD_FOR_TARGET
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, GHC, and the cmake setup hook all demonstrate that we really need to change binutils-wrapper to make these full paths across the board, not just names on the PATH.

@angerman
Copy link
Contributor

I did something similar in #40637, the primary motivation was to build gcc+winpthreads to support c++11 threading features. That however turned out to produce libraries that behaved subtly different from those built with the msvc. As such I did not persue that further.

Building with libwpthreads requries building gcc (no libs), then winpthreads with that gcc, and finally the rest of the libs to package it all together. So this migth just work out right with this appraoch.

@Ericson2314
Copy link
Member Author

Oh! I somehow missed that and assume you never upstreamed it. My bad!

@Ericson2314
Copy link
Member Author

Ericson2314 commented Jul 25, 2018

Are you saying that your old PR didn't work, but this might? Or just that whole window rebootstrap is doomed?

@angerman
Copy link
Contributor

It's not upstreamed and it's not perfectly working. Yes. I think this might be a clearer approach; you've got way more experience with the low level details (doh!).

But maybe there's a nugget or two you can use :-)

@Ericson2314
Copy link
Member Author

Ericson2314 commented Jul 25, 2018

Well this wouldn't fix any C++ ABI issues with GCC, but it might make cross with LLVM easier, and LLVM on/for Windows has recently seen a lot of work. I'll be sure to take a look at that your stuff!

@GrahamcOfBorg
Copy link

Failure on aarch64-linux (full log)

Attempted: libgcc, libstdcxx5

Partial log (click to expand)

wrong ELF type
wrong ELF type
wrong ELF type
moving /nix/store/qkihfr0yjp24ls2s04q384b0zia6h2lk-libgcc-7.3.0/lib64/* to /nix/store/qkihfr0yjp24ls2s04q384b0zia6h2lk-libgcc-7.3.0/lib
shrinking RPATHs of ELF executables and libraries in /nix/store/kl5cr6nbj5swaaai49zl2i05jqj5sn79-libgcc-7.3.0-dev
strip is /nix/store/a245zacjzf3qw0davhvlfarihcy2yyrc-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/kl5cr6nbj5swaaai49zl2i05jqj5sn79-libgcc-7.3.0-dev/lib
patching script interpreter paths in /nix/store/kl5cr6nbj5swaaai49zl2i05jqj5sn79-libgcc-7.3.0-dev
checking for references to /build in /nix/store/kl5cr6nbj5swaaai49zl2i05jqj5sn79-libgcc-7.3.0-dev...
error: build of '/nix/store/wjf058s0ghn1k25h9f94lkyy16ma1457-libstdc++5-3.3.6.drv' failed

@Ericson2314 Ericson2314 added this to the 17.09 milestone Jul 25, 2018
@Ericson2314 Ericson2314 added the 6.topic: portability General portability concerns, not specific to cross-compilation or a specific platform label Jul 25, 2018
@GrahamcOfBorg
Copy link

Failure on x86_64-linux (full log)

Attempted: libgcc, libstdcxx5

Partial log (click to expand)

wrong ELF type
wrong ELF type
wrong ELF type
moving /nix/store/7ygs85qm585fvb9603anw8w8afmpp29w-libgcc-7.3.0/lib64/* to /nix/store/7ygs85qm585fvb9603anw8w8afmpp29w-libgcc-7.3.0/lib
shrinking RPATHs of ELF executables and libraries in /nix/store/vhk0vfsrnqplb5vfwrvj8l45qpz1sqn8-libgcc-7.3.0-dev
strip is /nix/store/a3nk8z2i7m7wa3jdckgv710n7j3yx4b5-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/vhk0vfsrnqplb5vfwrvj8l45qpz1sqn8-libgcc-7.3.0-dev/lib
patching script interpreter paths in /nix/store/vhk0vfsrnqplb5vfwrvj8l45qpz1sqn8-libgcc-7.3.0-dev
checking for references to /build in /nix/store/vhk0vfsrnqplb5vfwrvj8l45qpz1sqn8-libgcc-7.3.0-dev...
error: build of '/nix/store/iyrpsk0chsg8jzrf6q6s2gp3l52f7gkg-libstdc++5-3.3.6.drv' failed

@GrahamcOfBorg
Copy link

Failure on aarch64-linux (full log)

Attempted: libgcc, libstdcxx5

Partial log (click to expand)

wrong ELF type
wrong ELF type
wrong ELF type
wrong ELF type
shrinking RPATHs of ELF executables and libraries in /nix/store/rg3g1w2hn7kw1cnvmnsc7ya4bwxwgw0j-libgcc-7.3.0-dev
strip is /nix/store/a245zacjzf3qw0davhvlfarihcy2yyrc-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/rg3g1w2hn7kw1cnvmnsc7ya4bwxwgw0j-libgcc-7.3.0-dev/lib
patching script interpreter paths in /nix/store/rg3g1w2hn7kw1cnvmnsc7ya4bwxwgw0j-libgcc-7.3.0-dev
checking for references to /build in /nix/store/rg3g1w2hn7kw1cnvmnsc7ya4bwxwgw0j-libgcc-7.3.0-dev...
error: build of '/nix/store/wjf058s0ghn1k25h9f94lkyy16ma1457-libstdc++5-3.3.6.drv' failed

@GrahamcOfBorg
Copy link

Failure on x86_64-darwin (full log)

Attempted: libgcc

The following builds were skipped because they don't evaluate on x86_64-darwin: libstdcxx5

Partial log (click to expand)

ln -s /private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc/gthr-posix.h gthr-default.h
DEFINES='' HEADERS='/private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc/config/i386/darwin-lib.h' \
        /private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc/mkheader.sh > tmp-libgcc_tm.h
/nix/store/ryb1pmpqm7xiznq5574lifykqrr30hg6-bash-4.4-p23/bin/bash /private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc/../move-if-change tmp-libgcc_tm.h libgcc_tm.h
echo timestamp > libgcc_tm.stamp
/nix/store/9r8nrjxq2njgfl879dvd5acm4c8hc79q-clang-wrapper-5.0.2/bin/clang -g -O2 -O2  -DIN_GCC    -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -mmacosx-version-min=10.5 -pipe -fno-common -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -mmacosx-version-min=10.5 -pipe -fno-common -I. -I. -I../../.././gcc -I/private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc -I/private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc/. -I/private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc/../gcc -I/private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc/../include  -DHAVE_CC_TLS  -o _muldi3.o -MT _muldi3.o -MD -MP -MF _muldi3.dep -DL_muldi3 -c /private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
clang-5.0: error: unknown argument: '-fbuilding-libgcc'
make: *** [Makefile:491: _muldi3.o] Error 1
builder for '/nix/store/hzfl0iw7hnd0bp6b6x01xz2cfsksnphh-libgcc-7.3.0.drv' failed with exit code 2
�[31;1merror:�[0m build of '/nix/store/hzfl0iw7hnd0bp6b6x01xz2cfsksnphh-libgcc-7.3.0.drv' failed

@GrahamcOfBorg
Copy link

Failure on x86_64-linux (full log)

Attempted: libgcc, libstdcxx5

Partial log (click to expand)

collect2: ld returned 1 exit status
make[3]: *** [Makefile:309: abi_check] Error 1
make[3]: Leaving directory '/build/build/x86_64-unknown-linux-gnu/libstdc++-v3/testsuite'
make[2]: *** [Makefile:287: all-recursive] Error 1
make[2]: Leaving directory '/build/build/x86_64-unknown-linux-gnu/libstdc++-v3'
make[1]: *** [Makefile:418: all-recursive-am] Error 2
make[1]: Leaving directory '/build/build/x86_64-unknown-linux-gnu/libstdc++-v3'
make: *** [Makefile:1456: all-target-libstdc++-v3] Error 2
builder for '/nix/store/iyrpsk0chsg8jzrf6q6s2gp3l52f7gkg-libstdc++5-3.3.6.drv' failed with exit code 2
error: build of '/nix/store/iyrpsk0chsg8jzrf6q6s2gp3l52f7gkg-libstdc++5-3.3.6.drv' failed

This will be very useful for bootstrapping, eventually.
@GrahamcOfBorg
Copy link

Failure on x86_64-darwin (full log)

Attempted: libgcc

The following builds were skipped because they don't evaluate on x86_64-darwin: libstdcxx5

Partial log (click to expand)

ln -s /private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc/gthr-posix.h gthr-default.h
DEFINES='' HEADERS='/private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc/config/i386/darwin-lib.h' \
        /private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc/mkheader.sh > tmp-libgcc_tm.h
/nix/store/ryb1pmpqm7xiznq5574lifykqrr30hg6-bash-4.4-p23/bin/bash /private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc/../move-if-change tmp-libgcc_tm.h libgcc_tm.h
echo timestamp > libgcc_tm.stamp
/nix/store/9r8nrjxq2njgfl879dvd5acm4c8hc79q-clang-wrapper-5.0.2/bin/clang -g -O2 -O2  -DIN_GCC    -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -mmacosx-version-min=10.5 -pipe -fno-common -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -mmacosx-version-min=10.5 -pipe -fno-common -I. -I. -I../../.././gcc -I/private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc -I/private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc/. -I/private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc/../gcc -I/private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc/../include  -DHAVE_CC_TLS  -o _muldi3.o -MT _muldi3.o -MD -MP -MF _muldi3.dep -DL_muldi3 -c /private/tmp/nix-build-libgcc-7.3.0.drv-0/gcc-7.3.0/libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
clang-5.0: error: unknown argument: '-fbuilding-libgcc'
make: *** [Makefile:491: _muldi3.o] Error 1
builder for '/nix/store/pzy323mkgyigwg7fam3iscxirlxbsnfg-libgcc-7.3.0.drv' failed with exit code 2
�[31;1merror:�[0m build of '/nix/store/pzy323mkgyigwg7fam3iscxirlxbsnfg-libgcc-7.3.0.drv' failed

@GrahamcOfBorg
Copy link

Failure on aarch64-linux (full log)

Attempted: libgcc, libstdcxx5

Partial log (click to expand)

wrong ELF type
wrong ELF type
wrong ELF type
wrong ELF type
shrinking RPATHs of ELF executables and libraries in /nix/store/qmj8qdg8g1aa4pghpmfi2pb1vh6q8s04-libgcc-7.3.0-dev
strip is /nix/store/a245zacjzf3qw0davhvlfarihcy2yyrc-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/qmj8qdg8g1aa4pghpmfi2pb1vh6q8s04-libgcc-7.3.0-dev/lib
patching script interpreter paths in /nix/store/qmj8qdg8g1aa4pghpmfi2pb1vh6q8s04-libgcc-7.3.0-dev
checking for references to /build in /nix/store/qmj8qdg8g1aa4pghpmfi2pb1vh6q8s04-libgcc-7.3.0-dev...
error: build of '/nix/store/wjf058s0ghn1k25h9f94lkyy16ma1457-libstdc++5-3.3.6.drv' failed

@GrahamcOfBorg
Copy link

Failure on x86_64-linux (full log)

Attempted: libgcc, libstdcxx5

Partial log (click to expand)

collect2: ld returned 1 exit status
make[3]: *** [Makefile:309: abi_check] Error 1
make[3]: Leaving directory '/build/build/x86_64-unknown-linux-gnu/libstdc++-v3/testsuite'
make[2]: *** [Makefile:287: all-recursive] Error 1
make[2]: Leaving directory '/build/build/x86_64-unknown-linux-gnu/libstdc++-v3'
make[1]: *** [Makefile:418: all-recursive-am] Error 2
make[1]: Leaving directory '/build/build/x86_64-unknown-linux-gnu/libstdc++-v3'
make: *** [Makefile:1456: all-target-libstdc++-v3] Error 2
builder for '/nix/store/iyrpsk0chsg8jzrf6q6s2gp3l52f7gkg-libstdc++5-3.3.6.drv' failed with exit code 2
error: build of '/nix/store/iyrpsk0chsg8jzrf6q6s2gp3l52f7gkg-libstdc++5-3.3.6.drv' failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: portability General portability concerns, not specific to cross-compilation or a specific platform 8.has: package (new) 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10
Projects
No open projects
Cross compilation
Planned for 18.09
Development

Successfully merging this pull request may close these issues.

None yet

6 participants