Open andrewchambers opened 4 years ago
As an example of a build script that seemed to have messed with flags, my recent attempt at xterm did this: https://gist.github.com/sogaiu/44fa0f5f056f4d823cc3c29fad8f03de#file-xterm-hpkg-L184_L188
plink.sh
seemed to prune some things that were necessary for a successful compilation. For reference, here's a version of plink.sh
: https://github.com/joejulian/xterm/blob/master/plink.sh
Apparently, nixpkgs also experienced some difficulty: https://github.com/NixOS/nixpkgs/blob/751729914624e57888e85e6e178fc258db004d9a/pkgs/applications/misc/xterm/default.nix#L44_L45
I definitely think the most useful function of such a wrapper is getting the -L flags and the rpath flags through all the deeply nested build scripts unmodified. Then the compiler can just pass -lfoo which is what most build scripts expect.
Perhaps LD_RUN_PATH
could be useful in some cases...though the docs I've seen suggest that it's only checked as long as -rpath
or -rpath-link
are not specified:
- On an ELF system, for native linkers, if the -rpath and -rpath-link options were not used, search the contents of the environment variable "LD_RUN_PATH".
That's from ld(1) on my machine.
One thing that annoys me greatly about nix, is it wraps gcc with a magic shell script to add rpaths. This is implicit and does annoying things like setting -Werror.
I don't want to do this by default, but I can see a use for cases when packages are just poorly written, a wrapped gcc will ensure proper flags are used.
I think we could make a set of helper functions for generating such a 'wrapped' gcc. When added to the front of your $PATH, you will be able to enforce certain link/compile flags.
We should wait until we know more about 'poorly behaved' packages before implementing this though.