Skip to content

Undefined reference to `__atomic_test_and_set' (IDFGH-14383) #15167

@aiquie

Description

@aiquie

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

5.4

Operating System used.

Linux

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

What is the expected behavior?

Successful build.

What is the actual behavior?

Linking error: undefined reference to '__atomic_test_and_set'

Steps to reproduce.

  1. create project using function atomic_flag_test_and_set:
    a. idf.py create-project
    b. main/test.c
#include <stdatomic.h>

void app_main(void)
{
    atomic_flag_test_and_set(0);
}
  1. set esp32c2 target OR enable PSRAM:
    a. idf.py set-target esp32c2
    b. CONFIG_SPIRAM=y
  2. idf.py build

Build or installation Logs.

a. with esp32c2 target

~/.espressif/tools/riscv32-esp-elf/esp-14.2.0_20241119/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/14.2.0/../../../../riscv32-esp-elf/bin/ld: esp-idf/main/libmain.a(test.c.obj): in function `app_main':
~/test/main/test.c:5:(.text.app_main+0x8): undefined reference to `__atomic_test_and_set'

b. enabled PSRAM

~/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/main/libmain.a(test.c.obj):(.literal.app_main+0x0): undefined reference to `__atomic_test_and_set'
~/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/main/libmain.a(test.c.obj): in function `app_main':
~/test/main/test.c:5:(.text.app_main+0x7): undefined reference to `__atomic_test_and_set'

More Information.

  • build on version 5.3 and earlier
  • build with default settings

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions