Skip to content

Conversation

@al45tair
Copy link
Contributor

When we're statically linking the standard library, we need to force the inclusion of the backtracing code in the runtime, otherwise we don't get on-crash backtraces.

Also, add a test to make sure that this works.

rdar://115774613

When we're statically linking the standard library, we need to force
the inclusion of the backtracing code in the runtime, otherwise we don't
get on-crash backtraces.

Also, add a test to make sure that this works.

rdar://115774613
@al45tair al45tair requested a review from a team as a code owner September 21, 2023 14:42
@al45tair
Copy link
Contributor Author

@swift-ci Please test

@al45tair al45tair added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.9 Linux Platform: Linux labels Sep 21, 2023
@al45tair
Copy link
Contributor Author

Explanation: When using --static-stdlib, the crash handler for the backtracing code doesn't get linked into the final binary because the backtracing code is entirely self-contained and it gets discarded by the linker. This fixes that issue by adding a reference to it to swiftrt.o, which causes the static linker to drag it in from the archive.
Risk: Low. Only affects Linux.
Original PR: #68669
Reviewed by: @mikeash
Resolves: rdar://115774613
Tests: This PR adds an explicit test to make sure that we get backtraces when a statically linked program crashes. It fails prior to the other changes in the PR, and succeeds after them.

When we're building with host tools, we should use the host's swiftrt.o
and not the one we've just built when we're trying to build tools that we
will run on the host system.

rdar://115774613
@al45tair
Copy link
Contributor Author

@swift-ci Please test

We want the static version of Dispatch here.  If we don't use that version,
we'll fail the tests on the release branches (but strangely not on main
for some reason).

rdar://115774613
@al45tair
Copy link
Contributor Author

@swift-ci Please test

@al45tair al45tair merged commit c9a5a05 into swiftlang:release/5.9 Sep 26, 2023
al45tair added a commit to al45tair/swift that referenced this pull request Oct 2, 2023
[Linux] Force the inclusion of the backtracing code when static linking.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Linux Platform: Linux 🍒 release cherry pick Flag: Release branch cherry picks swift 5.9

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants