Skip to content

Add deserialization support for section attribute #71588

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 4 commits into from
Feb 21, 2024

Conversation

kastiglione
Copy link
Contributor

While working on #71425, I hit an assert indicating the @_section attribute was not handled in DeclDeserializer::deserializeDeclCommon. This change adds the missing deserialization for the @_section attribute.

@kastiglione
Copy link
Contributor Author

Alternatively, should the _section attribute be marked NotSerialized?

@kastiglione
Copy link
Contributor Author

@swift-ci smoke test

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

Can you add a test?

@kastiglione
Copy link
Contributor Author

@eeckstein is there a convention for testing deserialization? The way I would construct a test is to serialize a swiftmodule containing the section attribute, and then load it from a separate invocation. If the loading crashes, the test fails.

@eeckstein
Copy link
Contributor

Yes. You can look at some examples in https://github.com/apple/swift/tree/main/test/Serialization, for example https://github.com/apple/swift/blob/main/test/Serialization/attr-extern.swift

@kastiglione
Copy link
Contributor Author

@swift-ci test

@kastiglione
Copy link
Contributor Author

@swift-ci test linux

@kastiglione
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm!

@kastiglione
Copy link
Contributor Author

@swift-ci test macOS

@kastiglione
Copy link
Contributor Author

@swift-ci test linux

@kastiglione
Copy link
Contributor Author

@swift-ci test macOS

@kastiglione kastiglione merged commit e021534 into main Feb 21, 2024
@kastiglione kastiglione deleted the dl/deserialize-section-attr branch February 21, 2024 02:24
kastiglione added a commit that referenced this pull request Feb 21, 2024
Introduces the first use of `@_DebugDescription` in the standard library, applying it 
to `ObjectIdentifier`. In order to use the DebugDescription macro in the stdlib, the 
following changes are required:

1. Compilation must reference the just built macros (ie `libSwiftMacros.dylib`), not 
those from the SDK. This is addressed by adding an explicit `-external-plugin-path` 
flag that overrides the defaults generated by the compiler (which uses SDK paths, where 
the macro may or may not exist, and may not be the current version).
2. As DebugDescription uses `@_section`, compilation enables the `SymbolLinkageMarkers` 
feature.

Note that the use of DebugDescription is conditionally enabled for the following 
reasons:

1. Use is disabled in freestanding builds, where the stdlib macros are not built.
2. Use is temporarily disabled in Linux builds due to a dynamic loader issue that needs 
further investigation

The dynamic loader error causing issues with Linux CI is:
> swift-plugin-server: error while loading shared libraries: libswiftGlibc.so: cannot 
open shared object file: No such file or directory

This PR depended on #71639, #71588, and #71685.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants