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

Linker fails on avr-gcc 8.4 & 9.3 #182

Closed
fauxpark opened this issue Mar 23, 2020 · 18 comments
Closed

Linker fails on avr-gcc 8.4 & 9.3 #182

fauxpark opened this issue Mar 23, 2020 · 18 comments
Labels

Comments

@fauxpark
Copy link
Contributor

After updating to 8.4, avr-ld produces this error:

 | 
 | /usr/local/opt/avr-binutils/bin/avr-ld: cannot find crtatmega32u4.o: No such file or directory
 | /usr/local/opt/avr-binutils/bin/avr-ld: cannot find -latmega32u4
 | collect2: error: ld returned 1 exit status
 | 

and when building for AT90USB1286:

 | 
 | /usr/local/opt/avr-binutils/bin/avr-ld: cannot find crtat90usb1286.o: No such file or directory
 | /usr/local/opt/avr-binutils/bin/avr-ld: skipping incompatible /usr/local/Cellar/avr-gcc@8/8.4.0/lib/avr-gcc/8/gcc/avr/8.4.0/../../../../../../avr/lib/libm.a when searching for -lm
 | /usr/local/opt/avr-binutils/bin/avr-ld: cannot find -lm
 | /usr/local/opt/avr-binutils/bin/avr-ld: skipping incompatible /usr/local/Cellar/avr-gcc@8/8.4.0/lib/avr-gcc/8/gcc/avr/8.4.0/libgcc.a when searching for -lgcc
 | /usr/local/opt/avr-binutils/bin/avr-ld: cannot find -lgcc
 | /usr/local/opt/avr-binutils/bin/avr-ld: skipping incompatible /usr/local/Cellar/avr-gcc@8/8.4.0/lib/avr-gcc/8/gcc/avr/8.4.0/../../../../../../avr/lib/libm.a when searching for -lm
 | /usr/local/opt/avr-binutils/bin/avr-ld: cannot find -lm
 | /usr/local/opt/avr-binutils/bin/avr-ld: skipping incompatible /usr/local/Cellar/avr-gcc@8/8.4.0/lib/avr-gcc/8/gcc/avr/8.4.0/../../../../../../avr/lib/libc.a when searching for -lc
 | /usr/local/opt/avr-binutils/bin/avr-ld: cannot find -lc
 | /usr/local/opt/avr-binutils/bin/avr-ld: cannot find -lat90usb1286
 | collect2: error: ld returned 1 exit status
 | 
@ladislas
Copy link
Member

Yes, I've got the same issue, I'm investigating.

@ladislas ladislas added the bug label Mar 23, 2020
@ladislas ladislas changed the title Linker fails on avr-gcc 8.4 Linker fails on avr-gcc 8.4 & 9.3 Mar 23, 2020
@ladislas
Copy link
Member

I've found the issue, it was the --disable-multilib option. I'll push a fix asap.

ladislas added a commit that referenced this issue Mar 24, 2020
…182

Closes #185.

Signed-off-by: Ladislas de Toldi <ladislas@detoldi.me>
@fauxpark
Copy link
Contributor Author

Building succeeds again with the new bottles now - thanks for your hard work @ladislas :)

ladislas added a commit that referenced this issue Mar 24, 2020
Closes #184.

Signed-off-by: Ladislas de Toldi <ladislas@detoldi.me>
@matsutakehoyo
Copy link

matsutakehoyo commented Mar 25, 2020

@fauxpark How did you install with the new bottles? I tried reinstalling but I think it's just installing the same thing

edit: never mind I think I erased the cashe and then it worked.

@myraz
Copy link

myraz commented Mar 29, 2020

@matsutakehoyo I think i have the same problem. May I ask you how you erased your cashe?

@matsutakehoyo
Copy link

@myraz when I tried to reinstall I got a prompt saying something like

Reinstalling air-gcc@8 
==> Downloading https://homebrew...
Already downloaded: ... bottle.tar.gz

I just when to the directory that Already downloaded points to, found the downloaded file and manually deleted it. I think brew cleanup is supposed to remove these files, but on mine it is not.

Hope this helps

@ladislas
Copy link
Member

@myraz

brew uninstall avg-gcc OR avr-gcc@8
brew cleanup -s
brew install avr-gcc

@myraz
Copy link

myraz commented Mar 30, 2020

@matsutakehoyo @ladislas . Thank you very much for the quick help! At first it did not work but after unlinking my old avr-gcc and relinking, it now works!

brew unlink avr-gcc@8
brew link avr-gcc

@ladislas
Copy link
Member

Yes, you cannot have two different versions of gcc linked at the same time.

avr-gcc will by default me linked and available in path. If you want another version linked, you must unlink the main one and manually link a @x version.

@metropt
Copy link

metropt commented Apr 22, 2020

I tried the above suggestions but I got no success compiling.

ze-mac:Downloads ze$ avr-gcc -mmcu=attiny202 -B ~/Downloads/Atmel.ATtiny_DFP.1.4.310/gcc/dev/attiny202 main.c -I ~/Downloads/Atmel.ATtiny_DFP.1.4.310/include/
In file included from main.c:30:
/usr/local/Cellar/avr-gcc/9.3.0/avr/include/util/delay.h:112:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed" [-Wcpp]
  112 | # warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed"
      |   ^~~~~~~
/usr/local/opt/avr-binutils/bin/avr-ld: skipping incompatible /usr/local/Cellar/avr-gcc/9.3.0/lib/avr-gcc/9/gcc/avr/9.3.0/../../../../../../avr/lib/libm.a when searching for -lm
/usr/local/opt/avr-binutils/bin/avr-ld: cannot find -lm
/usr/local/opt/avr-binutils/bin/avr-ld: skipping incompatible /usr/local/Cellar/avr-gcc/9.3.0/lib/avr-gcc/9/gcc/avr/9.3.0/../../../../../../avr/lib/libc.a when searching for -lc
/usr/local/opt/avr-binutils/bin/avr-ld: cannot find -lc
collect2: error: ld returned 1 exit status
ze-mac:Downloads ze$ avr-gcc -v
Using built-in specs.
Reading specs from /usr/local/Cellar/avr-gcc/9.3.0/lib/avr-gcc/9/gcc/avr/9.3.0/device-specs/specs-avr2
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/usr/local/Cellar/avr-gcc/9.3.0/libexec/gcc/avr/9.3.0/lto-wrapper
Target: avr
Configured with: ../configure --target=avr --prefix=/usr/local/Cellar/avr-gcc/9.3.0 --libdir=/usr/local/Cellar/avr-gcc/9.3.0/lib/avr-gcc/9 --enable-languages=c,c++ --with-ld=/usr/local/opt/avr-binutils/bin/avr-ld --with-as=/usr/local/opt/avr-binutils/bin/avr-as --disable-nls --disable-libssp --disable-shared --disable-threads --disable-libgomp --with-dwarf2 --with-avrlibc --with-pkgversion='Homebrew AVR GCC 9.3.0' --with-bugurl=https://github.com/osx-cross/homebrew-avr/issues
Thread model: single
gcc version 9.3.0 (Homebrew AVR GCC 9.3.0)

@ladislas
Copy link
Member

@metropt have you tried brew remove avr-gcc and then brew install avr-gcc?

@metropt
Copy link

metropt commented Apr 22, 2020

@ladislas uninstall and install didn't solve but remove and install solve the problem hmm

@benwoodward
Copy link

benwoodward commented Jan 12, 2021

I've tried all of the above and still experiencing this issue.

