Page 1 of 1

[Solved] Problems linking with math library - undefined "__fpclassifyd"

Posted: Thu Sep 29, 2016 5:16 am
by kolban
I have some code that is including "math.h" from components/newlib/include/math.h

In that header there is an external reference to:

Code: Select all

extern int __fpclassifyd (double x);
when I link my application, I am getting an error stating:

Code: Select all

jswrap_functions.c:(.text.jswrap_parseInt+0x27): undefined reference to `__fpclassifyd'
It is important to note that the link step I am using is the following:

Code: Select all

xtensa-esp32-elf-gcc -Winline -Og -Wl,--gc-sections -nostdlib -u call_user_start_cpu0 \
-Wl,--gc-sections -Wl,-static -Wl,-EL \
-Wl,--start-group \
-T/home/pi/projects/esp32/esp-idf/components/esp32/ld/esp32.ld \
-T/home/pi/projects/esp32/esp-idf/components/esp32/ld/esp32.common.ld \
-T/home/pi/projects/esp32/esp-idf/components/esp32/ld/esp32.rom.ld \
-T/home/pi/projects/esp32/esp-idf/components/esp32/ld/esp32.peripherals.ld \
/home/pi/projects/esp32/esp-idf/components/newlib/lib/libc.a \
/home/pi/projects/esp32/esp-idf/components/newlib/lib/libm.a \
-Wl,--end-group -o espruino_1v87.213_esp32.elf src/jslex.o .... // many more .o files
I also found a mysterious file called "components/newlib/lib/extracted/romsys" which appears to list the entry "__fpclassifyd".

Can anyone spot where I must possibly be going wrong?

Re: Problems linking with math library - undefined "__fpclassifyd"

Posted: Thu Sep 29, 2016 6:29 am
by WiFive
It is listed in romsys but not in esp32.rom.ld so can't be linked

Re: Problems linking with math library - undefined "__fpclassifyd"

Posted: Thu Sep 29, 2016 7:27 am
by ESP_Sprite
Can you file an issue on Github for this? Sounds like the script that generates the rom ld file may have skipped over this because of the double underscore.

Re: Problems linking with math library - undefined "__fpclassifyd"

Posted: Thu Sep 29, 2016 1:47 pm
by kolban
Thank you guys. Git hub issue #33 raised.

Later ...

The problem was resolved and it was discovered to be a mistake on my part in my linking step. I had failed to include my source compiled object files in the --start-group / --end-group recursive linking definition. Once I moved my code to be within the recursive resolution group, the linker completed without error.

To be explicit ... I was linking incorrectly with:

Code: Select all

-Wl,--start-group <ESP-IDF libs> -Wl,--end-group <my object files>
when what I should have been doing was:

Code: Select all

-Wl,--start-group <ESP-IDF libs> <my object files> -Wl,--end-group 
If you are using the ESP-IDF makefiles, you shouldn't ever have to worry about this knowledge. I include for completeness in case a similar error is encountered down the line and these words may provide hints to the next person.

Re: Problems linking with math library - undefined "__fpclassifyd"

Posted: Fri Sep 30, 2016 2:17 am
by WiFive
So how does this reconcile the mismatch between romsys and esp32.rom.ld?