arduino / toolchain-avr

The AVR toolchain used by the Arduino IDE
142 stars 48 forks source link

Doesn't work on non-FHS systems #87

Open balsoft opened 4 years ago

balsoft commented 4 years ago

Bug Report

Current behavior

$ arduino-cli compile --fqbn arduino:avr:nano AnalogSensors/AnalogSensors.ino 
Error during build: build failed: fork/exec /home/balsoft/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-g++: no such file or directory

The build fails because the toolchain (downloaded to ~/.arduino15/packages) has /lib/ld-linux-x86-64.so.2 set as interpreter. While it might work on FHS systems, it doesn't work on mine. I can solve this by patching the executables (for i in $(find /home/balsoft/.arduino15 -t file); do patchelf --set-interpreter /nix/store/xlxiw4rnxx2dksa91fizjzf7jb5nqghc-glibc-2.27/lib/ld-linux-x86-64.so.2 $i; done) but it is a flimsy solution and won't work long-term (it'll break after the next glibc update and garbage collection).

Expected behavior

It works out of the box, independent of the location of ld-linux-x86-64.so.2. This can be achieved by building the toolchain statically.

Environment

Additional context

I'm not sure this should be reported here. If it isn't, please close the issue and redirect me to the correct place.

facchinm commented 4 years ago

Mmmh the toolchain is being built as statically as possible (for glibc), we could try compiling against musl in the future to solve this but it's not very high priority :slightly_smiling_face:

balsoft commented 4 years ago

To fix my problem, we need to link the toolchain with --no-dynamic-linker which should work on all platforms that support binfmt (so all of them).

ericonr commented 4 years ago

Hi there! Do you think it would be possible instead to build musl variants and have arduino-cli auto detect the platform? Void Linux ships arduino-cli in its musl variant, but has to resort to gcompat in order to run the AVR compiler, and quite a few more hacks to run the SAM one. I recently dealt with this here https://github.com/void-linux/void-packages/issues/22616#issuecomment-639968663

Where can I find the build configuration, if I were to try and help with it?

balsoft commented 4 years ago

@ericonr https://github.com/balsoft/nur-packages/blob/master/pkgs/arduino-cli/default.nix is the package description. deps.nix is generated from go.sum or go.mod, don't remember which one.

per1234 commented 2 years ago

Someone with write permission in the arduino/toolchain-avr repo (@facchinm, @cmaglie, ...), please transfer the issue over there. The issue doesn't seem to be anything that can be resolved by changing the Arduino CLI code base.

SpenceKonde commented 2 years ago

I saw this in my email, a growing sense of terror and dread,. as I saw owrds I firast assumed weretypos having never seen them before were repeated by multiple peop[le.

It was such a relief to find that it's not my problem yet. Whatever this problem is, may the technology gods have mercy on their soul.