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

std::remainder: undefined reference to `__ieee754_remainder' #7845

Closed
6 tasks done
mcspr opened this issue Jan 28, 2021 · 1 comment · Fixed by #7849
Closed
6 tasks done

std::remainder: undefined reference to `__ieee754_remainder' #7845

mcspr opened this issue Jan 28, 2021 · 1 comment · Fixed by #7849

Comments

@mcspr
Copy link
Collaborator

mcspr commented Jan 28, 2021

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: ESP8285
  • Core Version: c2393d0
  • Development Env: PlatformIO
  • Operating System: Windows

Settings in IDE

Defaults:

[env]
platform = espressif8266
board = d1_mini
framework = arduino

[env:git]
platform_packages =
    platformio/framework-arduinoespressif8266 @ https://github.com/esp8266/Arduino.git
    mcspr/toolchain-xtensa @ 5.100200.201223

Problem Description

std::remainder breaks the linker

ref. https://gitter.im/esp8266/Arduino?at=6011fd5f063b6c68d520a704
@earlephilhower

MCVE Sketch

#include <Arduino.h>
#include <cmath>

double does_this_work(double, double) __attribute((noinline));
double does_this_work(double a, double b) {
    return std::remainder(a, b);
}

void setup() {
    Serial.println(does_this_work(1.2345, 5.4321));
}

void loop() {
}

Debug Messages

Compiling .pio\build\git\src\main.cpp.o
Linking .pio\build\git\firmware.elf
c:/users/maxim/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.2.0/../../../../xtensa-lx106-elf/bin/ld.exe: c:/users/maxim/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.2.0/../../../../xtensa-lx106-elf/lib\libm.a(lib_a-w_remainder.o):(.literal+0x0): undefined reference to `__ieee754_remainder'
c:/users/maxim/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.2.0/../../../../xtensa-lx106-elf/bin/ld.exe: c:/users/maxim/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.2.0/../../../../xtensa-lx106-elf/lib\libm.a(lib_a-w_remainder.o): in function `remainder':
/workdir/repo/newlib/newlib/libm/math/w_remainder.c:60: undefined reference to `__ieee754_remainder'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\git\firmware.elf] Error 1
@earlephilhower
Copy link
Collaborator

Seems it's a known issue w/newlib on the Xtensa. Just needs a rebuild of the toolchain after a simple patch.

espressif/newlib-esp32@d833a53

earlephilhower added a commit to earlephilhower/Arduino that referenced this issue Jan 28, 2021
Update newlib to enable the __iee745_remainder(f) calls required by
std::remainder and others.

Fixes esp8266#7845
earlephilhower added a commit that referenced this issue Jan 29, 2021
Update newlib to enable the __ieee754_remainder(f) calls required by
std::remainder and others.

Add device test for std::remainder variants.

Fixes #7845
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants