OpenSUSE tumbleweed cross-avr toolchain issue

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi ..

For years I develop AVR projects under Linux OpenSuse tumbleweed using code::blocks IDE .. with no flows !..

Lately after some system updates .. The code::blocks fail to build the project !

Seems that avr-ld fails to find a library ..

As I'm not that expert , I can't figure out how to solve such issue ..

 

This is the build log for a test project "Default wizard generated project" which used to build flawless in the past ..

-------------- Build: Release in AVRTest (compiler: GNU GCC Compiler for AVR)---------------

avr-g++  -o Release/AVRTest.elf Release/fuse.o Release/main.o  -mmcu=atmega8 -Wl,-Map=Release/AVRTest.map,--cref  
/usr/lib64/gcc/avr/9/ld: warning: -z relro ignored
/usr/lib64/gcc/avr/9/ld: skipping incompatible /usr/lib64/gcc/avr/9/avr4/libgcc.a when searching for -lgcc
/usr/lib64/gcc/avr/9/ld: skipping incompatible /usr/lib64/gcc/avr/9/libgcc.a when searching for -lgcc
/usr/lib64/gcc/avr/9/ld: cannot find -lgcc
/usr/lib64/gcc/avr/9/ld: skipping incompatible /usr/lib64/gcc/avr/9/avr4/libgcc.a when searching for -lgcc
/usr/lib64/gcc/avr/9/ld: skipping incompatible /usr/lib64/gcc/avr/9/libgcc.a when searching for -lgcc
/usr/lib64/gcc/avr/9/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
3 error(s), 1 warning(s) (0 minute(s), 0 second(s))

 

Thanks in advance ..
 
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When it attempts the -lgcc it will try to link with a libgcc.a. there's actually about 17 or 18 different copies of this in the toolchain built for all the different AVR architectures (for example Tiny don't have MUL while the really big AVr have ELPM and 24 bit CALL/JMP and so on). What the above appears to be saying is that it trying to link the "avr4" version of libgcc.a to the rest of the code you are building but the architecture in the header of the .a and your .o don't match. That can happen, for example, if you pass a different -mmc= to the linker compared to the one passed to the compiler.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your fast replay ..

 

- Is this a code::blocks issue or toolchain's ?

- Could you suggest how to solve this issue ..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the above I see:

 

avr-g++  -o Release/AVRTest.elf Release/fuse.o Release/main.o  -mmcu=atmega8 -Wl,-Map=Release/AVRTest.map,--cref 

 

So was the main.o also built with -mmcu=atmega8 ?

 

The fact is that mega8 is "avr4" architecture. So when you build a .o file you will find:

D:\test\test\Debug>avr-objdump -f main.o

main.o:     file format elf32-avr
architecture: avr:4, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x00000000

It should also be the case that:

C:\One\SysGCC\avr\lib\gcc\avr\5.3.0\avr4>avr-objdump -f libgcc.a
In archive libgcc.a:

_absvhi2.o:     file format elf32-avr
architecture: avr:4, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x00000000


_addvhi3.o:     file format elf32-avr
architecture: avr:4, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x00000000


_subvhi3.o:     file format elf32-avr
architecture: avr:4, flags 0x00000011:
etc.

This libgcc.a can be linked to the main.o I created because these all have "avr:4" in the header which is the "family" into which mega8 falls.

 

but your error:

 

/usr/lib64/gcc/avr/9/ld: skipping incompatible /usr/lib64/gcc/avr/9/avr4/libgcc.a when searching for -lgcc

 

suggests that the header for your copy of libgcc.a does not match the header for the main.o you are building.

 

I'd start by checking that the libgcc.a it mentions there does show "avr:4" for the file headers when you use "avr-objdump -f" on it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

by avr-objdump main.o & /usr/lib64/gcc/avr/9/avr4/libgcc.a, both gives ..

 

architecture: avr:4, flags 0x00000011:
HAS_RELOC, HAS_SYMS

 

It seems both are avr:4

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is odd that the command being invoked appears to be just "ld". The AVR version of ld is called avr-ld so I wonder if that is the problem?

 

If it were me I'd consider getting my avr-gcc (and other tools) from the .tar.gz here:  https://www.microchip.com/mplab/avr-support/avr-and-arm-toolchains-c-compilers

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the link ..

