Skip to content

[SourceKit] Pass the main swift executable path when constructing a compiler invocation #58852

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 1 commit into from
May 14, 2022

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 12, 2022

#58786 (rdar://93030932) was failing because the swift-frontend invocations passed a swiftExecutablePath to Invocation.parseArgs. This caused the ClangImporter instance to point to a clang binary next to the swift-frontend executable while SourceKit used PATH to find clang. The clang executable next to swift-frontend doesn’t actually exist because clang lives in llvm-linux-aarch64/bin and swift-frontend lives in swift-linux-aarch64/bin.
So some checks for a minimum clang verison failed for the normal build (because the executable doesn’t actually exists) while they pass during the SourceKit build (which used clang from PATH). This in turn caused the outline-atomics to be enabled to the SourceKit clang compiler arguments but not the clang compiler arguments for a normal build and thus resulted in two separate module cache directories (which includes the enabled features in the module directory hash).

To fix this issue, also set the swift executable path for compiler invocations created from SourceKit.

Fixes rdar://93030932 #58786

@ahoppen ahoppen requested review from bnbarham and egorzhdan May 12, 2022 09:24
@ahoppen
Copy link
Member Author

ahoppen commented May 12, 2022

@swift-ci Please smoke test

Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

Looks like a part of the change got lost so it doesn't compile, other than that LGTM, thanks!

Copy link
Contributor

@bnbarham bnbarham left a comment

Choose a reason for hiding this comment

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

Couple questions:

  1. Why is this only a problem on Ubuntu 22.04 AArch64?
  2. This seems to imply that for testing both the regular compilation and SourceKit requests fail to find Clang, which seems... not ideal. The directory is optionally passed in swift-ide-test, but since this ends up affecting arguments I'm not sure that's really enough. @egorzhdan probably more of a question for you.

…ompiler invocation

swiftlang#58786 (rdar://93030932) was failing because the `swift-frontend` invocations passed a `swiftExecutablePath` to `Invocation.parseArgs`. This caused the `ClangImporter` instance to point to a `clang` binary next to the `swift-frontend` executable while SourceKit used PATH to find `clang`. The clang executable next to `swift-frontend` doesn’t actually exist because `clang` lives in `llvm-linux-aarch64/bin` and `swift-frontend` lives in `swift-linux-aarch64/bin`.
So some checks for a minimum clang verison failed for the normal build (because the executable doesn’t actually exists) while they pass during the SourceKit build (which used `clang` from `PATH`). This in turn caused the `outline-atomics` to be enabled to the SourceKit clang compiler arguments but not the clang compiler arguments for a normal build and thus resulted in two separate module cache directories (which includes the enabled features in the module directory hash).

To fix this issue, also set the swift executable path for compiler invocations created from SourceKit.

Fixes swiftlang#58786 (rdar://93030932)
@ahoppen
Copy link
Member Author

ahoppen commented May 13, 2022

  1. Why is this only a problem on Ubuntu 22.04 AArch64?

It’s only an issue on AArch64 because +outline-atomics only gets added for that architecture (https://github.com/apple/llvm-project/blob/c2589a76b4fa09ba25773162512ad463f003455d/clang/lib/Driver/ToolChains/Clang.cpp#L6988).

I haven’t checked why it’s not an issue on Ubuntu 20.04 but I assume it’s because because the libgcc is too old or one of the other checks in https://github.com/apple/llvm-project/blob/c2589a76b4fa09ba25773162512ad463f003455d/clang/lib/Driver/ToolChains/Linux.cpp#L664-L673 fails.

  1. This seems to imply that for testing both the regular compilation and SourceKit requests fail to find Clang, which seems... not ideal. The directory is optionally passed in swift-ide-test, but since this ends up affecting arguments I'm not sure that's really enough. @egorzhdan probably more of a question for you.

My intention with this patch was to make SourceKit match the normal compilation behavior. I filed #58885 to point clang to the correct path for development builds.

@ahoppen
Copy link
Member Author

ahoppen commented May 13, 2022

@swift-ci Please smoke test

@bnbarham
Copy link
Contributor

My intention with this patch was to make SourceKit match the normal compilation behavior. I filed #58885 to point clang to the correct path for development builds.

Yep, to be clear, I wasn't suggesting you fix that in this PR - just wanted to know what's going on there.

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