diff --git a/.gitlab/ci/build.yml b/.gitlab/ci/build.yml index 96ede903cc..014c00889d 100644 --- a/.gitlab/ci/build.yml +++ b/.gitlab/ci/build.yml @@ -658,9 +658,6 @@ build_clang_test_apps_esp32c2: extends: - .build_clang_test_apps_riscv - .rules:build:custom_test-esp32c2 - # spec files and nano libc are not supported yet by esp-clang - # TODO: LLVM-197 - allow_failure: true variables: IDF_TARGET: esp32c2 diff --git a/components/newlib/CMakeLists.txt b/components/newlib/CMakeLists.txt index 5e3e4efa1e..0cbce719ef 100644 --- a/components/newlib/CMakeLists.txt +++ b/components/newlib/CMakeLists.txt @@ -49,7 +49,19 @@ list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_assert_impl") target_link_libraries(${COMPONENT_LIB} INTERFACE "${EXTRA_LINK_FLAGS}") if(CONFIG_NEWLIB_NANO_FORMAT) - target_link_libraries(${COMPONENT_LIB} INTERFACE "--specs=nano.specs") + if(CMAKE_C_COMPILER_ID MATCHES "Clang") + set(libc_dir_cmd ${CMAKE_C_COMPILER}) + string(REPLACE " " ";" cflags_list ${CMAKE_C_FLAGS}) + list(APPEND libc_dir_cmd ${cflags_list} "-print-file-name=libc.a") + execute_process( + COMMAND ${libc_dir_cmd} + OUTPUT_VARIABLE libc_dir + ) + get_filename_component(libc_dir ${libc_dir} DIRECTORY) + target_link_directories(${COMPONENT_LIB} INTERFACE "${libc_dir}/nano") + else() + target_link_libraries(${COMPONENT_LIB} INTERFACE "--specs=nano.specs") + endif() endif() add_subdirectory(port)