Skip to content

Conversation

rafaeling
Copy link
Contributor

@rafaeling rafaeling commented Jul 23, 2025

When cross-compiling for the x86_64/aarch64-unknown-nto-qnx800 target (QNX SDP 8.0), the build fails during the final link stage with the error:

error: linking with `qcc` failed: exit status: 1
  ...
  = note: undefined reference to `__my_thread_exit'
  • On QNX 7.1: The __my_thread_exit symbol is defined and exported by the main C library (libc.a/libc.so). The std backtrace code can therefore successfully take its address at compile time.

  • On QNX 8.0: As part of a toolchain modernization, this symbol has been refactored. It is no longer present in any of the standard system libraries (.a or .so).

This patch addresses the problem at its source by conditionally compiling the problematic code.

Fixes #142726

@rustbot
Copy link
Collaborator

rustbot commented Jul 23, 2025

r? @tgross35

rustbot has assigned @tgross35.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 23, 2025
@rustbot

This comment has been minimized.

@rafaeling rafaeling force-pushed the fix-142726-qnx8-link-fail branch from 58ae39f to 43fab36 Compare July 24, 2025 07:40
@tgross35
Copy link
Contributor

This seems reasonable to me, pinging the target maintainers to make sure: @flba-eb @jonathanpallant

@flba-eb
Copy link
Contributor

flba-eb commented Jul 31, 2025

In general I think this is fine. Instead of excluding QNX8.0 it could be better to only include QNX 7.0 and 7.1: If the new implementation is more modern than the previous one as @rafaeling suggests, it is likely future versions will keep the new behavior. Hence I suggest to use any(target_env = "nto70", target_env = "nto71") instead of not(target_env = "nto80").

Currently, only QNX 7.0 and 7.1 are supported by Rust (and stack unwinding probably only in 7.1).

@tgross35
Copy link
Contributor

tgross35 commented Aug 1, 2025

To incorperate the above feedback,
@rustbot author

(please squash after)

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 1, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

This commit adds an empty stub for the  function
for QNX 8 targets. This symbol is required by the unwinder but is
not present, causing a linking failure when building with the
standard library.

Address review feedback: use whitelist for QNX versions
@rafaeling rafaeling force-pushed the fix-142726-qnx8-link-fail branch from 43fab36 to 17c8667 Compare August 25, 2025 08:36
@rustbot
Copy link
Collaborator

rustbot commented Aug 25, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rafaeling
Copy link
Contributor Author

rafaeling commented Aug 25, 2025

@rustbot ready @flba-eb

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 25, 2025
@tgross35
Copy link
Contributor

LGTM but I'll wait for @flba-eb to ack

@tgross35
Copy link
Contributor

It's been a few days, seems like this is a pretty sever bug so let's get the fix in.

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Aug 28, 2025

📌 Commit 17c8667 has been approved by tgross35

It is now in the queue for this repository.

@bors bors 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 Aug 28, 2025
bors added a commit that referenced this pull request Aug 29, 2025
Rollup of 9 pull requests

Successful merges:

 - #143713 (Add a mailmap entry for gnzlbg)
 - #144275 (implement Sum and Product for Saturating(u*))
 - #144354 (fix(std): Fix undefined reference to __my_thread_exit on QNX 8.0)
 - #145387 (Remove TmpLayout in layout_of_enum)
 - #145793 (std library: use execinfo library also on NetBSD.)
 - #145884 (Test `instrument-mcount` codegen)
 - #145947 (Add more to the `[workspace.dependencies]` section in the top-level `Cargo.toml`)
 - #145972 (fix `core::marker::Destruct` doc)
 - #145977 (tests: Ignore basic-stepping.rs on riscv64)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6ac6eb6 into rust-lang:master Aug 29, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 29, 2025
rust-timer added a commit that referenced this pull request Aug 29, 2025
Rollup merge of #144354 - rafaeling:fix-142726-qnx8-link-fail, r=tgross35

fix(std): Fix undefined reference to __my_thread_exit on QNX 8.0

When cross-compiling for the x86_64/aarch64-unknown-nto-qnx800 target (QNX SDP 8.0), the build fails during the final link stage with the error:
```
error: linking with `qcc` failed: exit status: 1
  ...
  = note: undefined reference to `__my_thread_exit'
 ```

- **On QNX 7.1**: The __my_thread_exit symbol is defined and exported by the main C library (libc.a/libc.so). The std backtrace code can therefore successfully take its address at compile time.

- **On QNX 8.0**: As part of a toolchain modernization, this symbol has been refactored. It is no longer present in any of the standard system libraries (.a or .so).

This patch addresses the problem at its source by conditionally compiling the problematic code.

Fixes #142726
@jieyouxu
Copy link
Member

Already merged.
@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[QNX] Failure to link with std on QNX 8.0
6 participants