Skip to content

gcc 15.1.0 no longer compiles a basic example using import std and modules #24424

@DiegoSpeziari

Description

@DiegoSpeziari

Description / Steps to reproduce the issue

This simple code used to compile. With the updates of the last month it does not compile anymore.

Code:
main.cpp
import std; import mymodule; int main() { std::vector<int> v = get_vector(); std::println("vector = {}", v); }

mymodule.cpp
export module mymodule; import std; export std::vector<int> get_vector() { std::vector<int> v={1,2,3,4}; return v; }

CMakeLists.txt
cmake_minimum_required(VERSION 4.0) set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "a9e1cf81-9932-4810-974b-6eccaf14e457") set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_MODULE_STD 1) project(demo LANGUAGES CXX) add_executable(demo src/main.cpp) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") target_link_libraries(demo PRIVATE stdc++exp) endif()

If I revert to previous updates it compiles correctly. This is the command to revert to the working version:

pacman -U /var/cache/pacman/pkg/mingw-w64-x86_64-winstorecompat-git-12.0.0.r679.g71699efcb-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-tools-git-12.0.0.r679.g71699efcb-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-sqlite3-3.47.2-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-mpdecimal-4.0.0-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-libpng-1.6.47-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-libmangle-git-12.0.0.r679.g71699efcb-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-libgcrypt-1.11.0-2-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-libgpg-error-1.53-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-hdf5-1.14.6-2-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-libaec-1.1.3-3-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-gcc-libgfortran-15.1.0-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-gcc-15.1.0-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-winpthreads-git-12.0.0.r679.g71699efcb-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-crt-git-12.0.0.r679.g71699efcb-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-headers-git-12.0.0.r679.g71699efcb-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-cmake-4.0.1-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-libuv-1.50.0-2-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-binutils-2.44-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-gettext-runtime-0.24-2-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-gcc-libs-15.1.0-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-libwinpthread-git-12.0.0.r679.g71699efcb-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/curl-8.13.0-1-x86_64.pkg.tar.zst 
/var/cache/pacman/pkg/libcurl-8.13.0-1-x86_64.pkg.tar.zst 
/var/cache/pacman/pkg/libsqlite-3.46.1-1-x86_64.pkg.tar.zst 
/var/cache/pacman/pkg/info-7.1-3-x86_64.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-gcc-ada-15.1.0-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-gcc-objc-15.1.0-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-libgccjit-15.1.0-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-glib2-2.84.1-2-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-gcc-fortran-15.1.0-1-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-libarchive-3.7.9-2-any.pkg.tar.zst 
/var/cache/pacman/pkg/mingw-w64-x86_64-nghttp3-1.9.0-1-any.pkg.tar.zst

Expected behavior

correct compilation

Actual behavior

This is the error I get:

