daanvV
April 6, 2021, 1:51pm
1
I am trying to disable all compiler optimisation for Due. In platform.txt I set all "-Os" to "-O0" (see image for exact locations). Compiling a simple blink sketch gives me error below.
It seems problem is known for Arduino: fix for "undefined reference to `vtable for HardwareSerial'" by EndlessDelirium · Pull Request #336 · sandeepmistry/arduino-nRF5 · GitHub
Any ideas? Many thanks!
Optimisation settings can be set for Due here: Compiler optimisation for due board - Arduino Due - Arduino Forum
N.b. Forum is not letting me post full compiler output.
C:\Users\XXXXXX~1\AppData\Local\Temp\arduino_build_827689/..\arduino_cache_920391\core\core_arduino_sam_arduino_due_x_dbg_eff5f353e5a81c2d8743360c21514f17.a(UARTClass.cpp.o): In function `HardwareSerial::HardwareSerial()':
C:\Users\XXXXXX\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\cores\arduino/HardwareSerial.h:26: undefined reference to `vtable for HardwareSerial'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Due (Programming Port).
Did you try this:
#pragma GCC push_options // To disable optimization from compiler
#pragma GCC optimize ("O0")
void setup() {
}
void loop() {
}
#pragma GCC pop_options
daanvV
April 7, 2021, 7:19am
3
Yes I did, but when I do that the compiler output suggests that -Os is still being used as a flag(?) after the file path string:
Compiling sketch...
"C:\\Users\\XXXX\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10813 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" "-IC:\\Users\\XXXX\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\sam\\1.6.12\\system/libsam" "-IC:\\Users\\XXXX\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\sam\\1.6.12\\system/CMSIS/CMSIS/Include/" "-IC:\\Users\\XXXX\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\sam\\1.6.12\\system/CMSIS/Device/ATMEL/" "-IC:\\Users\\XXXX\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\sam\\1.6.12\\cores\\arduino" "-IC:\\Users\\XXXX\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\sam\\1.6.12\\variants\\arduino_due_x" "C:\\Users\\XXXX~1\\AppData\\Local\\Temp\\arduino_build_239963\\sketch\\sketch_apr07a.ino.cpp" -o "C:\\Users\\XXXX~1\\AppData\\Local\\Temp\\arduino_build_239963\\sketch\\sketch_apr07a.ino.cpp.o"
Compiling libraries...
Which gives me the impression nothing is done with the #pragma settings.
With the "empty" sketch provided in reply #1 , after compiling, I get:
Sketch uses 10004 bytes with
#pragma GCC optimize ("O0")
Sketch uses 9988 bytes with "O3"
Sketch uses 9980 bytes with "Os"
Hence #pragma does something.
daanvV
April 7, 2021, 10:37am
5
Ah indeed, I get a similar result. Thanks for that!
system
Closed
August 5, 2021, 10:38am
6
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.