]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: modules: Allow for EOPNOTSUPP error from posix_fallocate
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Fri, 10 Jul 2026 17:12:55 +0000 (19:12 +0200)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Fri, 10 Jul 2026 17:12:55 +0000 (19:12 +0200)
All g++/modules tests SEGV on NetBSD/amd64 in a ZFS build directory.
This is similar to the FreeBSD case:

commit a94156b8ee7165c32f73f9cd11c9b8f3b8687d3b
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Tue May 5 10:23:12 2026 +0200

    c++: modules: Fix posix_fallocate error handling

However, posix_fallocate returns EOPNOTSUPP here, which is distinct from
ENOTSUP.

This patch allows for both, providing a fallback definition since
EOPNOTSUPP may be missing.

Bootstrapped without regressions on amd64-pc-netbsd10.1,
x86_64-pc-linux-gnu, and i386-pc-solaris2.11.

2026-07-08  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/cp:
* module.cc (EOPNOTSUPP): Provide fallback.
(elf_out::create_mapping) [HAVE_POSIX_FALLOCATE]: Allow for
EOPNOTSUPP result.

gcc/cp/module.cc

index f250dc3e9dfe23a82626fbb4d466b9472724023b..da0e0e0aae3a74145461e4fcbd9c0a56be55b029 100644 (file)
@@ -258,6 +258,11 @@ Classes used:
 #endif
 #endif
 
+/* Provide fallback.  */
+#ifndef EOPNOTSUPP
+#define EOPNOTSUPP ENOTSUP
+#endif
+
 /* Some open(2) flag differences, what a colourful world it is!  */
 #if defined (O_CLOEXEC)
 // OK
@@ -1912,7 +1917,7 @@ elf_out::create_mapping (unsigned ext, bool extending)
     {
 #ifdef HAVE_POSIX_FALLOCATE
       int result = posix_fallocate (fd, offset, length);
-      if (result != EINVAL && result != ENOTSUP)
+      if (result != EINVAL && result != ENOTSUP && result != EOPNOTSUPP)
        return result == 0;
       /* Not supported by the underlying filesystem, fallback to ftruncate.  */
 #endif