https://gcc.gnu.org/g:9d450dee7112635a541c5a34268d54f63da48f71
commit r15-7233-g9d450dee7112635a541c5a34268d54f63da48f71 Author: John David Anglin <dang...@gcc.gnu.org> Date: Mon Jan 27 12:39:00 2025 -0500 c++: Use mapped reads and writes when munmap and msync are available Module support is broken when MAPPED_READING and MAPPED_WRITING are defined to 0. This causes internal compiler errors in the permissive-error-1.C and permissive-error-2.C tests. HP-UX 11.11 doesn't define _POSIX_MAPPED_FILES but it does have munmap and msync. Testing indicates support is sufficient for c++ modules, so use checks for these functions instead of _POSIX_MAPPED_FILES check. 2025-01-27 John David Anglin <dang...@gcc.gnu.org> gcc/ChangeLog: PR c++/116524 * configure.ac: Check for munmap and msync. * configure: Regenerate. * config.in: Regenerate. gcc/cp/ChangeLog: * module.cc: Test HAVE_MUNMAP and HAVE_MSYNC instead of _POSIX_MAPPED_FILES > 0. Diff: --- gcc/config.in | 12 ++++++++++++ gcc/configure | 2 +- gcc/configure.ac | 2 +- gcc/cp/module.cc | 6 +++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/gcc/config.in b/gcc/config.in index 44de5a546116..3b06533c4829 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1972,6 +1972,18 @@ #endif +/* Define to 1 if you have the `msync' function. */ +#ifndef USED_FOR_TARGET +#undef HAVE_MSYNC +#endif + + +/* Define to 1 if you have the `munmap' function. */ +#ifndef USED_FOR_TARGET +#undef HAVE_MUNMAP +#endif + + /* Define if GCC has been configured with --enable-newlib-nano-formatted-io. */ #ifndef USED_FOR_TARGET diff --git a/gcc/configure b/gcc/configure index b4c52de62184..e36d1d91612a 100755 --- a/gcc/configure +++ b/gcc/configure @@ -10637,7 +10637,7 @@ for ac_func in times clock kill getrlimit setrlimit atoq \ popen sysconf strsignal getrusage nl_langinfo \ gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \ clearerr_unlocked feof_unlocked ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked putchar_unlocked putc_unlocked madvise mallinfo mallinfo2 fstatat getauxval \ - clock_gettime + clock_gettime munmap msync do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/gcc/configure.ac b/gcc/configure.ac index 6c38c4925fb3..8fab93c93654 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1574,7 +1574,7 @@ AC_CHECK_FUNCS(times clock kill getrlimit setrlimit atoq \ popen sysconf strsignal getrusage nl_langinfo \ gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \ gcc_UNLOCKED_FUNCS madvise mallinfo mallinfo2 fstatat getauxval \ - clock_gettime) + clock_gettime munmap msync) # At least for glibc, clock_gettime is in librt. But don't pull that # in if it still doesn't give us the function we want. diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 312ff6687508..59716e1873e9 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -241,11 +241,11 @@ Classes used: #define MAPPED_READING 0 #define MAPPED_WRITING 0 #else -#if HAVE_MMAP_FILE && _POSIX_MAPPED_FILES > 0 -/* mmap, munmap. */ +#if HAVE_MMAP_FILE && HAVE_MUNMAP && HAVE_MSYNC +/* mmap, munmap, msync. */ #define MAPPED_READING 1 #if HAVE_SYSCONF && defined (_SC_PAGE_SIZE) -/* msync, sysconf (_SC_PAGE_SIZE), ftruncate */ +/* sysconf (_SC_PAGE_SIZE), ftruncate */ /* posix_fallocate used if available. */ #define MAPPED_WRITING 1 #else