It seems it was a toolchain issue ..

I used "Linux x68-64" from the link you provided ..

It build successfully without even a warning ..

 

I'll check the result on the hardware ..

 

Note:

avr-g++ from the toolchain seems to call the system's gcc, it outputs the same gcc version no. of the system's .

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> It is odd that the command being invoked appears to be just "ld". The AVR version of ld is called avr-ld so I wonder if that is the problem?

 

Using the avr-ld linker directly also yielded the same error, so its very unlikely.

 

I'm also using openSUSE Tumbleweed and encountered the same problem. For now I'am able to link the binary using the microchip's toolchain version of libgcc.a. I think this is bug in openSUSE packaging.

 

avr-ld: mode avr5
attempt to open main.o succeeded
main.o
attempt to open /usr/lib64/gcc/avr/9/avr5//libgcc.so failed
attempt to open /usr/lib64/gcc/avr/9/avr5//libgcc.a succeeded
avr-ld: skipping incompatible /usr/lib64/gcc/avr/9/avr5//libgcc.a when searching for -lgcc
attempt to open /usr/avr/sys-root/lib/avr5//libgcc.so failed
attempt to open /usr/avr/sys-root/lib/avr5//libgcc.a failed
attempt to open /usr/lib64/gcc/avr/9//libgcc.so failed
attempt to open /usr/lib64/gcc/avr/9//libgcc.a succeeded
avr-ld: skipping incompatible /usr/lib64/gcc/avr/9//libgcc.a when searching for -lgcc
attempt to open /usr/lib64/gcc/avr/9/../../../../avr/lib//libgcc.so failed
attempt to open /usr/lib64/gcc/avr/9/../../../../avr/lib//libgcc.a failed
attempt to open /usr/avr/sys-root/lib//libgcc.so failed
attempt to open /usr/avr/sys-root/lib//libgcc.a failed
attempt to open /home/giovanism/Repos/garbage/embed/avr8-gnu-toolchain-linux_x86_64/lib/gcc/avr/5.4.0/avr5/libgcc.so failed
attempt to open /home/giovanism/Repos/garbage/embed/avr8-gnu-toolchain-linux_x86_64/lib/gcc/avr/5.4.0/avr5/libgcc.a succeeded
/home/giovanism/Repos/garbage/embed/avr8-gnu-toolchain-linux_x86_64/lib/gcc/avr/5.4.0/avr5/libgcc.a
attempt to open /usr/lib64/gcc/avr/9/avr5//libm.so failed
attempt to open /usr/lib64/gcc/avr/9/avr5//libm.a failed
attempt to open /usr/avr/sys-root/lib/avr5//libm.so failed
attempt to open /usr/avr/sys-root/lib/avr5//libm.a succeeded
/usr/avr/sys-root/lib/avr5//libm.a
attempt to open /usr/lib64/gcc/avr/9/avr5//libc.so failed
attempt to open /usr/lib64/gcc/avr/9/avr5//libc.a failed
attempt to open /usr/avr/sys-root/lib/avr5//libc.so failed
attempt to open /usr/avr/sys-root/lib/avr5//libc.a succeeded
/usr/avr/sys-root/lib/avr5//libc.a
attempt to open /usr/lib64/gcc/avr/9/avr5//libatmega328p.so failed
attempt to open /usr/lib64/gcc/avr/9/avr5//libatmega328p.a failed
attempt to open /usr/avr/sys-root/lib/avr5//libatmega328p.so failed
attempt to open /usr/avr/sys-root/lib/avr5//libatmega328p.a succeeded
/usr/avr/sys-root/lib/avr5//libatmega328p.a

The output demonstrates that the linker failed to link to system's libgcc.a and succeeded on toolchain's libgcc.a.

I’m Giovan, a humble servant in search of good companions. I am passionate about helping others on new things and the things I already excel with. I’m already familiar with git, Python, C#, Unity3D, Linux, and Docker. I’m now working on my skills and knowledge in FOSS, DevOps, Information Security, and CTF.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the last week or two we've now seen loads of threads like this - it seems the Liunx repository maintainers are not providing matching copies of compiler/binutils/clib. Your best bet is just to get the Atmel/Microchip build

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Your best bet is just to get the Atmel/Microchip build

or just get the Linux version of MPLabX!

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...