Skip to content

Conversation

hitgil
Copy link
Contributor

@hitgil hitgil commented Jul 31, 2025

Description

Fixes: #4863

Skip try_run() when cross-compiling, as it leads to configuration errors when detecting the C++ standard library version (LIBCPP_VERSION_OUTPUT).

When CMAKE_CROSSCOMPILING is set, try_run() fails because it cannot execute the compiled binary on the build host. This patch adds a conditional to bypass try_run() and sets the fallback value directly, avoiding configuration failure during the first run.


  • The changes are described in detail, both the what and why.
  • An existing issue is referenced.
  • The Code coverage remained at 100%. (No runtime logic modified)
  • The documentation is not affected by this change.
  • The source code is amalgamated by running make amalgamate. (Not applicable, this is a build script change)

@nlohmann
Copy link
Owner

Please also follow these instructions to satisfy the DCO check.

@hitgil hitgil force-pushed the fix-4863-libcpp-version-output branch from 0fb89d9 to 0c0b119 Compare July 31, 2025 13:15
@github-actions github-actions bot added S and removed M labels Jul 31, 2025
@hitgil hitgil requested a review from nlohmann July 31, 2025 14:15
@nlohmann
Copy link
Owner

Thanks a lot! The CI will be red, because #4871 is not yet merged. Don't worry about that.

@coveralls
Copy link

coveralls commented Jul 31, 2025

Coverage Status

coverage: 99.19%. remained the same
when pulling 6a7768f on hitgil:fix-4863-libcpp-version-output
into c637a8b on nlohmann:develop.

@nlohmann
Copy link
Owner

Please rebase to the latest develop branch as I just merged #4871.

@nlohmann nlohmann added the please rebase Please rebase your branch to origin/develop label Jul 31, 2025
@hitgil hitgil force-pushed the fix-4863-libcpp-version-output branch from 8dd4ce4 to 6a7768f Compare August 1, 2025 03:34
@nlohmann nlohmann removed the please rebase Please rebase your branch to origin/develop label Aug 1, 2025
Copy link
Owner

@nlohmann nlohmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@nlohmann nlohmann added this to the Release 3.12.1 milestone Aug 1, 2025
@nlohmann nlohmann merged commit 55abcb5 into nlohmann:develop Aug 1, 2025
129 checks passed
aryanrahar pushed a commit to aryanrahar/json-add that referenced this pull request Aug 6, 2025
…s compil… (nlohmann#4876)

* Fix nlohmann#4863: skip try_run for LIBCPP_VERSION_OUTPUT during cross compilation

Signed-off-by: Hitgirl <[email protected]>

* fix nlohmann#4863: handle cross-compiling in libc++ detection gracefully

Signed-off-by: Hitgirl <[email protected]>

* refactor: move cross-compiling check before cached output detection

Signed-off-by: Hitgirl <[email protected]>

* refactor: move cross-compiling check before cached output detection

Signed-off-by: Hitgirl <[email protected]>

* refactor: move cross-compiling check before cached output detection

Signed-off-by: Hitgirl <[email protected]>

---------

Signed-off-by: Hitgirl <[email protected]>
Co-authored-by: Hitgirl <[email protected]>
aryanrahar pushed a commit to aryanrahar/json-add that referenced this pull request Aug 7, 2025
…s compil… (nlohmann#4876)

* Fix nlohmann#4863: skip try_run for LIBCPP_VERSION_OUTPUT during cross compilation

Signed-off-by: Hitgirl <[email protected]>

* fix nlohmann#4863: handle cross-compiling in libc++ detection gracefully

Signed-off-by: Hitgirl <[email protected]>

* refactor: move cross-compiling check before cached output detection

Signed-off-by: Hitgirl <[email protected]>

* refactor: move cross-compiling check before cached output detection

Signed-off-by: Hitgirl <[email protected]>

* refactor: move cross-compiling check before cached output detection

Signed-off-by: Hitgirl <[email protected]>

---------

Signed-off-by: Hitgirl <[email protected]>
Co-authored-by: Hitgirl <[email protected]>
aryanrahar pushed a commit to aryanrahar/json-add that referenced this pull request Aug 7, 2025
…s compil… (nlohmann#4876)

* Fix nlohmann#4863: skip try_run for LIBCPP_VERSION_OUTPUT during cross compilation

Signed-off-by: Hitgirl <[email protected]>

* fix nlohmann#4863: handle cross-compiling in libc++ detection gracefully

Signed-off-by: Hitgirl <[email protected]>

* refactor: move cross-compiling check before cached output detection

Signed-off-by: Hitgirl <[email protected]>

* refactor: move cross-compiling check before cached output detection

Signed-off-by: Hitgirl <[email protected]>

* refactor: move cross-compiling check before cached output detection

Signed-off-by: Hitgirl <[email protected]>

---------

Signed-off-by: Hitgirl <[email protected]>
Co-authored-by: Hitgirl <[email protected]>
Signed-off-by: Aryan Rahar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LIBCPP_VERSION_OUTPUT breaks cross-compilation and is not used anywhere
3 participants