Skip to content

Build Errors on GCC 15 and glibc 2.43 #300

@avlec

Description

@avlec

With gcc 15.2.1+r604 and glibc 2.43 on Arch Linux this project does not build.

[ 33%] Building CXX object model/CMakeFiles/model.dir/model.cpp.o
In file included from /home/avlec/pico/pico-sdk/src/common/boot_picoboot_headers/include/boot/picoboot.h:15,
                 from /home/avlec/pico/picotool/model/model.h:8,
                 from /home/avlec/pico/picotool/model/model.cpp:1:
/usr/include/bits/struct_mutex.h:35:9: error: declaration does not declare anything [-fpermissive]
   35 |   short __unused;
      |         ^~~~~~~~
In file included from /usr/include/c++/15.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:35,
                 from /usr/include/c++/15.2.1/x86_64-pc-linux-gnu/bits/gthr.h:157,
                 from /usr/include/c++/15.2.1/ext/atomicity.h:37,
                 from /usr/include/c++/15.2.1/bits/shared_ptr_base.h:61,
                 from /usr/include/c++/15.2.1/bits/shared_ptr.h:53,
                 from /usr/include/c++/15.2.1/memory:82,
                 from /home/avlec/pico/picotool/model/model.h:43:
/usr/include/c++/15.2.1/ext/concurrence.h:124:34: error: cannot convert ‘<brace-enclosed initializer list>’ to ‘__pthread_internal_list*’ in initialization
  124 |     __gthread_mutex_t _M_mutex = __GTHREAD_MUTEX_INIT;
      |                                  ^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/15.2.1/ext/concurrence.h:179:44: error: cannot convert ‘<brace-enclosed initializer list>’ to ‘__pthread_internal_list*’ in initialization
  179 |     __gthread_recursive_mutex_t _M_mutex = __GTHREAD_RECURSIVE_MUTEX_INIT;
      |                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [model/CMakeFiles/model.dir/build.make:79: model/CMakeFiles/model.dir/model.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:802: model/CMakeFiles/model.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

/usr/include/bits/struct_mutex.h

This seems to be a bad glibc header that was fixed recently upstream and is unreleased
https://sourceware.org/git/?p=glibc.git;a=commit;h=243bdfec8f7cd4a85a8ce6e4e9a5a5accd3ce1aa

I do not know how to work around this one... (I just edited the system header with sudo to change __unused to the same thing in the linked glibc commit)

/usr/include/c++/15.2.1/ext/concurrence.h

Similar __GTHREAD failures have cropped up in pico-sdk here raspberrypi/pico-sdk#2746. Linked in that issue is an abandoned fix of which I applied here and it resolves these issues.

diff --git a/model/CMakeLists.txt b/model/CMakeLists.txt
index cd9e775..4879f63 100644
--- a/model/CMakeLists.txt
+++ b/model/CMakeLists.txt
@@ -4,6 +4,10 @@ add_library(model STATIC
 target_include_directories(model PUBLIC ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_BINARY_DIR})

 target_link_libraries(model PUBLIC boot_uf2_headers boot_picoboot_headers pico_platform_headers errors)
+target_compile_definitions(model PRIVATE
+       _GTHREAD_USE_MUTEX_INIT_FUNC
+       _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
+)

 add_custom_target(unreadable_rom_data DEPENDS
         ${CMAKE_CURRENT_BINARY_DIR}/rp2350_a2_rom_end.h

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions