NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.35k stars 14.31k forks source link

`pkgsCross.avr.stdenv.cc` doesn't work with `-mmcu=attiny2313a` #334906

Open Artturin opened 3 months ago

Artturin commented 3 months ago
#include <avr/sleep.h>

int main()
{
    sleep_mode();
}

Fails nix shell ".#pkgsCross.avr.stdenv.cc" --command avr-gcc -mmcu=attiny2313a main.c

Doesn't fail nix shell ".#pkgsCross.avr.stdenv.cc" --command avr-gcc -mmcu=atmega8 main.c

https://github.com/NixOS/nixpkgs/pull/220442 fixed this it but was reverted

Artturin commented 3 months ago

Adding the new(?) directories in avr/lib to bintools and cc wrappers doesn't fix the issue

diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix
index 6e97d0cf00fa..2a38564491a2 100644
--- a/pkgs/build-support/bintools-wrapper/default.nix
+++ b/pkgs/build-support/bintools-wrapper/default.nix
@@ -343,7 +343,7 @@ stdenvNoCC.mkDerivation {
     ''

     + optionalString (libc != null && targetPlatform.isAvr) ''
-      for isa in avr5 avr3 avr4 avr6 avr25 avr31 avr35 avr51 avrxmega2 avrxmega4 avrxmega5 avrxmega6 avrxmega7 tiny-stack; do
+      for isa in avr25 avr31 avr4 avr51 avrtiny avrxmega3 avrxmega5 avrxmega7 long-double32 avr3 avr35 avr5 avr6 avrxmega2 avrxmega4 avrxmega6 double64 tiny-stack; do
         echo "-L${getLib libc}/avr/lib/$isa" >> $out/nix-support/libc-cflags
       done
     ''
diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix
index d842f3fc7090..2995a2064bac 100644
--- a/pkgs/build-support/cc-wrapper/default.nix
+++ b/pkgs/build-support/cc-wrapper/default.nix
@@ -668,7 +668,7 @@ stdenvNoCC.mkDerivation {
     ''

     + optionalString (libc != null && targetPlatform.isAvr) ''
-      for isa in avr5 avr3 avr4 avr6 avr25 avr31 avr35 avr51 avrxmega2 avrxmega4 avrxmega5 avrxmega6 avrxmega7 tiny-stack; do
+      for isa in avr25 avr31 avr4 avr51 avrtiny avrxmega3 avrxmega5 avrxmega7 long-double32 avr3 avr35 avr5 avr6 avrxmega2 avrxmega4 avrxmega6 double64 tiny-stack; do
         echo "-B${getLib libc}/avr/lib/$isa" >> $out/nix-support/libc-crt1-cflags
       done
     ''
diff --git a/pkgs/development/misc/avr/libc/default.nix b/pkgs/development/misc/avr/libc/default.nix
index c2b35ed72204..b78a5eb13953 100644
--- a/pkgs/development/misc/avr/libc/default.nix
+++ b/pkgs/development/misc/avr/libc/default.nix
@@ -20,6 +20,7 @@ stdenv.mkDerivation rec {

   passthru = {
     incdir = "/avr/include";
+    libdir = "/avr/lib";
   };

   meta = with lib; {

Adding libdir to avrlibc fixes the issue but the lines in the bintools and cc wrappers can't be removed because it breaks simavr

EDIT: Actually, simply adding libdir breaks simavr?