Bug 1134394 - incompatible libgcc.a when searching for -lgcc
Summary: incompatible libgcc.a when searching for -lgcc
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: avr-gcc
Version: 21
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Michal Hlavinka
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-27 12:51 UTC by Chris Evich
Modified: 2014-11-01 16:22 UTC (History)
4 users (show)

Fixed In Version: avr-gcc-4.9.1-3.fc21
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1136400 (view as bug list)
Environment:
Last Closed: 2014-11-01 16:22:46 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Chris Evich 2014-08-27 12:51:47 UTC
Description of problem:
When using the Arduino IDE to build one of the included examples, it compiles fine but linking fails.

Version-Release number of selected component (if applicable):
arduino.noarch                                1:1.0.5-8.fc21
avr-binutils.x86_64                           1:2.24-2.fc21
avr-gcc.x86_64                                4.9.1-2.fc21
avr-gcc-c++.x86_64                            4.9.1-2.fc21
avr-gdb.x86_64                                7.1-11.fc21
avr-libc.noarch                               1.8.0-9.fc21
avr-libc-doc.noarch                           1.8.0-9.fc21

How reproducible:
Almost Trivial

Steps to Reproduce:
1. Run arduino IDE, in preferences check boxe for verbose compile
2. Click the "up" arrow button (open) and chose one of the examples (doesn't matter which)
3. Click the check-mark (verify) button

Actual results:
...
avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o /tmp/build8503997909648707358.tmp/Blink.cpp.elf /tmp/build8503997909648707358.tmp/Blink.cpp.o /tmp/build8503997909648707358.tmp/core.a -L/tmp/build8503997909648707358.tmp -lm 
/usr/lib/gcc/avr/4.9.1/../../../../avr/bin/ld: skipping incompatible /usr/lib/gcc/avr/4.9.1/avr5/libgcc.a when searching for -lgcc
/usr/lib/gcc/avr/4.9.1/../../../../avr/bin/ld: skipping incompatible /usr/lib/gcc/avr/4.9.1/libgcc.a when searching for -lgcc
/usr/lib/gcc/avr/4.9.1/../../../../avr/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status

Expected results:
Linking successful, then converts elf to hex (format) with avr-binutils, displays success message.

Additional info:
This can be reproduced w/o the Arduino IDE, but setting up AVR build environment is much less trivial to reproduce this bug than just using the IDE.  I have not yet tried rawhide.

Comment 1 Chris Evich 2014-08-27 12:59:29 UTC
Reproduced same linking failure with rawhide packages:

 avr-binutils            x86_64            1:2.24-2.fc22
 avr-gcc                 x86_64            4.9.1-2.fc22
 avr-gcc-c++             x86_64            4.9.1-2.fc22
 avr-gdb                 x86_64            7.1-11.fc22

Comment 2 Michal Hlavinka 2014-08-27 14:47:08 UTC
I've just tried to compile quite big project and it was working fine. Please try to find steps how to reproduce this without using arduino ide. Thanks

Comment 3 Chris Evich 2014-08-27 15:42:06 UTC
Building w/o the IDE is possible using https://github.com/queezythegreat/arduino-cmake and I just noticed it includes an example.  However the build is failing well before even touching the arduino-specifc bits with any compiler...

$ git clone https://github.com/queezythegreat/arduino-cmake.git arduino-cmake
Cloning into 'arduino-cmake'...
remote: Counting objects: 2096, done.
remote: Total 2096 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (2096/2096), 4.16 MiB | 5.25 MiB/s, done.
Resolving deltas: 100% (720/720), done.
Checking connectivity... done.
$ cd arduino-cmake
$ mkdir build; cd build
$ cmake ..
-- The C compiler identification is GNU 4.9.1
-- The CXX compiler identification is GNU 4.9.1
-- Arduino SDK version 1.0.5: /usr/share/arduino
-- Check for working C compiler: /usr/lib64/ccache/avr-gcc
-- Check for working C compiler: /usr/lib64/ccache/avr-gcc -- broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:61 (message):

...cut...

 /usr/lib64/ccache/avr-gcc -g -Os -mcall-prologues -ffunction-sections
  -fdata-sections -Wl,--gc-sections -lm
  CMakeFiles/cmTryCompileExec3150891695.dir/testCCompiler.c.obj -o
  cmTryCompileExec3150891695

  /usr/lib/gcc/avr/4.9.1/../../../../avr/bin/ld: skipping incompatible
  /usr/lib/gcc/avr/4.9.1/libgcc.a when searching for -lgcc

  /usr/lib/gcc/avr/4.9.1/../../../../avr/bin/ld: cannot find -lgcc

  collect2: error: ld returned 1 exit status

...cut...

The complete error is quite long, but that seems to be the important part and matches the trouble the IDE is having.  In any case, that's a bit more of a lower-level yet simpler reproducer.  Hope that helps.

Comment 4 Chris Evich 2014-08-28 13:46:13 UTC
Is there anything else I can provide that would help find and/or determine if this is a bug or setup problem?

Comment 5 Michal Hlavinka 2014-08-29 07:55:39 UTC
I'm not able to use this example either, as it uses arduino sdk configuration:

$ cmake ..
CMake Error at cmake/ArduinoToolchain.cmake:81 (message):
  Could not find Arduino SDK (set ARDUINO_SDK_PATH)!

I checked the 
CMake Error at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:61 
which fails on your system. It just tries to compile simple:

#ifdef __cplusplus
# error "The CMAKE_C_COMPILER is set to a C++ compiler"
#endif
#if defined(__CLASSIC_C__)
int main(argc, argv)
  int argc;
  char* argv[];
#else
 int main(int argc, char* argv[])
#endif
{ (void)argv; return argc-1; }

and it worked here too.

Also, I found that this error message (in distant past) was visible with seeing

architecture: UNKNOWN!, flags 0x00000011:

in avr-objdump output of libgcc, but again, the one we ship looks fine.

Comment 6 Chris Evich 2014-08-29 14:17:39 UTC
Thanks for responding so quickly, sorry I am not much of an expert, I am *just* starting to grow out of the Arduino IDE "wheelchair" :D  The "Arduino SDK" just comes from the standard 'arduino' package that we ship. Cmake just wants to find paths to the libraries.  However it doesn't even get to using them as you've seen above.  But I think you're reproducer is probably fine as well.  

Oh great, that's the test code, if I use same build commands from arduino-cmake it gives same error, so I don't need cmake or arduino stuff to reproduce:

$ /usr/lib64/ccache/avr-gcc -g -Os -mcall-prologues -ffunction-sections -fdata-sections -o test.c.obj -c test.c

$ /usr/lib64/ccache/avr-gcc -g -Os -mcall-prologues -ffunction-sections -fdata-sections -Wl,--gc-sections -lm test.c.obj -o test
/usr/lib/gcc/avr/4.9.1/../../../../avr/bin/ld: skipping incompatible /usr/lib/gcc/avr/4.9.1/libgcc.a when searching for -lgcc
/usr/lib/gcc/avr/4.9.1/../../../../avr/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status

I'm not sure how to use avr-objdump exactly, but playing with it I found:

$ avr-objdump -f test.c.obj 

test.c.obj:     file format elf32-avr
architecture: avr, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x00000000

$ avr-objdump -f /usr/lib/gcc/avr/4.9.1/libgcc.a
In archive /usr/lib/gcc/avr/4.9.1/libgcc.a:

_absvhi2.o:     file format elf32-little
architecture: UNKNOWN!, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x00000000


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

...repeat for each object in archive...

I didn't check the hundreds of others, but at least the first one shows that 'UNKNOWN!' arch.  What can I look at next?

Comment 7 Chris Evich 2014-08-29 14:19:25 UTC
FWIW:

$ rpm -qf /usr/lib/gcc/avr/4.9.1/libgcc.a
avr-gcc-4.9.1-2.fc21.x86_64
$ rpm -V avr-gcc-4.9.1-2.fc21.x86_64
...nothing...

Comment 8 Chris Evich 2014-08-29 14:28:43 UTC
All of the other ones seem to have this also:

$ pwd
/usr/lib/gcc/avr/4.9.1
[cevich@cevich 4.9.1]$ find -name libgcc.a | xargs -L 1 avr-objdump -f | grep -B 1 UNKNOWN
_absvhi2.o:     file format elf32-little
architecture: UNKNOWN!, flags 0x00000011:
--
_absvhi2.o:     file format elf32-little
architecture: UNKNOWN!, flags 0x00000011:
--
_absvhi2.o:     file format elf32-little
architecture: UNKNOWN!, flags 0x00000011:
--
...repeat...

What can I look at next that would help?

Comment 9 Michal Hlavinka 2014-08-29 16:16:11 UTC
(In reply to Chris Evich from comment #6)
> Oh great, that's the test code, if I use same build commands from
> arduino-cmake it gives same error, so I don't need cmake or arduino stuff to
> reproduce:
> 
> $ /usr/lib64/ccache/avr-gcc -g -Os -mcall-prologues -ffunction-sections
> -fdata-sections -o test.c.obj -c test.c

You've used the code from comment #5 as test.c or what is the content?

If I use that, it still works for me.

(In reply to Chris Evich from comment #8)
> All of the other ones seem to have this also:
> 
> $ pwd
> /usr/lib/gcc/avr/4.9.1
> [cevich@cevich 4.9.1]$ find -name libgcc.a | xargs -L 1 avr-objdump -f |
> grep -B 1 UNKNOWN

it prints nothing on my machine... I use Fedora 20 system with Fedora 21 avr-* packages. I will try again on Monday in virtual machine with freshly installed Fedora 21 and I will see if I can reproduce this.

Comment 10 Michal Hlavinka 2014-08-29 16:21:32 UTC
OK, I just noticed that you use even newer packages than those I've built. I've downloaded the newer ones and I can reproduce this now. Seems that packages from mass rebuild (4.9.1-2) are crippled. 4.9.1-1 works fine.

Comment 11 Chris Evich 2014-08-29 17:05:56 UTC
Oh great! I'm glad you've been able to narrow it down and it wasn't something silly that I was doing :)  So it seems a simple downgrade is the workaround for now also, cool!

Comment 12 Chris Evich 2014-08-30 13:02:42 UTC
Interesting, I can't seem to find 4.9.1-2 anywhere convenient.  In any case, for other's benefit:  What I did for now to workaround this is setup some Fedoa 20 repos (copy & replace $releasever -> 20), copy the GPG keys from the fedora-release-20-1.noarch.rpm package, then 'yum downgrade avr* libftdi'.  Works like a champ:

(using code from comment #5)
$ /usr/lib64/ccache/avr-gcc -g -Os -mcall-prologues -ffunction-sections -fdata-sections -o test.c.obj -c test.c

$ /usr/lib64/ccache/avr-gcc -g -Os -mcall-prologues -ffunction-sections -fdata-sections -Wl,--gc-sections -lm test.c.obj -o test

$ file test
test: ELF 32-bit LSB executable, Atmel AVR 8-bit, version 1 (SYSV), statically linked, not stripped

p.s. probably should mark those packages in excludes until this bug is fixed, so they don't get upgraded on ya.

Comment 13 Chris Evich 2014-08-30 13:03:25 UTC
correction, I meant 4.9.1-1

Comment 14 Michal Hlavinka 2014-09-02 12:32:39 UTC
(In reply to Chris Evich from comment #12)
> Interesting, I can't seem to find 4.9.1-2 anywhere convenient.

When looking for older/newer packages, check koji:
http://koji.fedoraproject.org/koji/packageinfo?packageID=4422

Comment 15 Fedora Update System 2014-09-02 13:55:17 UTC
avr-gcc-4.9.1-3.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/avr-gcc-4.9.1-3.fc21

Comment 16 Chris Evich 2014-09-03 18:13:18 UTC
Cool, I installed the -3 release from koji and verified all my stuff builds w/o any trouble now.  Thanks!

(not sure if I should mark this VERIFIED or if someone else does that)

Comment 17 Fedora Update System 2014-09-06 00:59:18 UTC
Package avr-gcc-4.9.1-3.fc21:
* should fix your issue,
* was pushed to the Fedora 21 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing avr-gcc-4.9.1-3.fc21'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-10185/avr-gcc-4.9.1-3.fc21
then log in and leave karma (feedback).

Comment 18 Fedora Update System 2014-11-01 16:22:46 UTC
avr-gcc-4.9.1-3.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.