https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95244

            Bug ID: 95244
           Summary: GCC 10 no longer builds on RHEL5 [trivial patch]
           Product: gcc
           Version: 10.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: bootstrap
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lopresti at gmail dot com
  Target Milestone: ---

I still compile GCC on Red Hat Enterprise Linux 5. It is an EoL platform, so
maybe you do not care... But the only problem (introduced with GCC 10) is the
lack of O_CLOEXEC. The following patch fixes my build:

diff --git a/libsanitizer/sanitizer_common/sanitizer_posix.cpp
b/libsanitizer/sanitizer_common/sanitizer_posix.cpp
index d890a3a3177..6ba525d1811 100644
--- a/libsanitizer/sanitizer_common/sanitizer_posix.cpp
+++ b/libsanitizer/sanitizer_common/sanitizer_posix.cpp
@@ -347,8 +347,14 @@ int GetNamedMappingFd(const char *name, uptr size, int
*flags) {
   CHECK(internal_strlen(name) < sizeof(shmname) - 10);
   internal_snprintf(shmname, sizeof(shmname), "/dev/shm/%zu [%s]",
                     internal_getpid(), name);
+#if defined O_CLOEXEC
   int fd = ReserveStandardFds(
       internal_open(shmname, O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC,
S_IRWXU));
+#else
+  int fd = ReserveStandardFds(
+      internal_open(shmname, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU));
+  fcntl(fd, F_SETFD, FD_CLOEXEC);
+#endif

I would be happy to make this a pull request if there is any chance it would
get accepted. Thanks.

Reply via email to