[main] Building folder: c:/Users/diego/Documents/Utilita/Sorgente/mingw/prova_import_std_2/build 
[build] Starting build
[proc] Executing command: C:\msys64\mingw64\bin\cmake.exe --build c:/Users/diego/Documents/Utilita/Sorgente/mingw/prova_import_std_2/build --config Debug --target all --
[build] [2/10  10% :: 0.053] Scanning C:/msys64/mingw64/include/c++/15.1.0/bits/std.compat.cc for CXX dependencies
[build] [2/10  20% :: 0.353] Scanning C:/msys64/mingw64/include/c++/15.1.0/bits/std.cc for CXX dependencies
[build] [3/10  30% :: 0.391] Generating CXX dyndep file CMakeFiles/__CMAKE__CXX23@synth_dd3106011d9b.dir/CXX.dd
[build] [6/10  40% :: 0.432] Scanning C:/Users/diego/Documents/Utilita/Sorgente/mingw/prova_import_std_2/src/main.cpp for CXX dependencies
[build] [6/10  50% :: 0.432] Scanning C:/Users/diego/Documents/Utilita/Sorgente/mingw/prova_import_std_2/src/mymodule.cpp for CXX dependencies
[build] [7/10  60% :: 0.476] Generating CXX dyndep file CMakeFiles/demo.dir/CXX.dd
[build] [7/10  70% :: 2.738] Building CXX object CMakeFiles/__CMAKE__CXX23@synth_dd3106011d9b.dir/f54cafc7d685.bmi
[build] FAILED: CMakeFiles/__CMAKE__CXX23@synth_dd3106011d9b.dir/f54cafc7d685.bmi 
[build] C:\msys64\mingw64\bin\g++.exe   -g -std=gnu++23 -fmodule-only -MD -MT CMakeFiles/__CMAKE__CXX23@synth_dd3106011d9b.dir/f54cafc7d685.bmi -MF CMakeFiles\__CMAKE__CXX23@synth_dd3106011d9b.dir\f54cafc7d685.bmi.d -fmodules-ts -fmodule-mapper=CMakeFiles\__CMAKE__CXX23@synth_dd3106011d9b.dir\f54cafc7d685.bmi.modmap -MD -fdeps-format=p1689r5 -x c++ -o CMakeFiles/__CMAKE__CXX23@synth_dd3106011d9b.dir/f54cafc7d685.bmi -c C:/msys64/mingw64/include/c++/15.1.0/bits/std.cc
[build] In file included from C:/msys64/mingw64/include/c++/15.1.0/x86_64-w64-mingw32/bits/stdc++.h:196,
[build]                  from C:/msys64/mingw64/include/c++/15.1.0/bits/std.cc:30:
[build] C:/msys64/mingw64/include/c++/15.1.0/shared_mutex:105:3: error: 'int std::__glibcxx_rwlock_timedrdlock(pthread_rwlock_t*, const timespec*)' exposes TU-local entity 'int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const timespec*)'
[build]   105 |   __glibcxx_rwlock_timedrdlock (pthread_rwlock_t *__rwlock,
[build]       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] In file included from C:/msys64/mingw64/include/c++/15.1.0/x86_64-w64-mingw32/bits/gthr-default.h:35,
[build]                  from C:/msys64/mingw64/include/c++/15.1.0/x86_64-w64-mingw32/bits/gthr.h:157,
[build]                  from C:/msys64/mingw64/include/c++/15.1.0/ext/atomicity.h:37,
[build]                  from C:/msys64/mingw64/include/c++/15.1.0/bits/ios_base.h:41,
[build]                  from C:/msys64/mingw64/include/c++/15.1.0/streambuf:45,
[build]                  from C:/msys64/mingw64/include/c++/15.1.0/bits/streambuf_iterator.h:37,
[build]                  from C:/msys64/mingw64/include/c++/15.1.0/iterator:68,
[build]                  from C:/msys64/mingw64/include/c++/15.1.0/x86_64-w64-mingw32/bits/stdc++.h:56:
[build] C:/msys64/mingw64/include/pthread.h:296:28: note: 'int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const timespec*)' declared with internal linkage
[build]   296 | WINPTHREAD_RWLOCK_DECL int pthread_rwlock_timedrdlock(pthread_rwlock_t *l, const struct timespec *ts)
[build]       |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
[build] C:/msys64/mingw64/include/c++/15.1.0/shared_mutex:115:3: error: 'int std::__glibcxx_rwlock_timedwrlock(pthread_rwlock_t*, const timespec*)' exposes TU-local entity 'int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const timespec*)'
[build]   115 |   __glibcxx_rwlock_timedwrlock (pthread_rwlock_t *__rwlock,
[build]       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] C:/msys64/mingw64/include/pthread.h:285:28: note: 'int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const timespec*)' declared with internal linkage
[build]   285 | WINPTHREAD_RWLOCK_DECL int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *ts)
[build]       |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
[build] In file included from C:/msys64/mingw64/include/c++/15.1.0/bits/atomic_timed_wait.h:41,
[build]                  from C:/msys64/mingw64/include/c++/15.1.0/bits/semaphore_base.h:40,
[build]                  from C:/msys64/mingw64/include/c++/15.1.0/semaphore:39,
[build]                  from C:/msys64/mingw64/include/c++/15.1.0/stop_token:42,
[build]                  from C:/msys64/mingw64/include/c++/15.1.0/condition_variable:51,
[build]                  from C:/msys64/mingw64/include/c++/15.1.0/x86_64-w64-mingw32/bits/stdc++.h:177:
[build] C:/msys64/mingw64/include/c++/15.1.0/bits/this_thread_sleep.h:70:7: error: 'void std::this_thread::sleep_for(const std::chrono::duration<_Rep1, _Period1>&) [with _Rep = long long int; _Period = std::ratio<1, 1000>]' exposes TU-local entity 'int nanosleep(const timespec*, timespec*)'
[build]    70 |       sleep_for(const chrono::duration<_Rep, _Period>& __rtime)
[build]       |       ^~~~~~~~~
[build] In file included from C:/msys64/mingw64/include/time.h:323,
[build]                  from C:/msys64/mingw64/include/pthread.h:69:
[build] C:/msys64/mingw64/include/pthread_time.h:79:39: note: 'int nanosleep(const timespec*, timespec*)' declared with internal linkage
[build]    79 | WINPTHREAD_NANOSLEEP_DECL int __cdecl nanosleep(const struct timespec *request, struct timespec *remain)
[build]       |                                       ^~~~~~~~~
[build] C:/msys64/mingw64/include/c++/15.1.0/bits/this_thread_sleep.h:70:7: error: 'template<class _Rep, class _Period> void std::this_thread::sleep_for(const std::chrono::duration<_Rep1, _Period1>&)' exposes TU-local entity 'int nanosleep(const timespec*, timespec*)'
[build]    70 |       sleep_for(const chrono::duration<_Rep, _Period>& __rtime)
[build]       |       ^~~~~~~~~
[build] C:/msys64/mingw64/include/pthread_time.h:79:39: note: 'int nanosleep(const timespec*, timespec*)' declared with internal linkage
[build]    79 | WINPTHREAD_NANOSLEEP_DECL int __cdecl nanosleep(const struct timespec *request, struct timespec *remain)
[build]       |                                       ^~~~~~~~~
[build] C:/msys64/mingw64/include/c++/15.1.0/bits/this_thread_sleep.h:70:7: error: 'void std::this_thread::sleep_for(const std::chrono::duration<_Rep1, _Period1>&) [with _Rep = long long int; _Period = std::ratio<1, 1000000000>]' exposes TU-local entity 'int nanosleep(const timespec*, timespec*)'
[build]    70 |       sleep_for(const chrono::duration<_Rep, _Period>& __rtime)
[build]       |       ^~~~~~~~~
[build] C:/msys64/mingw64/include/pthread_time.h:79:39: note: 'int nanosleep(const timespec*, timespec*)' declared with internal linkage
[build]    79 | WINPTHREAD_NANOSLEEP_DECL int __cdecl nanosleep(const struct timespec *request, struct timespec *remain)
[build]       |                                       ^~~~~~~~~
[build] C:/msys64/mingw64/include/c++/15.1.0/x86_64-w64-mingw32/bits/gthr-default.h:915:1: error: 'int __gthread_cond_timedwait(__gthread_cond_t*, __gthread_mutex_t*, const __gthread_time_t*)' exposes TU-local entity 'int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, const timespec*)'
[build]   915 | __gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex,
[build]       | ^~~~~~~~~~~~~~~~~~~~~~~~
[build] C:/msys64/mingw64/include/pthread.h:316:26: note: 'int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, const timespec*)' declared with internal linkage
[build]   316 | WINPTHREAD_COND_DECL int pthread_cond_timedwait(pthread_cond_t *cv, pthread_mutex_t *external_mutex, const struct timespec *t)
[build]       |                          ^~~~~~~~~~~~~~~~~~~~~~
[build] C:/msys64/mingw64/include/c++/15.1.0/x86_64-w64-mingw32/bits/gthr-default.h:811:1: error: 'int __gthread_mutex_timedlock(__gthread_mutex_t*, const __gthread_time_t*)' exposes TU-local entity 'int pthread_mutex_timedlock(pthread_mutex_t*, const timespec*)'
[build]   811 | __gthread_mutex_timedlock (__gthread_mutex_t *__mutex,
[build]       | ^~~~~~~~~~~~~~~~~~~~~~~~~
[build] C:/msys64/mingw64/include/pthread.h:338:27: note: 'int pthread_mutex_timedlock(pthread_mutex_t*, const timespec*)' declared with internal linkage
[proc] The command: C:\msys64\mingw64\bin\cmake.exe --build c:/Users/diego/Documents/Utilita/Sorgente/mingw/prova_import_std_2/build --config Debug --target all -- exited with code: 1
[build]   338 | WINPTHREAD_MUTEX_DECL int pthread_mutex_timedlock(pthread_mutex_t *m, const struct timespec *ts)
[build]       |                           ^~~~~~~~~~~~~~~~~~~~~~~
[build] ninja: build stopped: subcommand failed.
[driver] Build completed: 00:00:02.784
[build] Build finished with exit code 1

Verification

Windows Version

MINGW64_NT-10.0-19045

MINGW environments affected

  • MINGW64
  • MINGW32
  • UCRT64
  • CLANG64
  • CLANGARM64

Are you willing to submit a PR?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions