From c5924998c6d2f220cf2cf2726ec60877ef128e96 Mon Sep 17 00:00:00 2001 From: om-ghante Date: Sat, 11 Apr 2026 02:46:45 +0530 Subject: [PATCH 1/2] build: remove duplicate C++ standard flags from LIEF LIEF's lief.gyp explicitly sets -std=gnu++17 in cflags_cc and xcode_settings, while common.gypi already sets -std=gnu++20 project-wide. This results in both flags being passed to the compiler (-std=gnu++20 -std=gnu++17). Since the last flag wins, LIEF was silently compiling as C++17 instead of the intended project-wide C++20. Remove the explicit -std=gnu++17 flags from cflags_cc and xcode_settings.OTHER_CPLUSPLUSFLAGS, and the msvs_settings LanguageStandard override (stdcpp17), so LIEF uses the project-wide C++20 standard. LIEF is compatible with C++20 because SPDLOG_USE_STD_FORMAT is not defined, so spdlog uses its bundled fmt library rather than std::format, avoiding any C++20 conflicts. Note: a separate issue with a stray debug string in the defines list is addressed in a follow-up PR. Fixes: https://github.com/nodejs/node/issues/62129 --- deps/LIEF/lief.gyp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/deps/LIEF/lief.gyp b/deps/LIEF/lief.gyp index 3864c0e538a588..c02a27375a7697 100644 --- a/deps/LIEF/lief.gyp +++ b/deps/LIEF/lief.gyp @@ -454,14 +454,7 @@ 'cflags': [ '-fPIC' ], - # We need c++17 to compile without std::format and avoid conflicts with spdlog. - 'msvs_settings': { - 'VCCLCompilerTool': { - 'LanguageStandard': 'stdcpp17', - }, - }, 'cflags_cc': [ - '-std=gnu++17', '-fPIC', '-fvisibility=hidden', '-fvisibility-inlines-hidden', @@ -474,7 +467,6 @@ ], 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS': [ - '-std=gnu++17', '-fPIC', '-fvisibility=hidden', '-fvisibility-inlines-hidden', From 0437529cbfb2e63bbd1392d25556b7fed132b99a Mon Sep 17 00:00:00 2001 From: om-ghante Date: Sat, 11 Apr 2026 04:54:26 +0530 Subject: [PATCH 2/2] build: fix LIEF compilation failure with C++20 and {fmt} When building LIEF with C++20 standard, the unqualified calls to `format` and `join` in `Section.cpp` conflict with the C++20 `std::format` header provided by libstdc++ and MSVC. `std::format` attempts to evaluate these calls at compile time but fails because `fmt::join_view` is not a valid `std::formatter` type. Explicitly use `fmt::format` and `fmt::join`, and convert the joined views into `std::string` values prior to passing them into the final formatting calls to prevent the compiler from instantiating `std::format`. Fixes CI build failures on Linux ARM, macOS, and Windows. Refs: https://github.com/nodejs/node/pull/62682 --- deps/LIEF/src/PE/Section.cpp | 38 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/deps/LIEF/src/PE/Section.cpp b/deps/LIEF/src/PE/Section.cpp index 0239855294ade4..77ded6d879f306 100644 --- a/deps/LIEF/src/PE/Section.cpp +++ b/deps/LIEF/src/PE/Section.cpp @@ -126,7 +126,6 @@ void Section::clear(uint8_t c) { } std::ostream& operator<<(std::ostream& os, const Section& section) { - using namespace fmt; static constexpr auto WIDTH = 24; const auto& list = section.characteristics_list(); std::vector list_str; @@ -138,29 +137,34 @@ std::ostream& operator<<(std::ostream& os, const Section& section) { fullname_hex.reserve(section.name().size()); std::transform(section.fullname().begin(), section.fullname().end(), std::back_inserter(fullname_hex), - [] (const char c) { return format("{:02x}", c); }); + [] (const char c) { return fmt::format("{:02x}", c); }); + + const std::string fullname_hex_joined = + fmt::format("{}", fmt::join(fullname_hex, " ")); + const std::string characteristics_joined = + fmt::format("{}", fmt::join(list_str, ", ")); if (const COFF::String* coff_str = section.coff_string()) { - os << format("{:{}} {} ({}, {})\n", "Name:", WIDTH, section.name(), - join(fullname_hex, " "), coff_str->str()); + os << fmt::format("{:{}} {} ({}, {})\n", "Name:", WIDTH, section.name(), + fullname_hex_joined, coff_str->str()); } else { - os << format("{:{}} {} ({})\n", "Name:", WIDTH, section.name(), - join(fullname_hex, " ")); + os << fmt::format("{:{}} {} ({})\n", "Name:", WIDTH, section.name(), + fullname_hex_joined); } - os << format("{:{}} 0x{:x}\n", "Virtual Size", WIDTH, section.virtual_size()) - << format("{:{}} 0x{:x}\n", "Virtual Address", WIDTH, section.virtual_address()) - << format("{:{}} [0x{:08x}, 0x{:08x}]\n", "Range", WIDTH, + os << fmt::format("{:{}} 0x{:x}\n", "Virtual Size", WIDTH, section.virtual_size()) + << fmt::format("{:{}} 0x{:x}\n", "Virtual Address", WIDTH, section.virtual_address()) + << fmt::format("{:{}} [0x{:08x}, 0x{:08x}]\n", "Range", WIDTH, section.virtual_address(), section.virtual_address() + section.virtual_size()) - << format("{:{}} 0x{:x}\n", "Size of raw data", WIDTH, section.sizeof_raw_data()) - << format("{:{}} 0x{:x}\n", "Pointer to raw data", WIDTH, section.pointerto_raw_data()) - << format("{:{}} [0x{:08x}, 0x{:08x}]\n", "Range", WIDTH, + << fmt::format("{:{}} 0x{:x}\n", "Size of raw data", WIDTH, section.sizeof_raw_data()) + << fmt::format("{:{}} 0x{:x}\n", "Pointer to raw data", WIDTH, section.pointerto_raw_data()) + << fmt::format("{:{}} [0x{:08x}, 0x{:08x}]\n", "Range", WIDTH, section.pointerto_raw_data(), section.pointerto_raw_data() + section.sizeof_raw_data()) - << format("{:{}} 0x{:x}\n", "Pointer to relocations", WIDTH, section.pointerto_relocation()) - << format("{:{}} 0x{:x}\n", "Pointer to line numbers", WIDTH, section.pointerto_line_numbers()) - << format("{:{}} 0x{:x}\n", "Number of relocations", WIDTH, section.numberof_relocations()) - << format("{:{}} 0x{:x}\n", "Number of lines", WIDTH, section.numberof_line_numbers()) - << format("{:{}} {}", "Characteristics", WIDTH, join(list_str, ", ")); + << fmt::format("{:{}} 0x{:x}\n", "Pointer to relocations", WIDTH, section.pointerto_relocation()) + << fmt::format("{:{}} 0x{:x}\n", "Pointer to line numbers", WIDTH, section.pointerto_line_numbers()) + << fmt::format("{:{}} 0x{:x}\n", "Number of relocations", WIDTH, section.numberof_relocations()) + << fmt::format("{:{}} 0x{:x}\n", "Number of lines", WIDTH, section.numberof_line_numbers()) + << fmt::format("{:{}} {}", "Characteristics", WIDTH, characteristics_joined); return os; }