Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

build: remove duplicate C++ standard flags from LIEF#62682

Open
omghante wants to merge 1 commit into
nodejs:mainnodejs/node:mainfrom
omghante:fix/62129-lief-duplicate-cpp-standard-flagsomghante/node:fix/62129-lief-duplicate-cpp-standard-flagsCopy head branch name to clipboard
Open

build: remove duplicate C++ standard flags from LIEF#62682
omghante wants to merge 1 commit into
nodejs:mainnodejs/node:mainfrom
omghante:fix/62129-lief-duplicate-cpp-standard-flagsomghante/node:fix/62129-lief-duplicate-cpp-standard-flagsCopy head branch name to clipboard

Conversation

@omghante

@omghante omghante commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

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.

Additionally, upgrading LIEF to C++20 triggered compile-time conflicts in Section.cpp on modern compilers (like GCC 14 and Xcode 16.4) due to overlapping definitions between {fmt} and C++20 std::format.

Changes

  • Removed -std=gnu++17 from cflags_cc and xcode_settings.OTHER_CPLUSPLUSFLAGS.
  • Removed the msvs_settings LanguageStandard: stdcpp17 override.
  • Removed the now-inaccurate comment about needing C++17.
  • Fixed C++20 compilation failures: Removed using namespace fmt; and explicitly qualified fmt::format and fmt::join inside deps/LIEF/src/PE/Section.cpp. Joined sequence views are now cleanly materialized into std::string objects prior to formatting. This completely prevents the compiler from evaluating {fmt} function calls under C++20's strict std::format compile-time rules, resolving the CI build crash on Linux ARM, macOS, and Windows.

Why C++20 is safe for LIEF

SPDLOG_USE_STD_FORMAT is not defined in the build, so spdlog uses its
bundled fmt library rather than <format>, avoiding any C++20 conflicts once the Section.cpp syntax is properly isolated.

Risk

LIEF was previously compiling as C++17 (last flag wins). With this change it
will compile as C++20. While C++20 is a superset, reviewers should confirm
no subtle deprecations or narrowing issues arise.

Note: A separate stray debug string issue in the same file is addressed
in PR #62683.

Fixes: #62129

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/gyp
  • @nodejs/security-wg
  • @nodejs/single-executable

@nodejs-github-bot nodejs-github-bot added dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run. labels Apr 10, 2026
omghante added a commit to omghante/node that referenced this pull request Apr 10, 2026
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: nodejs#62682
@omghante omghante force-pushed the fix/62129-lief-duplicate-cpp-standard-flags branch 5 times, most recently from d862bf2 to b5e63d3 Compare April 14, 2026 18:58
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: nodejs#62129
@omghante omghante force-pushed the fix/62129-lief-duplicate-cpp-standard-flags branch from b5e63d3 to 09692f5 Compare April 14, 2026 20:13
@omghante

omghante commented May 1, 2026

Copy link
Copy Markdown
Contributor Author

Gentle ping this PR has been open for 3 weeks without any review.

This is the companion fix to #62683 (which landed) together they fully
resolve #62129. While #62683 fixed the stray debug string, this PR addresses
the actual dual-standard-flag issue where LIEF was silently compiling as
C++17 instead of the project-wide C++20 due to duplicate -std=gnu++17
flags in lief.gyp.

The fix also resolves C++20 compilation failures on GCC 14 and Xcode 16.4
by explicitly qualifying fmt::format / fmt::join in Section.cpp to
avoid conflicts with std::format.

The change touches 7 files but is a net -8 lines (removing overrides). CI
is green and the risk is documented in the PR description.

@joyeecheung @richardlau @lpinca since you all reviewed the related
#62683, would you be able to take a look at this follow-up as well?
@targos this completes the fix for the dual-standard-flag issue you
reported in #62129. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LIEF is built with two C++ standard version flags

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.