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

cc-wrapper: More intelligent sierra hack #29096

Merged

Conversation

Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented Sep 7, 2017

Motivation for this change

I made a patch for cctool's ld in order to get it to split out flags for all inputs in a fully-resolved normal form. I use this to avoid trying to -reexport-l static libraries. Linking them directly will reexport them just fine.

@TaktInc needs this for 17.03, so I'm starting here and then forward porting to master (and probably 17.09 if all goes well).

The patch itself uses \0 as a delimiter, but perhaps expandResponseParams could be used to parse a more human readable output. I just bring this up if it would help upstream the patch.

N.B. as I mentioned in #24844 (comment), if we likewise patch GNU Binutils, we can dramatically simplify ld-wrapper (with and without the sierra hack) by not trying to resolve linker scripts on our own.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • 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/)
  • Fits CONTRIBUTING.md.

CC @orivej

@@ -2,67 +2,113 @@

set -eu -o pipefail

# For cmd | while; read; do ...; done
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is needed for the block after the pipe (the while loop here) to set Bash variables. Otherwise it runs in a subshell and the variables it sets are not visible outside that block.

Copy link
Member

Choose a reason for hiding this comment

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

I'm asking about the comment :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't have though of this reason without the comment, so it was useful for me.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it's not clear to my lastpipe is always an improvement, unlike the other extensions I used, so I wanted to motivate it.

I should remove the extra semicolon, however :D

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed!

Patch is drawn from [1], a back-port of [2].

Eventually, we might consider doing something for GNU binutils too, in
order that we switch (the normal) ld-wrapper to always use this to
leverage ld to resolve libraries, rather than faking it in bash.

[1]: https://github.com/obsidiansystems/cctools-port/tree/libs-normalize-17.03
[2]: tpoechtrager/cctools-port#34
@Ericson2314 Ericson2314 force-pushed the appease-sierra-linker branch 3 times, most recently from 86316fb to ba053dc Compare September 13, 2017 02:35
Also fix numberous bugs, such as:

 - Not getting confused on more flags taking file arguments.

 - Ensuring children reexport their children, but the original
   binary/library doesn't.

 - Not spawning children when it turns out we just dynamically link
   under the threshold but our total number of inputs exceeeds it.

 - Children were always named `libunnamed-*`, when that name was
   supposed to be the last resort only.

In addition to the script, we also patch ld-wrapper to respect `.dylib`
and `.so` alike. In a future version of nixpkgs, this can be so enabled
by defaut. Newer nixpkgs will probably do this by default.
@Ericson2314
Copy link
Member Author

Ok! I tested this on a big haskell project ;) and with my existing C test. It passes!

@Ericson2314 Ericson2314 merged commit 86c879d into NixOS:release-17.03 Sep 13, 2017
@Ericson2314 Ericson2314 deleted the appease-sierra-linker branch September 13, 2017 02:45
@Ericson2314 Ericson2314 added the 9.needs: port to stable A PR needs a backport to the stable release. label Sep 13, 2017
@Ericson2314
Copy link
Member Author

Ericson2314 commented Sep 13, 2017

This now needs to be ported to master and 17.09, which I will do shortly. Also, we can try deploying it by default (for just Haskell or even all of Darawin) / get rid of the existing half-measures.

CC @globin @fpletz

@samueldr samueldr removed the 9.needs: port to stable A PR needs a backport to the stable release. label Apr 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants