Nixpkgs Stdenv | 234 Members | |
| 75 Servers |
| Sender | Message | Time |
|---|---|---|
| 27 Oct 2024 | ||
Yeah. Unfortunately compilers (and linkers) assume quite a bit about FHS layout: ld.so location, crt?.o file lookup, executable tools (as) lookup, etc. I'd say adding the proper knobs to upstreams (like an arbitrary --prefix= for these things instead of hardcoded paths with various inference rules) might be the best long-term option. But they have to be designed carefully to be compatible (or at least non-conflictings) with --sysroot= stuff, cross-compiling directory switch, multilib switch, etc. | 22:10:21 | |
| right. | 22:11:11 | |
| in Darwin we have the situation where we have switched to assembling a "normal"-structured sysroot for the basic system library set – which in our case is not FHS but instead the Xcode SDK layout – because it is much more compatible with build systems (and anyway contains only headers and stub libraries) | 22:12:13 | |
which meant having to patch the purity filter to be aware of the fact that things like -L/usr/lib/swift are relative to that sysroot and therefore shouldn't be filtered | 22:12:36 | |
| I'd love to do more working with upstreams to get the appropriate knobs for our toolchains. I would be happiest if we didn't have wrappers at all | 22:13:04 | |
but the state where we have a half-broken command-line parser just to filter out build systems that pass in -I/usr/whatever in non-build development shells on non-NixOS … is sad to me | 22:13:39 | |
| yeah, wrappers are a disaster | 22:13:42 | |
| the juice may be barely worth the squeeze, but I just spent several days fighting the squeeze on Darwin and it's been a pain | 22:14:12 | |
| and there's so many ways you can bypass it inadvertently to get a bad path into the argv anyway. | 22:14:26 | |
so, one thing about the sysroot is that apparently at least on Darwin -isysroots stack, so we could do a thing where we pass one that just contains empty ./usr/lib etc., and overlay our SDK sysroot on top of that. I don't know if it's possible to do that with Linux toolchains, though. | 22:15:28 | |
but if it is, we could maybe have such a stub sysroot to catch common errant -I and -L paths, and then "overlay" / on top to get DT_NEEDED etc. working? | 22:15:57 | |
| it's possible that all this is just weird Darwin-specific behaviour that we can't replicate on Linux though. | 22:16:10 | |
I had an impression that to get a sysroot prefix addition on linux you need to add = in front, like -L=/usr/lib. Otherwise it will use unprefixed path. Linker scripts have an exception though that if the linker script is within the sysroot the prefix is added anyways even if = is not prepended: https://sourceware.org/binutils/docs/ld/File-Commands.html | 22:21:34 | |
| 22:23:06 | |
| That hurts my brain to parse. | 22:23:42 | |
If a linker script is in sysroot directory and /foo paths will work like =/foo paths :) | 22:24:09 | |
* If a linker script is in sysroot directory then any /foo paths will work like =/foo paths :) | 22:24:23 | |
| so you're saying we just need to put a linker script in there? :) | 22:25:03 | |
| I think this is what I wanted.
If searchdir begins with = or $SYSROOT, then this prefix will be replaced by the sysroot prefix, controlled by the ‘--sysroot’ option, or specified when the linker is configured. | 22:25:25 | |
| oh, only for things the linker script references. | 22:25:27 | |
| * I think this is what I wanted.
| 22:25:34 | |
| binutils’s | 22:25:58 | |
| I wonder if this stuff is conditioned based on host or target platform 🙃 | 22:25:59 | |
| (for e.g. Clang) | 22:26:15 | |
(uh, -I is definitely interpreted relative to $SDKROOT with Clang on Darwin, right?) | 22:26:42 | |
| Yes. | 22:27:23 | |
| I’m pretty sure. | 22:27:43 | |
| it would be funny if the solution ends up being "ask toolchains to allow us to opt-in to the weird Darwin prefixing behaviour on other platforms". | 22:27:50 | |
| don't ever say Darwin support does nothing for Nixpkgs! | 22:27:59 | |
| https://github.com/NixOS/nixpkgs/pull/351768 | 22:48:34 | |