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

undefined reference to `vtable for fs::FileImpl' using Arduino as Component (debug -O0 flag). #8792

Closed
1 task done
yizakat opened this issue Oct 23, 2023 · 3 comments
Closed
1 task done
Labels
Area: Arduino as ESP-IDF component Issues about Arduino used as component in ESP-IDF Status: Solved

Comments

@yizakat
Copy link

yizakat commented Oct 23, 2023

Board

ESP32-S3

Device Description

esp32proS3 : Unexpected Maker.

Hardware Configuration

Not relevant.

Version

v2.0.14

IDE Name

VSCode - ESP-IDF extension.

Operating System

Windows 11

Flash frequency

40MHz

PSRAM enabled

yes

Upload speed

115200

Description

I am using Arduino as a component linked to an ESP-IDF project. I get the following linker error when using the SPIFFS file system object and building with the O0 (no optimisation) sdkconfig setting.

Linker error "undefined reference to `vtable for fs::FileImpl'"

This has been noted in other forums/git repos, usually PlatformIO or Arduino IDE context and appears to be related to a change in the behaviour of the GCC toolchain. Switching optimisation back to Og resolves the problem but makes the debugger unusable, presumably most people on those forums are not using GDB.

I am using the matching version of the ESP-IDF tooling for the Arduino component which packages the following toolchain version: esp-2021r2-patch5-8.4.0

Is there a later (or earlier) version I should be using that resolves this issue? I can work my way back but it would be quicker if there is a known point at which the problem was introduced.

Sketch

#include <Arduino.h>
#include <SPIFFS.h>

const static char *TAG="TEST";

extern "C" void app_main(void)
{
    initArduino();    

    if(!SPIFFS.begin(true))
    {
        ESP_LOGE(TAG,"Error enabling SPIFFS filesystem\n");
    }
    else
    {
        ESP_LOGI(TAG,"SPIFFS mounted OK\n");
    }
}

Debug Message

[5/7] Linking CXX executable main.elf
FAILED: main.elf
cmd.exe /C "cd . && C:\Users\jason\.espressif\tools\xtensa-esp32s3-elf\esp-2021r2-patch5-8.4.0\xtensa-esp32s3-elf\bin\xtensa-esp32s3-elf-g++.exe -mlongcalls  @CMakeFiles\main.elf.rsp -o main.elf  && cd ."      
c:/users/jason/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch5-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: esp-idf/arduino-esp32/libarduino-esp32.a(vfs_api.cpp.obj):(.literal._ZN2fs8FileImplD5Ev[_ZN2fs8FileImplD5Ev]+0x0): undefined reference to `vtable for fs::FileImpl'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

Other Steps to Reproduce

None.

Additional notes:

  • RTTI is disabled.
  • Changing the app debug flags to 0g resolves the issue, so presumably optimises the problem out somehow.

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@yizakat yizakat added the Status: Awaiting triage Issue is waiting for triage label Oct 23, 2023
@yizakat yizakat changed the title undefined reference to `vtable for fs::FileImpl' in debug builds with -O0 flag. undefined reference to `vtable for fs::FileImpl' using Arduino as Component (debug -O0 flag). Oct 23, 2023
@VojtechBartoska VojtechBartoska added the Area: Arduino as ESP-IDF component Issues about Arduino used as component in ESP-IDF label Oct 23, 2023
@me-no-dev
Copy link
Member

@igrr any clues why this would be happening?

@Jason2866
Copy link
Collaborator

Will happen if the PR #8768 is not applied.

@yizakat
Copy link
Author

yizakat commented Oct 23, 2023

This is the same but the version I'm using is older 4.4.6, so this has actually been around a while. As noted, it only manifests if there is no optimisation which presumably optimises out the unused/unreferenced methods without the pure-virtual decl.

I've applied the PR locally and all fine now.

@yizakat yizakat closed this as completed Oct 23, 2023
@VojtechBartoska VojtechBartoska added Status: Solved and removed Status: Awaiting triage Issue is waiting for triage labels Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Arduino as ESP-IDF component Issues about Arduino used as component in ESP-IDF Status: Solved
Projects
None yet
Development

No branches or pull requests

4 participants