bugAVR C Runtime Library - Bugs: bug #32086, libm library not linked

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #32086: libm library not linked

Submitter:  Christian Mikula <cmikula>
Submitted:  Mon 10 Jan 2011 10:23:12 AM UTC
   
 
Category:  Library Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Build system
Status:  Invalid Assigned to:  joerg_wunsch
Percent Complete:  0% Open/Closed:  Closed
Release:  1.6.7 Fixed Release:  None

Mon 10 Jan 2011 02:42:14 PM UTC, comment #5: 


> Now you can see that the codesize is 1344 bytes
> instead of your 3090 bytes.


Aha, that is your point.

Please describe the exact problem next time ...  "not linked"
sounds like "unresolved symbols" to me.

This is a GCC bug, together with our lack of a compilable
libstdc++.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28718

Unfortunately, there's nothing the avr-libc project could do
about this, that's why I'm closing the bug as "invalid"
(with respect to this project).

Joerg Wunsch <joerg_wunsch>
Group administrator
Mon 10 Jan 2011 02:26:35 PM UTC, comment #4: 

Pleas edit the makefile as describet bellow in point 2. in line 57.

And you get this!

rm -rf .o demo.elf .eps .png .pdf *.bak
rm -rf .lst .map .hex .bin *.srec
avr-g++ -g -Wall -Os -mmcu=attiny861    -c -o demo.o demo.c
avr-g++ -g -Wall -Os -mmcu=attiny861  -v -Wl,-Map,demo.map -o demo.elf demo.o -lm -lm
Es werden eingebaute Spezifikationen verwendet.
Ziel: avr
Konfiguriert mit: ../src/configure -v --enable-languages=c,c++ --prefix=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --disable-libssp --build=i686-linux-gnu --host=i686-linux-gnu --target=avr
Thread-Modell: single
gcc-Version 4.3.5 (GCC)
COMPILER_PATH=/usr/lib/gcc/avr/4.3.5/:/usr/lib/gcc/avr/4.3.5/:/usr/lib/gcc/avr/:/usr/lib/gcc/avr/4.3.5/:/usr/lib/gcc/avr/:/usr/lib/gcc/avr/4.3.5/../../../avr/bin/
LIBRARY_PATH=/usr/lib/gcc/avr/4.3.5/avr25/:/usr/lib/gcc/avr/4.3.5/../../../avr/lib/avr25/:/usr/lib/gcc/avr/4.3.5/:/usr/lib/gcc/avr/4.3.5/../../../avr/lib/
COLLECT_GCC_OPTIONS='-g' '-Wall' '-Os' '-mmcu=attiny861' '-v' '-o' 'demo.elf'
 /usr/lib/gcc/avr/4.3.5/../../../avr/bin/ld -m avr2 -o demo.elf /usr/lib/gcc/avr/4.3.5/../../../avr/lib/avr25/crttn861.o -L/usr/lib/gcc/avr/4.3.5/avr25 -L/usr/lib/gcc/avr/4.3.5/../../../avr/lib/avr25 -L/usr/lib/gcc/avr/4.3.5 -L/usr/lib/gcc/avr/4.3.5/../../../avr/lib -Map demo.map demo.o -lm -lgcc -lm -lgcc -lc -lgcc
avr-objdump -h -S demo.elf > demo.lst
avr-objcopy -j .text -j .data -O ihex demo.elf demo.hex
avr-objcopy -j .text -j .data -O binary demo.elf demo.bin
avr-objcopy -j .text -j .data -O srec demo.elf demo.srec
avr-size --format=avr --mcu=attiny861 demo.elf
AVR Memory Usage
----------------
Device: attiny861

Program:    1344 bytes (16.4% Full)
(.text + .data + .bootloader)

Data:          0 bytes (0.0% Full)
(.data + .bss + .noinit)


Now you can see that the codesize is 1344 bytes instead of your 3090 bytes.


Christian Mikula <cmikula>
Mon 10 Jan 2011 02:08:35 PM UTC, comment #3: 


> I attached a demo project with makefile to test it for you!


Not very helpful.  I already wrote that I cannot reproduce it,
but if you don't believe it:

j@uriah 86% gmake
rm -rf .o demo.elf .eps .png .pdf *.bak
rm -rf .lst .map .hex .bin *.srec
avr-g++ -g -Wall -Os -mmcu=attiny861    -c -o demo.o demo.c
avr-g++ -g -Wall -Os -mmcu=attiny861  -v -Wl,-Map,demo.map -o demo.elf demo.o -lm
Using built-in specs.
Target: avr
Configured with: ./../gcc-4.3.4/configure --target=avr --disable-libssp --with-gmp=/usr/local --prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/ --build=i386-portbld-freebsd7.0
Thread model: single
gcc version 4.3.4 (GCC)
COMPILER_PATH=/usr/local/libexec/gcc/avr/4.3.4/:/usr/local/libexec/gcc/avr/4.3.4/:/usr/local/libexec/gcc/avr/:/usr/local/lib/gcc/avr/4.3.4/:/usr/local/lib/gcc/avr/:/usr/local/lib/gcc/avr/4.3.4/../../../../avr/bin/
LIBRARY_PATH=/usr/local/lib/gcc/avr/4.3.4/avr25/:/usr/local/lib/gcc/avr/4.3.4/../../../../avr/lib/avr25/:/usr/local/lib/gcc/avr/4.3.4/:/usr/local/lib/gcc/avr/4.3.4/../../../../avr/lib/
COLLECT_GCC_OPTIONS='-g' '-Wall' '-Os' '-mmcu=attiny861' '-v' '-o' 'demo.elf'
 /usr/local/lib/gcc/avr/4.3.4/../../../../avr/bin/ld -m avr2 -o demo.elf /usr/local/lib/gcc/avr/4.3.4/../../../../avr/lib/avr25/crttn861.o -L/usr/local/lib/gcc/avr/4.3.4/avr25 -L/usr/local/lib/gcc/avr/4.3.4/../../../../avr/lib/avr25 -L/usr/local/lib/gcc/avr/4.3.4 -L/usr/local/lib/gcc/avr/4.3.4/../../../../avr/lib -Map demo.map demo.o -lgcc -lm -lgcc -lc -lgcc
avr-objdump -h -S demo.elf > demo.lst
avr-objcopy -j .text -j .data -O ihex demo.elf demo.hex
avr-objcopy -j .text -j .data -O binary demo.elf demo.bin
avr-objcopy -j .text -j .data -O srec demo.elf demo.srec
avr-size --format=avr --mcu=attiny861 demo.elf
AVR Memory Usage
----------------
Device: attiny861

Program:    3090 bytes (37.7% Full)
(.text + .data + .bootloader)

Data:          8 bytes (1.6% Full)
(.data + .bss + .noinit)


Please attach your -v transcript file.

Joerg Wunsch <joerg_wunsch>
Group administrator
Mon 10 Jan 2011 01:54:27 PM UTC, comment #2: 

I attached a demo project with makefile to test it for you!

This project is only to demonstrate the bug.

I get the error in really cpp project and in this place (as you described)the g++ is used.

1. Use "make all" to build the project.
Program:    3090 bytes (37.7% Full)

2. Edit makefile in line 57 from "LIBs = -lm" to "LIBs = -lm -lm"
3. Store and use "make all" to build the project.
Program:    1344 bytes (16.4% Full)

Now you can see, that the linker does not work korrectly.

If avr-gcc is used the linker works fine.



(file #22384)

Christian Mikula <cmikula>
Mon 10 Jan 2011 10:38:49 AM UTC, comment #1: 

First, I cannot reproduce that at all.  Please add the -v
option, and attach a full transcript of the session as a
separate file (e.g. by using the "script" command).

Second, your command invocation of avr-gcc vs. avr-g++ does
not match.  This is not expected to work at all.  Please use
consistent command for both, compilation and linking.  Either
your source code is plain C, then use avr-gcc for both, or
it's C++, then use avr-g++ for both commands.

Joerg Wunsch <joerg_wunsch>
Group administrator
Mon 10 Jan 2011 10:23:12 AM UTC, original submission:  

Hi,

the libm library will be not linked if the -lm command is added once! it must be added twice to get correct result!

main code:


#include "avr/io.h"
#include "math.h"

#define R1 10000
#define R0 10000
#define T0 298.15
#define B 3380
#define ZeroTemp 273.15

float get_temp(float Rth) {
float T = B / (log(Rth / (R0 * exp(-B / T0))));
return T - ZeroTemp;
}


int main(void) {
double x = 1234;
while (1) {
x = get_temp(x);
}
return 0;
}


Invoking: AVR Compiler
avr-gcc -Wall -Os -fpack-struct -fshort-enums -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=attiny861 -DF_CPU=8000000UL -MMD -MP -MF"main.d" -MT"main.d" -c -o"main.o" "../main.c"

Invoking: AVR C++ Linker will not work correctly
avr-g++ -Wl,-Map,gpptest.map,--cref -mmcu=attiny861 -o"gpptest.elf"  ./main.o   -lm
 
Invoking: AVR C++ Linker work correctly
avr-g++ -Wl,-Map,gpptest.map,--cref -mmcu=attiny861 -o"gpptest.elf"  ./main.o   -lm -lm


See the problem to invoke the print size kommand!
avr-size --format=avr --mcu=attiny861 gpptest.elf

Best regards

Chris

Christian Mikula <cmikula>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #22384:  gpp-test.tar.gz added by cmikula (1KiB - application/gzip)
file #22381:  main.c added by cmikula (429B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by joerg_wunsch (Posted a comment)
  • -email is unavailable- added by cmikula (Submitted the item)
  •  

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-01-10 joerg_wunsch StatusNeed Info Invalid
        Open/ClosedOpen Closed
    2011-01-10 cmikula Attached File- Added gpp-test.tar.gz, #22384
    2011-01-10 joerg_wunsch StatusNone Need Info
        Assigned toNone joerg_wunsch
    2011-01-10 cmikula Attached File- Added main.c, #22381

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code