[Backtracing] Add initial support for Windows.#84906
[Backtracing] Add initial support for Windows.#84906al45tair merged 29 commits intoswiftlang:mainfrom
Conversation
|
@swift-ci Please smoke test |
4ea287c to
d954e8a
Compare
|
@swift-ci Please smoke test |
|
Status: this isn't working for 32-bit Windows, because of a problem with the Swift compiler itself. Also, I need to work on the build system a bit because right now you need to manually copy the backtracer into the correct place. Not sure why, because I'm fairly certain there's CMake code already that's supposed to do that. |
447ed50 to
435bea0
Compare
|
@swift-ci Please test |
1 similar comment
|
@swift-ci Please test |
d4a345a to
499c6ea
Compare
|
@swift-ci Please test |
1 similar comment
|
@swift-ci Please test |
6512a83 to
bb20822
Compare
|
@swift-ci Please test |
|
@swift-ci Please test macOS platform |
057805c to
51b2102
Compare
|
@swift-ci Please test |
2 similar comments
|
@swift-ci Please test |
|
@swift-ci Please test |
f8e40e5 to
2e707c6
Compare
|
@swift-ci Please test |
1 similar comment
|
@swift-ci Please test |
|
@swift-ci Please test Linux platform |
|
@swift-ci Please test macOS platform |
|
@swift-ci Please test |
1 similar comment
|
@swift-ci Please test |
|
@swift-ci Please test Linux platform |
|
@swift-ci Please test |
|
I've just checked that this works on ARM64 Windows, since we don't have PR testing coverage there. My small crash test program generated a backtrace :-) One thing I did spot is that if you install x86-64 Swift on ARM64 Windows, programs seem to crash on exit somewhere in mimalloc. We might need to look into that, but that's nothing to do with this PR. |
edymtt
left a comment
There was a problem hiding this comment.
Looks good to me on the build system side (especially the new one) -- not sure if it makes sense to break the rename of SwiftRuntime to SwiftRuntimeCore in the Core build system in a separate PR.
| find_package(SwiftOverlay REQUIRED) | ||
| find_package(SwiftCxxOverlay REQUIRED) | ||
|
|
||
| if(APPLE) |
There was a problem hiding this comment.
The Darwin find module should be already skipping the search if we are not building for Darwin, so this if should not be strictly necessary -- did you hit issues when building at desk?
There was a problem hiding this comment.
I think I did, yes, We might want to investigate that, if we're not supposed to need the APPLE condition.
| target_compile_definitions(swiftRuntimeCore | ||
| PRIVATE | ||
| -DSWIFT_RUNTIME | ||
| -DSWIFT_TARGET_LIBRARY_NAME=swiftRuntimeCore |
There was a problem hiding this comment.
Wondering if this is now redundant -- in case, we can remove it at a later time to reduce risks in landing this PR.
There was a problem hiding this comment.
I wondered that also, but didn't feel brave enough to delete it :-)
|
@swift-ci Please test Linux platform |
|
@swift-ci Please test macOS platform |
|
In addition to manually testing crash catching on ARM64 Windows, I've also tested that the |
|
@swift-ci Please test macOS platform |
6a8a47c to
2ebe6ed
Compare
Don't even bother building the backtracing code if the backtracing code is disabled. rdar://101623384
We were omitting the `end` instruction, the upshot of which was that the compact backtrace was always being decoded as truncated. rdar://101623384
Also, fix two files that managed to use Windows API without importing `WinSDK` as a result of the leakage caused by including `windows.h` from `codeview.h`. rdar://101623384
We should only add the assembly files if we're actually going to build the `Runtime` module. This was tripping up iOS/tvOS/ watchOS builds. rdar://101623384
Tweak things to build on Linux and macOS again. Also fix a few things in the tests. rdar://101623384
We can't use `|| true` on Windows, so use `not` instead. Also, on Windows, program names get downcased because `lit` uses `os.path.normcase()`, so if we have program names in the output, make sure the programs are already lower-case. Fix up the stack overflow test to match the expected output. Plus fix the macOS build to always build for macOS 26.0 or above. rdar://101623384
`not` works on Windows, but not on Linux or Darwin. rdar://101623384
Test for `}` rather than `},`, since we may or may not have extra frames after the ones we expect, depending. rdar://101623384
Tweaked the comment in `Runtime/Config.h`. Fixed a couple of incorrect ARM64 instruction mnemonics. This still needs testing on ARM64 Windows. Fixed an out-of-date comment in `swift-backtrace`. Use a macro in `Backtrace.cpp` to guarantee we don't overrun the buffer, and in the process simplify the code slightly. rdar://101623384
This change in the driver isn't necessary after all. rdar://101623384
I really did mean `ret`. rdar://101623384
We needed to add the `Runtime` module to the new build system, but when I tried doing that, various things broke. Firstly, we ended up with two targets with the name `swiftRuntime`, but only in the static build (because in that build, everything gets pulled in together, so CMake sees both of them). Rename the one that's part of `swiftCore` to `swiftRuntimeCore`. Second, we need some extra paths for the `Cxx` module and its submodules, and since those are part of the `INTERFACE`, we need to make sure we `PUBLIC` link them into the `Cxx` module so that they get passed through when building `swiftRuntime`. rdar://101623384
2ebe6ed to
079c165
Compare
|
@swift-ci Please smoke test |
…in CI again (#87275) This was fixed in #86694, but the subsequent massive #84906 appears to have [inadvertently disabled adding the needed Android API level](https://github.com/swiftlang/swift/pull/84906/changes#diff-c861caa2fcc08744108e542ca836b07e342f537566e8c5f7a21a0e9125331ed9R2774), as it was started late last year, long before the fix was added.
…in CI again (swiftlang#87275) This was fixed in swiftlang#86694, but the subsequent massive swiftlang#84906 appears to have [inadvertently disabled adding the needed Android API level](https://github.com/swiftlang/swift/pull/84906/changes#diff-c861caa2fcc08744108e542ca836b07e342f537566e8c5f7a21a0e9125331ed9R2774), as it was started late last year, long before the fix was added.
This PR includes support for capturing backtraces and symbolicating using DWARF debug information. It doesn't include support for PDB (yet).
rdar://101623384