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
Bintools Wrapper: Init by refactoring out of cc-wrapper, take 2 #29396
Conversation
# TODO(@Ericson2314): Remove this after stable release and force | ||
# everyone to refer to binutils-wrapper directly. | ||
if [[ -f "$binutils/nix-support/dynamic-linker" ]]; then | ||
ln -s "$binutils/nix-support/dynamic-linker" "$out/nix-support" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edolstra this symlink avoids the incompatibility the old version introduced.
d8c0c7e
to
d753d4c
Compare
# Choose 32-bit dynamic linker if needed | ||
if [ -e @out@/nix-support/dynamic-linker-m32 ]; then | ||
prev= | ||
for p in ${params+"${params[@]}"}; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was determined to be valuable not to iterate over params more times than necessary. Could you merge this loop into the next one? (It has already merged two cases, [ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ]
and [ "$NIX_@infixSalt@_SET_BUILD_ID" = 1 ]
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
beb7de1
to
f1a1ac2
Compare
if [ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ] || [ "$NIX_@infixSalt@_SET_BUILD_ID" = 1 ]; then | ||
# Two tasks: | ||
# | ||
# 1. Find all -L... switches for rpath, and relocatable flags for build id. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These cases are not related, so if you enumerate the cases, these should be 1 and 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Good catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
case $depOffset in | ||
-1) local role='BUILD_' ;; | ||
0) local role='' ;; | ||
1) local role='TARGET_' ;; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where may depOffset
be set to 1? I find only places where it is set to -1 or 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh heh. That would anticipate #26805
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cc-wrapper already has that, I guess I'll leave it as consistent anticipation.
f1a1ac2
to
d9a2380
Compare
3dbb0a3
to
621ae3d
Compare
doc/stdenv.xml
Outdated
CC wrapper's setup hook causes any <filename>include</filename> subdirectory of such a dependency to be added to <envar>NIX_CFLAGS_COMPILE</envar>, and any <filename>lib</filename> and <filename>lib64</filename> subdirectories to <envar>NIX_LDFLAGS</envar>. | ||
The setup hook itself contains some lengthy comments describing the exact convoluted mechanism by which this is accomplished. | ||
Binutils Wrapper's setup hook causes any <filename>lib</filename> and <filename>lib64</filename> subdirectories to <envar>NIX_LDFLAGS</envar>. | ||
Sine CC Wrapper and Binutils Wrapper use the same strategy, most of the Binutils Wrapper code is sparsely commented and refers to CC Wrapper. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Sine" is a typo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
doc/stdenv.xml
Outdated
It is currently accomplished by collecting directories of host-platform dependencies (i.e. <varname>buildInputs</varname> and <varname>nativeBuildInputs</varname>) in environment variables. | ||
CC wrapper's setup hook causes any <filename>include</filename> subdirectory of such a dependency to be added to <envar>NIX_CFLAGS_COMPILE</envar>, and any <filename>lib</filename> and <filename>lib64</filename> subdirectories to <envar>NIX_LDFLAGS</envar>. | ||
The setup hook itself contains some lengthy comments describing the exact convoluted mechanism by which this is accomplished. | ||
Binutils Wrapper's setup hook causes any <filename>lib</filename> and <filename>lib64</filename> subdirectories to <envar>NIX_LDFLAGS</envar>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably you're missing the words "be added to" in this sentence.
doc/stdenv.xml
Outdated
Firstly, this helps poorly-written packages, e.g. ones that look for just <command>gcc</command> when <envar>CC</envar> isn't defined yet <command>clang</command> is to be used. | ||
Secondly, this helps packages not get confused when cross-compiling, in which case multiple CC wrappers may be simultaneous in use (targeting different platforms). | ||
<envar>BUILD_</envar>- and <envar>TARGET_</envar>-prefixed versions of the normal environment variable are defined for the additional CC Wrappers, properly disambiguating them. | ||
Secondly, this helps packages not get confused when cross-compiling, in which case multiple Binutils Wrappers may be simultaneous in use (targeting different platforms). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idomatic wording options would be:
- "may be in use simultaneously", or
- "may be in simultaneous use"
doc/stdenv.xml
Outdated
</para> | ||
<para> | ||
Dependency finding is undoubtedly the main task of CC Wrapper. | ||
This works just like Binutils Wrapper, except the any <filename>include</filename> subdirectory of any relevant dependency is added to <envar>NIX_CFLAGS_COMPILE</envar>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"the" should be "that"
doc/stdenv.xml
Outdated
Most packages, however, firstly use the C compiler for linking, secondly use <envar>LD</envar> anyways, defining it as the C compiler, and thirdly, only so define <envar>LD</envar> when it is undefined as a fallback. | ||
This triple-threat means CC Wrapper will break those packages, as LD is already defined as the actually linker which the package won't override yet doesn't want to use. | ||
This triple-threat means Binutils Wrapper will break those packages, as LD is already defined as the actually linker which the package won't override yet doesn't want to use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"actually" is not an adjective, probably you meant "actual".
621ae3d
to
49e0ad4
Compare
This avoids any `NIX_FOOBAR=1 1` not triggering conditions.
It means stdin, and is morally equivalent to passing a file. e.g. $ echo 'int main(void) { return 0; }' | gcc -x c - will compile and link a binary.
Factor a bintools (i.e. binutils / cctools) wrapper out of cc-wrapper. While only LD is wrapped, the setup hook defines environment variables on behalf of other utilites.
Shrunk the CC Wrapper documentation so as not to be repetative.
This is more robust for cross-compilation
Also make the code more precise in the process
These will be installed if the wrappers are. The wrappers aren't very good to install, but that's another matter.
Will need to be editted again to work for cross
d816053
to
84fb59e
Compare
@edolstra told me he doesn't have time to review this any time soon, so we might as well not hold it up further. Yay, thanks! This has passed nixborg CI many times before. the last change is a mass rebuild, but just from merging with staging. The post-merge change is just an eval fix for a newer package (clang multilib). Merging, but will keep an I on staging just in case. |
This broke |
This broke
|
Two perl packages, It seems that |
Can't fix this instant, but the crux of the Perl packages' problem is that |
after NixOS#29396 removed `-L path/to/dir/of/libstdc++.so` from ld flags See NixOS#29396 (comment) Module::Build build helper works correctly when LD is unset (taking LD from Perl config to be `cc`). However, we can not unset LD because this goes contrary to the cross compilation effort, and we can not make it propagate ld-is-cc-hook because it breaks e.g. the build of `libguestfs`. However, NixOS#29396 makes LD=ld incompatible with just 3 perl packages; they are individually fixed by this commit.
Thanks! I'm fixing perl packages in #32830. |
Hm. I don't really understand where |
edit see my question in #29396 (comment)
Motivation for this change
This is meant to be reviewed commit by commit.
This is needed so packages that just use binutils get the same setup-hook support. That is, variables like
BUILD_AS
orLD
should be defined the same way, along with theLD_FLAGS
. This will be necessary to clean up at least the gcc derivation (which must be built with an binutils not associated with any existsing C compiler when target != host), and probably other compilers too.More broadly, having two wrappers will help enforce proper layering between binutils and the C compiler. For languages besides C/C++, it would be neat to use `stdenvNoCC + binutils, avoiding a C compiler dependency. This wrapper makes that change possible.
@edolstra I'm hoping for you to merge this change when you approve of it, to avoid a repeat of last time.
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)