Skip to content

Commit

Permalink
systems/parse.nix: support eabihf
Browse files Browse the repository at this point in the history
eabihf is an abi that can be used with ARM architectures that support
the “hard float”. It should probably only be used with ARM32 when you
are absolutely sure your binaries will run on ARM systems with a FPU.

Also, add an example "armhf-embedded" to match the preexisting
arm-embedded system. qmk_firmware needs hard float in a few places, so
add them here to get that to work.

Fixes #51184
  • Loading branch information
matthewbauer committed Dec 3, 2018
1 parent 808f058 commit 3b32c92
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
4 changes: 4 additions & 0 deletions lib/systems/examples.nix
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ rec {
config = "arm-none-eabi";
libc = "newlib";
};
armhf-embedded = {
config = "arm-none-eabihf";
libc = "newlib";
};

aarch64-embedded = {
config = "aarch64-none-elf";
Expand Down
23 changes: 13 additions & 10 deletions lib/systems/parse.nix
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,15 @@ rec {
abis = setTypes types.openAbi {
cygnus = {};
msvc = {};
eabi = {};
elf = {};

# Note: eabi is specific to ARM and PowerPC.
# On PowerPC, this corresponds to PPCEABI.
# On ARM, this corresponds to ARMEABI.
eabi = { float = "soft"; };
eabihf = { float = "hard"; };

# Other architectures should use ELF in embedded situations.
elf = {};

androideabi = {};
android = {
Expand Down Expand Up @@ -272,10 +279,8 @@ rec {
"2" = # We only do 2-part hacks for things Nix already supports
if elemAt l 1 == "cygwin"
then { cpu = elemAt l 0; kernel = "windows"; abi = "cygnus"; }
else if (elemAt l 1 == "eabi")
then { cpu = elemAt l 0; vendor = "none"; kernel = "none"; abi = elemAt l 1; }
else if (elemAt l 1 == "elf")
then { cpu = elemAt l 0; vendor = "none"; kernel = "none"; abi = elemAt l 1; }
else if (elemAt l 1) == "elf"
then { cpu = elemAt l 0; vendor = "unknown"; kernel = "none"; abi = elemAt l 1; }
else { cpu = elemAt l 0; kernel = elemAt l 1; };
"3" = # Awkwards hacks, beware!
if elemAt l 1 == "apple"
Expand All @@ -286,10 +291,8 @@ rec {
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "windows"; abi = "gnu"; }
else if hasPrefix "netbsd" (elemAt l 2)
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; }
else if (elemAt l 2 == "eabi")
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "none"; abi = elemAt l 2; }
else if (elemAt l 2 == "elf")
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "none"; abi = elemAt l 2; }
else if (elem (elemAt l 2) ["eabi" "eabihf" "elf"])
then { cpu = elemAt l 0; vendor = "unknown"; kernel = elemAt l 1; abi = elemAt l 2; }
else throw "Target specification with 3 components is ambiguous";
"4" = { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; abi = elemAt l 3; };
}.${toString (length l)}
Expand Down
13 changes: 12 additions & 1 deletion pkgs/development/misc/qmk_firmware/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ stdenv, fetchFromGitHub
, avrgcc, avrbinutils
, gcc-arm-embedded, binutils-arm-embedded
, gcc-arm-embedded, gcc-armhf-embedded
, teensy-loader-cli, dfu-programmer, dfu-util }:

let version = "0.6.144";
Expand All @@ -14,12 +14,23 @@ in stdenv.mkDerivation {
sha256 = "0m71f9w32ksqjkrwhqwhr74q5v3pr38bihjyb9ks0k5id0inhrjn";
fetchSubmodules = true;
};
postPatch = ''
substituteInPlace tmk_core/arm_atsam.mk \
--replace arm-none-eabi arm-none-eabihf
rm keyboards/handwired/frenchdev/rules.mk keyboards/dk60/rules.mk
'';
buildFlags = "all:default";
doCheck = true;
checkTarget = "test:all";
installPhase = ''
mkdir $out
'';
NIX_CFLAGS_COMPILE = "-Wno-error";
nativeBuildInputs = [
avrgcc
avrbinutils
gcc-arm-embedded
gcc-armhf-embedded
teensy-loader-cli
dfu-programmer
dfu-util
Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23027,7 +23027,7 @@ with pkgs;
avrgcc = pkgsCross.avr.buildPackages.gcc;
avrbinutils = pkgsCross.avr.buildPackages.binutils;
gcc-arm-embedded = pkgsCross.arm-embedded.buildPackages.gcc;
binutils-arm-embedded = pkgsCross.arm-embedded.buildPackages.binutils;
gcc-armhf-embedded = pkgsCross.armhf-embedded.buildPackages.gcc;
};

newlib = callPackage ../development/misc/newlib { };
Expand Down

0 comments on commit 3b32c92

Please sign in to comment.