Skip to content
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

avrgcc: bake path to avr-ar into avr-gcc-ar #33762

Merged
merged 1 commit into from Jan 12, 2018

Conversation

kierdavis
Copy link
Contributor

@kierdavis kierdavis commented Jan 12, 2018

(tl;dr: this fixes a bug in avrgcc that's present in master and in the current release)

gcc provides wrappers for binutils' ar, nm and ranlib
executables, which must be used instead when using link-time
optimisation. See also:
http://manpages.ubuntu.com/manpages/zesty/man1/aarch64-linux-gnu-gcc-ar-5.1.html

The upstream version of avr-gcc-ar searches in paths passed to
the configure script for the avr-ar binary that it wraps, falling
back to searching PATH instead. Thus currently avr-gcc-ar works on
Nix, but only if avrbinutils is already in the environment.

This change bakes the path to avr-ar into avr-gcc-ar, since its path
is known at compile time. It also no longer searches PATH, meaning the
user's local environment won't override this path.

Note that avr-gcc-nm and avr-gcc-ranlib are compiled from the same
source file as avr-gcc-ar, just with different compiler flags.

Testing on master (without avrbinutils in the environment):

$ nix-build -A avrgcc
$ result/bin/avr-gcc-ar --version
result/bin/avr-gcc-ar: Cannot find binary 'avr-ar'

Testing on branch with this fix:

$ nix-build -A avrgcc
$ result/bin/avr-gcc-ar --version
GNU ar (GNU Binutils) 2.26.20160125
...
Motivation for this change

avr-gcc-ar shouldn't require any particular package to be present in the user's environment when it is run.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

cc package maintainer @mguentner

gcc provides wrappers for binutils' ar, nm and ranlib
executables, which must be used instead when using link-time
optimisation. See also:
http://manpages.ubuntu.com/manpages/zesty/man1/aarch64-linux-gnu-gcc-ar-5.1.html

The upstream version of avr-gcc-ar searches in paths passed to
the configure script for the avr-ar binary that it wraps, falling
back to searching PATH instead. Thus currently avr-gcc-ar works on
Nix, but only if avrbinutils is already in the environment.

This change bakes the path to avr-ar into avr-gcc-ar, since its path
is known at compile time. It also no longer searches PATH, meaning the
user's local environment won't override this path.

Note that avr-gcc-nm and avr-gcc-ranlib are compiled from the same
source file as avr-gcc-ar, just with different compiler flags.

Testing on master (without avrbinutils in the environment):

    $ nix-build -A avrgcc
    $ result/bin/avr-gcc-ar --version
    result/bin/avr-gcc-ar: Cannot find binary 'avr-ar'

Testing on branch with this fix:

    $ nix-build -A avrgcc
    $ result/bin/avr-gcc-ar --version
    GNU ar (GNU Binutils) 2.26.20160125
    ...
@Mic92
Copy link
Member

Mic92 commented Jan 12, 2018

Is this also broken on 17.09?

@kierdavis
Copy link
Contributor Author

kierdavis commented Jan 12, 2018 via email

@Mic92
Copy link
Member

Mic92 commented Jan 12, 2018

back ported in 412ad94

@kierdavis
Copy link
Contributor Author

Thanks 👍

@kierdavis kierdavis deleted the fix-avr-gcc-ar branch January 12, 2018 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants