Skip to content

Instantly share code, notes, and snippets.

@guibou
Last active November 22, 2018 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guibou/75fb1a138220b779fdadc8db0d0ad019 to your computer and use it in GitHub Desktop.
Save guibou/75fb1a138220b779fdadc8db0d0ad019 to your computer and use it in GitHub Desktop.
`foo` builds with `gcc-arm-embedded` but `bar` does not, with `pkgsCross.arm-embedded`.
let
nixos1809 = import (fetchTarball channel:nixos-18.09) {};
file = nixos1809.writeTextFile {
name = "file.c";
text = ''
#include <math.h>
int _exit(int i){};
int main()
{
float v = log(0.f);
return 0;
}
'';
};
cmd = ''arm-none-eabi-gcc -mfloat-abi=hard ${file} -o file -lm -o $out'';
overlay = self : super : {
/*
# I Tried to override newlibCross with hardware floating point, but without success
newlibCross = super.newlibCross.overrideAttrs (old : {
configureFlags = old.configureFlags ++ ["--enable-newlib-hw-fp"];
});
*/
};
in
{
# That one will work
foo = with nixos1809;
runCommand "foo" {
allowSubstitutes = false;
buildInputs = [gcc-arm-embedded];
}
cmd;
# That one fails with
# error: /build/ccgJg8Xr.o uses VFP register arguments...
bar = with import (fetchTarball channel:nixpkgs-unstable) {overlays = [overlay];};
runCommand "bar" {
buildInputs = [pkgsCross.arm-embedded.buildPackages.gcc];
}
cmd;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment