[PATCH RFA] libstdc++: add more #if to std.cc (was Re: [Linaro-TCWG-CI] gcc-16-5581-g3ad2e2d707c3: 1 regression on arm)
Jason Merrill <[email protected]>
| Newsgroups | gmane.comp.gcc.patches,gmane.comp.gcc.regression,gmane.comp.gcc.libstdc++.devel,gmane.linux.linaro.toolchain |
|---|---|
| Message-ID | <[email protected]> |
On 12/6/25 11:52 AM, [email protected] wrote: > Dear contributor, > > Our automatic CI has detected problems related to your patch(es). Please find some details below. > > In arm-eabi v7-a softfp, after: > | commit gcc-16-5581-g3ad2e2d707c3 > | Author: Jason Merrill <[email protected]> > | Date: Tue Nov 11 15:58:01 2025 +0530 > | > | driver/c++: add --compile-std-module > | > | For simple testcases that want to use the std module, it would be useful to > | have a reasonably short way to request building the binary module form > | before the testcase. So with this patch users can write > | ... 31 lines of the commit log omitted. > > Produces 1 regression: > | > | regressions.sum: > | Running g++:g++.dg/modules/modules.exp ... > | FAIL: g++.dg/modules/compile-std1.C -std=c++26 (test for excess errors) It seems that module std doesn't compile on arm-eabi, which is good to know. There seem to be two general issues: first, that some of the <stdio.h> functions that <print> relies on aren't declared: > /home/tcwg-buildslave/workspace/tcwg_gnu_1/abe/builds/x86_64-pc-linux-gnu/arm-eabi/gcc-gcc.git~master-sta\ > ge2/arm-eabi/libstdc++-v3/include/print: In member function 'virtual void std::__format::_File_sink::_M_o\ > verflow()': > /home/tcwg-buildslave/workspace/tcwg_gnu_1/abe/builds/x86_64-pc-linux-gnu/arm-eabi/gcc-gcc.git~master-sta\ > ge2/arm-eabi/libstdc++-v3/include/print:197:20: error: '::fwrite_unlocked' has not been declared; did you\ > mean '_fwrite_unlocked_r'? > /home/tcwg-buildslave/workspace/tcwg_gnu_1/abe/builds/x86_64-pc-linux-gnu/arm-eabi/gcc-gcc.git~master-sta\ > ge2/arm-eabi/libstdc++-v3/include/print: In constructor 'std::__format::_File_sink::_File_sink(FILE*, boo\ > l)': > /home/tcwg-buildslave/workspace/tcwg_gnu_1/abe/builds/x86_64-pc-linux-gnu/arm-eabi/gcc-gcc.git~master-sta\ > ge2/arm-eabi/libstdc++-v3/include/print:212:9: error: '::flockfile' has not been declared; did you mean '\ > _flockfile'? > /home/tcwg-buildslave/workspace/tcwg_gnu_1/abe/builds/x86_64-pc-linux-gnu/arm-eabi/gcc-gcc.git~master-sta\ > ge2/arm-eabi/libstdc++-v3/include/print: In destructor 'std::__format::_File_sink::~_File_sink()': > /home/tcwg-buildslave/workspace/tcwg_gnu_1/abe/builds/x86_64-pc-linux-gnu/arm-eabi/gcc-gcc.git~master-sta\ > ge2/arm-eabi/libstdc++-v3/include/print:218:11: error: '::putc_unlocked' has not been declared; did you m\ > ean '_putc_unlocked_r'? > /home/tcwg-buildslave/workspace/tcwg_gnu_1/abe/builds/x86_64-pc-linux-gnu/arm-eabi/gcc-gcc.git~master-sta\ > ge2/arm-eabi/libstdc++-v3/include/print:219:9: error: '::funlockfile' has not been declared; did you mean\ > '_funlockfile'? It seems that newlib doesn't declare these functions under -std=c++26, only -std=gnu++26. I don't know what the right approach to this is. and then a bunch of "not declared" exports, such as > /home/tcwg-buildslave/workspace/tcwg_gnu_1/abe/builds/x86_64-pc-linux-gnu/arm-eabi/gcc-gcc.git~master-sta\ > ge2/arm-eabi/libstdc++-v3/include/bits/std.cc:1002:14: error: 'condition_variable' has not been declared \ > in 'std' This looks like just needing to add more #if to std.cc, as below. OK for trunk? Incidentally, is it expected that arm-eabi doesn't support gthread? Jason
0001-libstdc-add-more-if-to-std.cc.patch
(text/x-patch, 3.9 KB)
From e098c651d9269e8ddb36dbf43cfe1876f5f40168 Mon Sep 17 00:00:00 2001 From: Jason Merrill <[email protected]> Date: Sat, 6 Dec 2025 15:55:43 +0800 Subject: [PATCH] libstdc++: add more #if to std.cc To: [email protected] compile-std1.C was breaking on arm-eabi because these interfaces aren't declared. So for exporting let's check the same macros that control declaring them. libstdc++-v3/ChangeLog: * src/c++23/std.cc.in: Add more #if. --- libstdc++-v3/src/c++23/std.cc.in | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/libstdc++-v3/src/c++23/std.cc.in b/libstdc++-v3/src/c++23/std.cc.in index c2a9293b05a..4962d4fc598 100644 --- a/libstdc++-v3/src/c++23/std.cc.in +++ b/libstdc++-v3/src/c++23/std.cc.in @@ -573,14 +573,20 @@ export namespace std using std::atomic_flag; using std::atomic_flag_clear; using std::atomic_flag_clear_explicit; +#if __cpp_lib_atomic_wait using std::atomic_flag_notify_all; using std::atomic_flag_notify_one; +#endif +#if __cpp_lib_atomic_flag_test using std::atomic_flag_test; using std::atomic_flag_test_and_set; using std::atomic_flag_test_and_set_explicit; using std::atomic_flag_test_explicit; +#endif +#if __cpp_lib_atomic_wait using std::atomic_flag_wait; using std::atomic_flag_wait_explicit; +#endif using std::atomic_init; using std::atomic_int; using std::atomic_int16_t; @@ -602,8 +608,10 @@ export namespace std using std::atomic_load; using std::atomic_load_explicit; using std::atomic_long; +#if __cpp_lib_atomic_wait using std::atomic_notify_all; using std::atomic_notify_one; +#endif using std::atomic_ptrdiff_t; using std::atomic_ref; using std::atomic_schar; @@ -638,8 +646,10 @@ export namespace std using std::atomic_unsigned_lock_free; #endif using std::atomic_ushort; +#if __cpp_lib_atomic_wait using std::atomic_wait; using std::atomic_wait_explicit; +#endif using std::atomic_wchar_t; using std::kill_dependency; using std::memory_order; @@ -997,6 +1007,7 @@ export namespace std } // 33.7 <condition_variable> +#if _GLIBCXX_HAS_GTHREADS export namespace std { using std::condition_variable; @@ -1004,6 +1015,7 @@ export namespace std using std::cv_status; using std::notify_all_at_thread_exit; } +#endif // 17.12.2 <coroutine> #if __cpp_lib_coroutine @@ -1762,10 +1774,12 @@ export namespace std } // <latch> +#if __cpp_lib_latch export namespace std { using std::latch; } +#endif // 17.3.3 <limits> [limits.syn] export namespace std @@ -2037,7 +2051,9 @@ export namespace std::pmr using std::pmr::polymorphic_allocator; using std::pmr::pool_options; using std::pmr::set_default_resource; +#if _GLIBCXX_HAS_GTHREADS using std::pmr::synchronized_pool_resource; +#endif using std::pmr::unsynchronized_pool_resource; } @@ -2051,13 +2067,19 @@ export namespace std using std::defer_lock_t; using std::lock; using std::lock_guard; +#if _GLIBCXX_HAS_GTHREADS using std::mutex; +#endif using std::once_flag; +#if _GLIBCXX_HAS_GTHREADS using std::recursive_mutex; using std::recursive_timed_mutex; +#endif using std::scoped_lock; using std::swap; +#if _GLIBCXX_HAS_GTHREADS using std::timed_mutex; +#endif using std::try_lock; using std::try_to_lock; using std::try_to_lock_t; @@ -2645,11 +2667,13 @@ export namespace std } // <semaphore> +#if __cpp_lib_semaphore export namespace std { using std::binary_semaphore; using std::counting_semaphore; } +#endif // <set> export namespace std @@ -2671,8 +2695,10 @@ export namespace std export namespace std { using std::shared_lock; +#if _GLIBCXX_HAS_GTHREADS using std::shared_mutex; using std::shared_timed_mutex; +#endif using std::swap; } @@ -2957,7 +2983,9 @@ export namespace std { using std::swap; using std::thread; +#if __cpp_lib_jthread using std::jthread; +#endif namespace this_thread { using std::this_thread::get_id; -- 2.51.1