FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

build: remove duplicate C++ standard flags from LIEF by omghante · Pull Request #62682 · nodejs/node · GitHub

/ node Public

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

Open
omghante wants to merge 1 commit into
nodejs:mainfrom
omghante:fix/62129-lief-duplicate-cpp-standard-flags
Open

build: remove duplicate C++ standard flags from LIEF#62682
omghante wants to merge 1 commit into
nodejs:mainfrom
omghante:fix/62129-lief-duplicate-cpp-standard-flags

Conversation

omghante commented Apr 10, 2026
edited
Loading

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

Copy link
Copy Markdown
Collaborator

Review requested:

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

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 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 force-pushed the fix/62129-lief-duplicate-cpp-standard-flags branch from b5e63d3 to 09692f5 Compare April 14, 2026 20:13

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!

Copy link
Copy Markdown
Member

Can you upstream the changes to deps/LIEF to LIEF first? After it goes out in a LIEF release you can run tools/dep_updaters/update-lief.sh to pull it into the deps folder.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

3 participants


Back | FazBrowse Home | New Git URL