❯ qmk setup benwoodward/qmk_firmware -b apple_fn_k320
Ψ Found qmk_firmware at /Users/ben/qmk_firmware.
Ψ QMK Doctor is checking your environment.
Ψ Detected macOS.
Ψ QMK home: /Users/ben/qmk_firmware
Ψ All dependencies are installed.
Ψ Found arm-none-eabi-gcc version 8.3.1
Ψ Found avr-gcc version 8.4.0
Ψ Found avrdude version 6.3
Ψ Found dfu-util version 0.10
Ψ Found dfu-programmer version 0.7.2
Ψ Submodules are up to date.
Ψ QMK is ready to go
❯ qmk compile -kb kbdfans/kbd75/rev2 -km default
Ψ Compiling keymap with make kbdfans/kbd75/rev2:default


QMK Firmware 0.11.43
Making kbdfans/kbd75/rev2 with keymap default

avr-gcc (Homebrew AVR GCC 8.4.0) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Linking: .build/kbdfans_kbd75_rev2_default.elf                                                      [ERRORS]
 |
 | /usr/local/opt/avr-binutils/bin/avr-ld: cannot find crtatmega32u4.o: No such file or directory
 | /usr/local/opt/avr-binutils/bin/avr-ld: cannot find -latmega32u4
 | collect2: error: ld returned 1 exit status
 |
make[1]: *** [.build/kbdfans_kbd75_rev2_default.elf] Error 1
make: *** [kbdfans/kbd75/rev2:default] Error 1
Make finished with errors

EDIT: Looks like the issue is perhaps because the --disable-multilib line was re-added in 16cfb08#diff-e2671d3010d865efd9551cdb61636f7ebdb9a9d698330e0294948d02e776ac61R89

EDIT: My workaround was to install avr-gcc using previous version of the formula:

brew remove avr-gcc@8
wget https://raw.githubusercontent.com/osx-cross/homebrew-avr/3f86697315aad66d6213e158e0c0af88dd6c241f/Formula/avr-gcc%408.rb
brew install avr-gcc@8.rb
brew link --overwrite --force avr-gcc@8

EDIT: Made a PR to reapply the fix: #206

EDIT: Actually, I'm still experiencing the error 😞

EDIT: OK, It does work, I just needed to remove avr-binutils first, which is obvious now because that was the binary throwing an error.

So the full list of steps (if you have the same problem):

brew uninstall --ignore-dependencies avr-binutils
brew uninstall --ignore-dependencies avr-gcc@8
wget https://raw.githubusercontent.com/osx-cross/homebrew-avr/3f86697315aad66d6213e158e0c0af88dd6c241f/Formula/avr-gcc%408.rb
brew install avr-gcc@8.rb
brew link --overwrite --force avr-gcc@8

benwoodward added a commit to benwoodward/homebrew-avr that referenced this issue Jan 12, 2021
@ladislas
Copy link
Member

yes, sorry for that! while working on the new bottle system, I took the opportunity to update the formula and follow what brew/core does. That's how I reintroduced the multilib thing...

it will soon be fixed.

@w-A-L-L-e
Copy link

w-A-L-L-e commented Jan 12, 2021

Just as note both v9 and avr-gcc@10 have this problem:

/usr/local/opt/avr-binutils/bin/avr-ld: cannot find crtatmega32u4.o: No such file or directory
/usr/local/opt/avr-binutils/bin/avr-ld: cannot find -latmega32u4

I'm now trying this workaround:

brew remove avr-gcc@8
brew uninstall avr-gcc
brew uninstall avr-binutils
wget https://raw.githubusercontent.com/osx-cross/homebrew-avr/3f86697315aad66d6213e158e0c0af88dd6c241f/Formula/avr-gcc%408.rb
brew install avr-gcc@8.rb
brew link --overwrite --force avr-gcc@8

@ladislas
Copy link
Member

This is fixed! 🎉 you can brew remove and brew install avr-gcc@8 again :)

@w-A-L-L-e
Copy link

Good to know, for now the workaround worked for me and it takes a long time to recompile here so I'm leaving it. Any ideas when avr-gcc v9 and @10 will also get this fix?

@ladislas
Copy link
Member

everything is fixed, you need to brew update && brew upgrade first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment