From 09692f57d0d44ce953bba0e1f2f7a83e34d9416b Mon Sep 17 00:00:00 2001 From: om-ghante Date: Tue, 14 Apr 2026 08:03:36 +0530 Subject: [PATCH] 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. Additionally, fix LIEF compilation with C++20 by explicitly qualifying fmt::format and fmt::join in Section.cpp, and converting joined views into std::string values prior to passing them into final formatting calls. This prevents conflicts between fmt::join_view and std::format when compiling under C++20. Fixes: https://github.com/nodejs/node/issues/62129 --- deps/LIEF/lief.gyp | 8 -------- deps/LIEF/src/COFF/Section.cpp | 4 ++-- deps/LIEF/src/MachO/layout_check.cpp | 2 +- deps/LIEF/src/PE/LoadConfigurations/LoadConfiguration.cpp | 2 +- deps/LIEF/src/PE/Section.cpp | 6 +++--- deps/LIEF/src/PE/debug/ExDllCharacteristics.cpp | 2 +- deps/LIEF/src/PE/layout_check.cpp | 2 +- 7 files changed, 9 insertions(+), 17 deletions(-) diff --git a/deps/LIEF/lief.gyp b/deps/LIEF/lief.gyp index 783e97c181d897..00ea8260e23271 100644 --- a/deps/LIEF/lief.gyp +++ b/deps/LIEF/lief.gyp @@ -453,14 +453,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', @@ -473,7 +466,6 @@ ], 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS': [ - '-std=gnu++17', '-fPIC', '-fvisibility=hidden', '-fvisibility-inlines-hidden', diff --git a/deps/LIEF/src/COFF/Section.cpp b/deps/LIEF/src/COFF/Section.cpp index 0a11ba5ca4572e..1a541eb15ca049 100644 --- a/deps/LIEF/src/COFF/Section.cpp +++ b/deps/LIEF/src/COFF/Section.cpp @@ -122,7 +122,7 @@ std::string Section::to_string() const { [] (const char c) { return format("{:02x}", c); }); os << format("{:{}} {} ({})\n", "Name:", WIDTH, name(), - join(fullname_hex, " ")); + fmt::to_string(join(fullname_hex, " "))); os << format("{:{}} 0x{:x}\n", "Virtual Size", WIDTH, virtual_size()) << format("{:{}} 0x{:x}\n", "Virtual Address", WIDTH, virtual_address()) @@ -134,7 +134,7 @@ std::string Section::to_string() const { << format("{:{}} 0x{:x}\n", "Pointer to line numbers", WIDTH, pointerto_line_numbers()) << format("{:{}} 0x{:x}\n", "Number of relocations", WIDTH, numberof_relocations()) << format("{:{}} 0x{:x}\n", "Number of lines", WIDTH, numberof_line_numbers()) - << format("{:{}} {}", "Characteristics", WIDTH, join(list_str, ", ")); + << format("{:{}} {}", "Characteristics", WIDTH, fmt::to_string(join(list_str, ", "))); return os.str(); diff --git a/deps/LIEF/src/MachO/layout_check.cpp b/deps/LIEF/src/MachO/layout_check.cpp index 7fea03c43e08aa..8a344344528fff 100644 --- a/deps/LIEF/src/MachO/layout_check.cpp +++ b/deps/LIEF/src/MachO/layout_check.cpp @@ -86,7 +86,7 @@ class LayoutChecker { template bool error(const char *fmt, const Args &... args) { - error_msg = fmt::format(fmt, args...); + error_msg = fmt::vformat(fmt, fmt::make_format_args(args...)); return false; } diff --git a/deps/LIEF/src/PE/LoadConfigurations/LoadConfiguration.cpp b/deps/LIEF/src/PE/LoadConfigurations/LoadConfiguration.cpp index 07185e03b3c454..05937e9824a9b4 100644 --- a/deps/LIEF/src/PE/LoadConfigurations/LoadConfiguration.cpp +++ b/deps/LIEF/src/PE/LoadConfigurations/LoadConfiguration.cpp @@ -917,7 +917,7 @@ std::string LoadConfiguration::to_string() const { if (auto val = guard_flags(); val && *val != 0) { oss << format("{:{}} {}\n", "Guard Flags:", WIDTH, - fmt::join(guard_cf_flags_list(), ",")); + fmt::to_string(fmt::join(guard_cf_flags_list(), ","))); } if (const CodeIntegrity* CI = code_integrity()) { diff --git a/deps/LIEF/src/PE/Section.cpp b/deps/LIEF/src/PE/Section.cpp index 0239855294ade4..2ed0d74f0e5c23 100644 --- a/deps/LIEF/src/PE/Section.cpp +++ b/deps/LIEF/src/PE/Section.cpp @@ -142,10 +142,10 @@ std::ostream& operator<<(std::ostream& os, const Section& section) { if (const COFF::String* coff_str = section.coff_string()) { os << format("{:{}} {} ({}, {})\n", "Name:", WIDTH, section.name(), - join(fullname_hex, " "), coff_str->str()); + fmt::to_string(join(fullname_hex, " ")), coff_str->str()); } else { os << format("{:{}} {} ({})\n", "Name:", WIDTH, section.name(), - join(fullname_hex, " ")); + fmt::to_string(join(fullname_hex, " "))); } os << format("{:{}} 0x{:x}\n", "Virtual Size", WIDTH, section.virtual_size()) @@ -160,7 +160,7 @@ std::ostream& operator<<(std::ostream& os, const Section& section) { << 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, ", ")); + << format("{:{}} {}", "Characteristics", WIDTH, fmt::to_string(join(list_str, ", "))); return os; } diff --git a/deps/LIEF/src/PE/debug/ExDllCharacteristics.cpp b/deps/LIEF/src/PE/debug/ExDllCharacteristics.cpp index e148258b832bb1..a4e09693bdc766 100644 --- a/deps/LIEF/src/PE/debug/ExDllCharacteristics.cpp +++ b/deps/LIEF/src/PE/debug/ExDllCharacteristics.cpp @@ -59,7 +59,7 @@ std::string ExDllCharacteristics::to_string() const { std::ostringstream os; using namespace fmt; os << Debug::to_string() << '\n' - << format(" Characteristics: {}", join(characteristics_list(), ", ")); + << format(" Characteristics: {}", fmt::to_string(join(characteristics_list(), ", "))); return os.str(); } diff --git a/deps/LIEF/src/PE/layout_check.cpp b/deps/LIEF/src/PE/layout_check.cpp index 6d0b526c265b7a..6e7676f7352b24 100644 --- a/deps/LIEF/src/PE/layout_check.cpp +++ b/deps/LIEF/src/PE/layout_check.cpp @@ -106,7 +106,7 @@ class LayoutChecker { template bool error(const char *fmt, const Args &... args) { - error_msg = fmt::format(fmt, args...); + error_msg = fmt::vformat(fmt, fmt::make_format_args(args...)); return false; }