-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
binutils-unwrapped: install gcc LTO plugin #188544
Conversation
73d70fe
to
6faf661
Compare
Fixed |
I think these changes are correct, but I'd love for @Ericson2314 to take a look before we merge it. Especially the cross implications of this. |
We shouldn't have binutills depend on GCC that is backwards bootstrapping. We have have the wrapper or a new derivation instead "mix in" this plugin. |
That makes sense.
To avoid the need of need a bunch of Currently static void
build_plugin_list (bfd *abfd)
{
/* The intent was to search ${libdir}/bfd-plugins for plugins, but
unfortunately the original implementation wasn't precisely that
when configuring binutils using --libdir. Search in the proper
path first, then the old one for backwards compatibility. */
static const char *path[]
= { LIBDIR "/bfd-plugins", BINDIR "/../lib/bfd-plugins" };
... |
Let's make an env var and try to upstream it? |
Before the change binutils was not able to handle LTO bytecode without explicit plugin being passed: $ touch a.c && gcc -flto -fPIC -c a.c -o a.o && ar cr a.a a.o ar: a.o: plugin needed to handle lto object After the change binutils can now handle LTO bytecode and build valid indices: $ touch a.c && gcc -flto -fPIC -c a.c -o a.o && ar cr a.a a.o <ok> The change fixes LTO build of sway: $ nix build --impure --expr 'with import ./. {}; sway-unwrapped.overrideAttrs (oa: { NIX_CFLAGS_COMPILE = "-flto=auto"; NIX_CFLAGS_LINK = "-flto=auto"; })
Note: it's an incompletel wrap: we only populate plugin link for `ld`, `strip` (existing wrappers) and `ar` (new wrapper). If we go that route we'll need to wrap most binaries for GNU binutils as almost all of them can detect plugin format and act on it accordingly: `size`, `nm`, `ranlib`, `addr2line`.
6faf661
to
30f9808
Compare
@Ericson2314 I switched to runtime detection of a plugin and switched to plugin injection at binutils-wrapper site. PTAL. CAVEAT: I created only a subset of binutils wrappers: I find the result quite messy :)
|
@trofi OK this is better just a few things things left:
The ideal bootstrapping is:
If bintuils depends on GCC for the plugin, however, we need to build it twice:
This is wasteful. The only reason you didn't notice this is because the current convoluted native bootstrapping obscures it. But I would want to get LTO support for cross native alike, so I rather not rely on that tech debt serendipitously helping us :). |
Aha, I'll spend some time understanding what is the correct gcc passed to wrapper.
Aha, makes sense. One option would be to put it to
That makes sense. Given that I'll turn it into a WIP ntil I update the patchset.
For my understanding: do you describe one step of bootstrap or full bootstrap? If it's a full bootstrap we will get binaries built by (prebuilt) bootstrap compiler. Which might be problematic if
Aha, makes sense. I guess it depends on the goals of
Current Also fun fact: current bootstrap builds binutils 3 times:
|
@trofi So my long term goal is to make all bootstrapping, native or cross, build the same way. And also to minimize dependencies / avoid extra rebuild steps. In that regard, just on basic intuition, compilers (may) need linkers, but linkers shouldn't assume the existence of any specific compiler because they can be used with many. In fact, at build time, neither compilers or linkers should be aware of each other because tool chains can be put together after the fact in many different ways. Basically, we've fought vary hard to separate concerns and untangle things, and this gives us the flexible to solve bootstrapping problems and other problems in more and nicer ways, and I want to keep that separation of concerns and flexibility. |
As to search path, yes maybe a flag would be better. I guess keep it a single env var for now, but please do email the mailing list so they can bikeshed what they want and we aren't left guessing. |
To email something material I need more precise semantics than "a flag, or a path, or a list of paths". There already is a I'll abandon this PR until I get a bit better understanding what our bootstrap is achieving to see how LTO fits into it. |
Aw, I was excited to see this happen. To me the semantics of search path should be just like |
I'm not sure how plugins could follow Given that plugin is loaded into address space of the compiler there are extra constraints how compatible they are: for example I don't expect gcc plugin built against musl libc runtime to work when loaded into For fancier cases like The indirection of |
@trofi Given all your recent work on bootstrap, and the improvements amjoseph landed, how do you feel about giving this another shot? Happy to chat on Matrix about it, as soon as I manage to log into my account :^) |
Yeah, I keep the tab open to get it working eventually. Currently stdenv is in a bit of flux and will require more cleanups to fix things like |
I'm dropping the ball on that. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Reviewers' note: I did a very hacky condition of gcc and binutils compatibility. I think it's slightly incorrect for cross case. Please have a close look at it.
Before the change binutils was not able to handle LTO bytecode without
explicit plugin being passed:
After the change binutils can now handle LTO bytecode and build valid
indices:
The change fixes LTO build of sway:
Description of changes
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes