Skip to content

Add IsSDKRelative field to ModuleInterfaceLayout #77860

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
Dec 6, 2024
Merged

Conversation

rmaz
Copy link
Contributor

@rmaz rmaz commented Nov 27, 2024

When serializing the module interface path of an interface that is part of the SDK, we serialize relative to the SDK path. During deserialization we need to know if a path was serialized relative to the SDK or not. The existing logic assumes any relative path has been serialized relative to the SDK, which makes it impossible to compile modules from relative swiftinterface paths that are not part of the SDK.

Update the swiftmodule file to include an attribute to show if the path was serialized relative to the SDK or not, which is used during deserialization to correctly reconstruct the interface path.

@rmaz
Copy link
Contributor Author

rmaz commented Nov 27, 2024

@swift-ci please test

@rmaz
Copy link
Contributor Author

rmaz commented Nov 27, 2024

@swift-ci please test

@rmaz
Copy link
Contributor Author

rmaz commented Dec 2, 2024

@swift-ci please test

Copy link
Contributor

@xymus xymus left a comment

Choose a reason for hiding this comment

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

LGTM

Do you know why it currently fails or where the compiler is using that path? I can see the cannot open file error when running the test locally, but I would have expected that path to be used mostly for diagnostics or by the dependency scanner so I'm surprised the frontend tries to open the file.

@rmaz
Copy link
Contributor Author

rmaz commented Dec 3, 2024

LGTM

Do you know why it currently fails or where the compiler is using that path? I can see the cannot open file error when running the test locally, but I would have expected that path to be used mostly for diagnostics or by the dependency scanner so I'm surprised the frontend tries to open the file.

I believe the test failure is unrelated, i'll give it another rebase to check

@xymus
Copy link
Contributor

xymus commented Dec 3, 2024

Yeah the failure on shebang-env.swift looks unrelated and it should be fixed by now.

However I meant to ask if you know why your test fails before your fix? Why is the compiler opening that file?

@rmaz
Copy link
Contributor Author

rmaz commented Dec 3, 2024

However I meant to ask if you know why your test fails before your fix? Why is the compiler opening that file?

Oh I see. The test fails because the deserialized swiftinterface path for B.swiftmodule is relative, but is not found in the SDK. When deserializing the compiler will construct its path relative to the SDK, and fails with:

<unknown>:0: error: cannot open file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/relative_path/B.swiftmodule/arm64-apple-macos.swiftinterface' (No such file or directory)

This is raised here, while checking the dependencies of the module:

if (!Status) {
Instance.getDiags().diagnose(SourceLoc(), diag::cannot_open_file, DepName,
Status.getError().message());
return true;
}

@rmaz
Copy link
Contributor Author

rmaz commented Dec 3, 2024

@swift-ci please test

@xymus
Copy link
Contributor

xymus commented Dec 3, 2024

Oh ok, we consider the swiftinterface as a dependency of the client swiftmodules to trigger a rebuild on upstream changes. That makes sense, thank you!

When serializing the module interface path of an interface that
is part of the SDK, we serialize relative to the SDK path. During
deserialization we need to know if a path was serialized relative
to the SDK or not. The existing logic assumes any relative path
has been serialized relative to the SDK, which makes it impossible
to compile modules from relative swiftinterface paths that are not
part of the SDK.

Update the swiftmodule file to include an attribute to show if the
path was serialized relative to the SDK or not, which is used
during deserialization to correctly reconstruct the interface path.
@rmaz
Copy link
Contributor Author

rmaz commented Dec 4, 2024

@swift-ci please test

@rmaz
Copy link
Contributor Author

rmaz commented Dec 4, 2024

@swift-ci please smoke test

@rmaz
Copy link
Contributor Author

rmaz commented Dec 5, 2024

@swift-ci please test

@rmaz
Copy link
Contributor Author

rmaz commented Dec 5, 2024

@swift-ci please test

@rmaz
Copy link
Contributor Author

rmaz commented Dec 6, 2024

@swift-ci please smoke test Linux Platform

@rmaz
Copy link
Contributor Author

rmaz commented Dec 6, 2024

@swift-ci please smoke test macOS Platform

@rmaz rmaz merged commit 8c49520 into swiftlang:main Dec 6, 2024
3 of 5 checks passed
@rmaz rmaz deleted the sdkrelative branch December 6, 2024 20:40
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.

3 participants