Skip to content

[embedded] Fix embedded Swift builds with -Xcc -ffreestanding and -fno-builtin #68817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 29, 2023

Conversation

kubamracek
Copy link
Contributor

The attached testcase shows the problem: With -Xcc -fno-builtin, or with -Xcc -ffreestanding, the compiler crashes during deserialization due to the "free" function not showing up in SwiftShims. This turns out to be caused by the declaration of free not being at the top level in LibcShims.h.

lib/swift/embedded/Swift.swiftmodule/arm64-apple-macos.swiftmodule:1:1: error: reference to top-level declaration 'free' broken by a context change; 'free' is not found, it was expected to be in 'SwiftShims'
SwiftShims.free
^
<unknown>:0: note: the declaration was expected to be found in module 'SwiftShims'
<unknown>:0: note: declarations in the  clang module 'SwiftShims' may be hidden by clang preprocessor macros
Stack dump:
3.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { Mandatory Diagnostic Passes + Enabling Optimization Passes } on SIL for main)
4.	While running pass #51 SILModuleTransform "MandatorySILLinker".
5.	While deserializing SIL function "swift_deallocClassInstance"
6.	While deserializing SIL function "free"
7.	*** DESERIALIZATION FAILURE ***

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek kubamracek added the embedded Embedded Swift label Sep 28, 2023
Copy link
Contributor

@mikeash mikeash left a comment

Choose a reason for hiding this comment

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

🤨

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek
Copy link
Contributor Author

@swift-ci please test Linux platform

2 similar comments
@kubamracek
Copy link
Contributor Author

@swift-ci please test Linux platform

@kubamracek
Copy link
Contributor Author

@swift-ci please test Linux platform

@kubamracek kubamracek merged commit 95330bc into swiftlang:main Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
embedded Embedded Swift
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants