From 1c0c3831b64f6ca917ae27a5c1e9dbb6260fa38c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 25 Oct 2022 09:03:39 +0200 Subject: [PATCH] Revert "deps: make V8 compilable with older glibc" This reverts commit 84d455e08e4129f7d1b3c68d62cbb129458619ec. --- common.gypi | 2 +- deps/v8/src/base/platform/platform-posix.cc | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/common.gypi b/common.gypi index 169f7da9c41785..0df1792137febf 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.17', + 'v8_embedder_string': '-node.18', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/base/platform/platform-posix.cc b/deps/v8/src/base/platform/platform-posix.cc index cb95c8635015af..d37b6219d410a7 100644 --- a/deps/v8/src/base/platform/platform-posix.cc +++ b/deps/v8/src/base/platform/platform-posix.cc @@ -618,7 +618,26 @@ void OS::FreeAddressSpaceReservation(AddressSpaceReservation reservation) { // Need to disable CFI_ICALL due to the indirect call to memfd_create. DISABLE_CFI_ICALL PlatformSharedMemoryHandle OS::CreateSharedMemoryHandleForTesting(size_t size) { +#if V8_OS_LINUX && !V8_OS_ANDROID + // Use memfd_create if available, otherwise mkstemp. + using memfd_create_t = int (*)(const char*, unsigned int); + memfd_create_t memfd_create = + reinterpret_cast(dlsym(RTLD_DEFAULT, "memfd_create")); + int fd = -1; + if (memfd_create) { + fd = memfd_create("V8MemFDForTesting", 0); + } + if (fd == -1) { + char filename[] = "/tmp/v8_tmp_file_for_testing_XXXXXX"; + fd = mkstemp(filename); + if (fd != -1) CHECK_EQ(0, unlink(filename)); + } + if (fd == -1) return kInvalidSharedMemoryHandle; + CHECK_EQ(0, ftruncate(fd, size)); + return SharedMemoryHandleFromFileDescriptor(fd); +#else return kInvalidSharedMemoryHandle; +#endif } // static