Skip to content

Filter host libstdc++ ABI flag in rustc_llvm cross builds#158808

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
chitao1234:fix-rustc-llvm-cross-libstdcxx-abi
Jul 21, 2026
Merged

Filter host libstdc++ ABI flag in rustc_llvm cross builds#158808
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
chitao1234:fix-rustc-llvm-cross-libstdcxx-abi

Conversation

@chitao1234

Copy link
Copy Markdown
Contributor

compiler/rustc_llvm/build.rs invokes llvm-config for the build host machine in cross compilation scenarios. In particular, the normal LLVM configuration on Linux sets _GLIBCXX_USE_CXX11_ABI=1 and those flags would then pollute C++ wrapper objects being compiled for the target.

This patch makes rustc_llvm avoid propagating that macro when cross-compiling. This follows the existing pattern in rustc_llvm/build.rs, which already treats parts of cross llvm-config output as host-specific by filtering -m* flags and rewriting include paths. Although I think the more appropriate approach is to use a separate target LLVM C++ flags setting.

This currently affects Haiku rustc cross-compilation from Linux hosts. The Haiku target currently uses the old libstdc++ string ABI by default and that creates an ABI mismatch. I currently work around this locally by setting environment variable CXXFLAGS_x86_64_unknown_haiku=-D_GLIBCXX_USE_CXX11_ABI=0.

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 5, 2026
@rustbot

rustbot commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @cuviper (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @cuviper

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 5, 2026

@cuviper cuviper left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems fine, thanks!

@bors r+ rollup

View changes since this review

@rust-bors

rust-bors Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

📌 Commit b1a5d85 has been approved by cuviper

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 20, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 21, 2026
Rollup of 14 pull requests

Successful merges:

 - #159307 (Improve cross-namespace name diagnostics)
 - #159543 (Remove extra semicolons in parsing item lists)
 - #157270 (ergonomic_clones_dotuse_capture_by_ref: Capture upvar by ref for `.use` in non-move closures)
 - #158496 (Move `check_rustc_pub_transparent` into the attribute parser)
 - #158547 (Move `std::io::buffered` to `alloc::io`)
 - #158808 (Filter host libstdc++ ABI flag in rustc_llvm cross builds)
 - #159362 (Add regression test for #120328)
 - #159472 (Support creating float constants in rustc_public mir)
 - #159505 (make rustdoc::bare_urls strip trailing periods from url)
 - #159568 (Suggest close compiler options)
 - #159578 (Extract coroutine closure helper functions)
 - #159601 (Make `TokenTreeCursor` private)
 - #159613 (Set the rustc lib path for unstable-book-gen)
 - #159616 (Clarify the comment about stage1/stage2 discrepancy in input-stats test)
@rust-bors
rust-bors Bot merged commit 5f9254e into rust-lang:main Jul 21, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 21, 2026
rust-timer added a commit that referenced this pull request Jul 21, 2026
Rollup merge of #158808 - chitao1234:fix-rustc-llvm-cross-libstdcxx-abi, r=cuviper

Filter host libstdc++ ABI flag in rustc_llvm cross builds

`compiler/rustc_llvm/build.rs` invokes `llvm-config` for the build host machine in cross compilation scenarios. In particular, the normal LLVM configuration on Linux sets `_GLIBCXX_USE_CXX11_ABI=1` and those flags would then pollute C++ wrapper objects being compiled for the target.

This patch makes `rustc_llvm` avoid propagating that macro when cross-compiling. This follows the existing pattern in `rustc_llvm/build.rs`, which already treats parts of cross `llvm-config` output as host-specific by filtering `-m*` flags and rewriting include paths. Although I think the more appropriate approach is to use a separate target LLVM C++ flags setting.

This currently affects Haiku rustc cross-compilation from Linux hosts. The Haiku target currently uses the old libstdc++ string ABI by default and that creates an ABI mismatch. I currently work around this locally by setting environment variable `CXXFLAGS_x86_64_unknown_haiku=-D_GLIBCXX_USE_CXX11_ABI=0`.
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Jul 22, 2026
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#159307 (Improve cross-namespace name diagnostics)
 - rust-lang/rust#159543 (Remove extra semicolons in parsing item lists)
 - rust-lang/rust#157270 (ergonomic_clones_dotuse_capture_by_ref: Capture upvar by ref for `.use` in non-move closures)
 - rust-lang/rust#158496 (Move `check_rustc_pub_transparent` into the attribute parser)
 - rust-lang/rust#158547 (Move `std::io::buffered` to `alloc::io`)
 - rust-lang/rust#158808 (Filter host libstdc++ ABI flag in rustc_llvm cross builds)
 - rust-lang/rust#159362 (Add regression test for rust-lang/rust#120328)
 - rust-lang/rust#159472 (Support creating float constants in rustc_public mir)
 - rust-lang/rust#159505 (make rustdoc::bare_urls strip trailing periods from url)
 - rust-lang/rust#159568 (Suggest close compiler options)
 - rust-lang/rust#159578 (Extract coroutine closure helper functions)
 - rust-lang/rust#159601 (Make `TokenTreeCursor` private)
 - rust-lang/rust#159613 (Set the rustc lib path for unstable-book-gen)
 - rust-lang/rust#159616 (Clarify the comment about stage1/stage2 discrepancy in input-stats test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants