!OqhvaDMJdKYUicLDiE:nixos.org

Nixpkgs Stdenv

234 Members
75 Servers

Load older messages


SenderMessageTime
27 Oct 2024
@trofi:matrix.orgtrofi 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
@emilazy:matrix.orgemilyright.22:11:11
@emilazy:matrix.orgemilyin 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
@emilazy:matrix.orgemily 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
@emilazy:matrix.orgemilyI'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 all22:13:04
@emilazy:matrix.orgemily 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
@trofi:matrix.orgtrofiyeah, wrappers are a disaster22:13:42
@emilazy:matrix.orgemilythe juice may be barely worth the squeeze, but I just spent several days fighting the squeeze on Darwin and it's been a pain22:14:12
@emilazy:matrix.orgemilyand there's so many ways you can bypass it inadvertently to get a bad path into the argv anyway.22:14:26
@emilazy:matrix.orgemily 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
@emilazy:matrix.orgemily 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
@emilazy:matrix.orgemilyit's possible that all this is just weird Darwin-specific behaviour that we can't replicate on Linux though.22:16:10
@trofi:matrix.orgtrofi 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
@reckenrode:matrix.orgRandy Eckenrode

In case a sysroot prefix is configured, and the filename starts with the ‘/’ character, and the script being processed was located inside the sysroot prefix, the filename will be looked for in the sysroot prefix. The sysroot prefix can also be forced by specifying = as the first character in the filename path, or prefixing the filename path with $SYSROOT.

22:23:06
@reckenrode:matrix.orgRandy EckenrodeThat hurts my brain to parse.22:23:42
@trofi:matrix.orgtrofi If a linker script is in sysroot directory and /foo paths will work like =/foo paths :) 22:24:09
@trofi:matrix.orgtrofi * If a linker script is in sysroot directory then any /foo paths will work like =/foo paths :) 22:24:23
@emilazy:matrix.orgemilyso you're saying we just need to put a linker script in there? :)22:25:03
@reckenrode:matrix.orgRandy Eckenrode

I think this is what I wanted.

Add path searchdir to the list of paths that ld will search for archive libraries and ld control scripts. You may use this option any number of times. The directories are searched in the order in which they are specified on the command line. Directories specified on the command line are searched before the default directories. All -L options apply to all -l options, regardless of the order in which the options appear. -L options do not affect how ld searches for a linker script unless -T option is specified.

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
@emilazy:matrix.orgemilyoh, only for things the linker script references.22:25:27
@reckenrode:matrix.orgRandy Eckenrode *

I think this is what I wanted.

Add path searchdir to the list of paths that ld will search for archive libraries and ld control scripts. You may use this option any number of times. The directories are searched in the order in which they are specified on the command line. Directories specified on the command line are searched before the default directories. All -L options apply to all -l options, regardless of the order in which the options appear. -L options do not affect how ld searches for a linker script unless -T option is specified.

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:34
@reckenrode:matrix.orgRandy Eckenrode

binutils’s ld interprets -L/usr/lib as /usr/lib always. ld64 does not. What does lld do?

22:25:58
@emilazy:matrix.orgemilyI wonder if this stuff is conditioned based on host or target platform 🙃22:25:59
@emilazy:matrix.orgemily(for e.g. Clang)22:26:15
@emilazy:matrix.orgemily (uh, -I is definitely interpreted relative to $SDKROOT with Clang on Darwin, right?) 22:26:42
@reckenrode:matrix.orgRandy EckenrodeYes.22:27:23
@reckenrode:matrix.orgRandy EckenrodeI’m pretty sure.22:27:43
@emilazy:matrix.orgemilyit 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
@emilazy:matrix.orgemilydon't ever say Darwin support does nothing for Nixpkgs!22:27:59
@artturin:matrix.orgArtturinhttps://github.com/NixOS/nixpkgs/pull/35176822:48:34

Show newer messages


Back to Room ListRoom Version: 9