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: rename to avrgcc-unwrapped; add wrappers #48278

Closed
wants to merge 4 commits into from

Conversation

acowley
Copy link
Contributor

@acowley acowley commented Oct 12, 2018

The wrappers supply flags so that avr-gcc and avr-g++ can
find necessary headers and libraries.

Fixes #48205

Motivation for this change

As currently defined, it is not obvious how to use the avgcc compilers.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option 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/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

The wrappers supply flags so that avr-gcc and avr-g++ can
find necessary headers and libraries.

Fixes NixOS#48205
version = stdenv.lib.strings.getVersion avrgcc-unwrapped.name;
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ avrgcc-unwrapped avrlibc ];
builder = writeText "builder.sh" ''

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified by using buildCommand (see #48205 (comment))

@@ -7872,11 +7872,13 @@ with pkgs;

avrgcclibc = throw "avrgcclibs are now separate packages, install avrbinutils, avrgcc and avrlibc";

avrbinutils = callPackage ../development/misc/avr/binutils {};
avrbinutils = callPackage ../development/misc/avr/binutils {};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whenever multiple defs are aligned with extra spaces before the = in all-packages.nix, the defs are also formatted as a paragraph without extra newlines. So either remove the spaces or also remove the newlines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code I was replacing had this alignment, so I thought it'd be neighborly and preserve it. I've taken it out now as it didn't really help the aesthetics very much to begin with.

@matthewbauer
Copy link
Member

👎 from me on this. We want everyone to use the cc-wrapper for cross compilation. It should be possible to do something like:

nix-build '<nixpkgs>' -A hello --arg crossSystem '{ config = "avr"; }'

That way we can cross compile the entire Nixpkgs.

@gesturbjarkason
Copy link

gesturbjarkason commented Oct 12, 2018

@matthewbauer, what would you recommend then for simple AVR use cases as described in #48205?
Should the user always have to manually import avrlibc?

source $stdenv/setup
mkdir -p $out/bin $out/lib
buildCommand = ''
mkdir -p $out/bin $out

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extra $out is not needed. (But a bit of extra pedantry never hurts 😉)

@acowley
Copy link
Contributor Author

acowley commented Oct 12, 2018

I started out trying to do this with cc-wrapper, but it was proving non-trivial while the typical usage with this target is pretty trivial.

We can leave this hard-to-use until someone writes a cc-wrapper solution if that's what people prefer.

ETA:

I should expand a bit. cc-wrapper has things like these asserts that weren't obvious to me how to get around for this tool chain.

@matthewbauer
Copy link
Member

I've opened #48286 as an alternative. Still waiting for it to build but if we can get that to work I would prefer to use it. avr* stuff has been on my list of things to replace:

#39087

@acowley
Copy link
Contributor Author

acowley commented Oct 12, 2018

That looks terrific @matthewbauer !

@acowley acowley closed this Oct 12, 2018
@gesturbjarkason
Copy link

Thanks @acowley for your initial draft!

@acowley acowley deleted the avr-gcc-wrapper branch January 27, 2019 19:09
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

4 participants