-
Notifications
You must be signed in to change notification settings - Fork 302
Add back -no-toolchain-stdlib-rpath when installing sourcekit-lsp on linux #715
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
Conversation
Hey @buttaface, We can’t simply add this flag back because in CI we are building all SwiftPM packages in a unified build, meaning that we don’t need to e.g. rebuild SwiftSyntax multiple times because the SourceKit-LSP, swift-format and the SourceKit stress tester import it. If one of the build invocation uses different compiler arguments than the others, that invalidates the entire unified build. That being said, I think what we should be able to do is set this compiler flag inside SourceKit-LSP’s Package.swift using Also: Just so I understand the problem correctly: This is just about removing the rpath that references a directory on the Swift CI build machines. IIUC (and I might be completely wrong) that rpath shouldn’t be causing any harm because it most likely doesn’t exist on your machine, it’s just not clean. Is this correct? |
I don't think that's the right place, because it's okay for local builds of sourcekit-lsp to have this rpath. The issue is that this build script determines the rpath for the executable shipping in the official toolchain, where this is wrong.
I believe it's a security hole on multi-user machines, as an attacker could create that account and then inject their own libraries' into others' use of sourcekit-lsp. Perhaps uncommon these days, but still worth closing up. |
I did notice that. If there's some way to avoid that, let me know: maybe we can only apply it to executable targets at installation somehow? |
Thanks for the explanation. That makes sense. I see two options here: Option 1: Add the flag in Package.swift behind an environment variable like Option 2: Pass |
While the first option may be a way out, having to work around this seems wrong in the first place. Correct me if I'm wrong but I presume the reason SPM kicks off a rebuild is to make sure the same compiler flags are applied to all Swift source. However, this is a linker flag, so it should only apply to shared library and executable targets and shouldn't trigger a rebuild of all source files. Is there currently no way to tell SPM or the compiler that? |
I don’t think SwiftPM really knows anything about that compiler flag so it just assumes the worst and rebuilds all source files, which is a reasonable behavior IMO. Teaching SwiftPM about every Swift compiler flag doesn’t seem reasonable to me. CC @neonichu |
I think if the flag gets passed as an unsafe flag in |
Not every flag, but couldn't we give it a list of Swift compiler flags that shouldn't trigger a full rebuild?
To be clear, this is a Swift compiler flag that only affects a linker flag set by the Swift compiler, so it wouldn't be passed to |
Ah I see. I don't think we have a great way to give special treatment to something like that at the moment. Rebuilding is happening at the llbuild layer and it works by basically comparing hashes of the full commandlines. |
Huh, that is unfortunate that SPM doesn't control that. I will try Alex's workaround and submit that if it works. |
Circled back around to this and updated this pull with a combination of Alex's Option 1 and Boris's suggestion of using @neonichu, I was wrong to assume @ahoppen, if you would kick off the CI for this, I'd like to get this in and into 5.8 next. |
Note to self: Check that SourceKit-LSP build times aren’t increasing with this change. @swift-ci Please test |
Ready to go in? I will submit for 5.8 next. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, looks good to me.
Ah, actually, I’d like to measure toolchain build times as well. I triggered a toolchain build in swiftlang/swift#37710. If that doesn’t show us rebuilding SourceKit-LSP during the install phase, I’ll merge. |
Good thing you tested building the toolchain too: it appears there's a bug with macOS SPM alone where @neonichu, is this a known issue with mac SPM? Should I file a bug? The good news is that this did not trigger a full unified rebuild on the linux toolchain, according to the build log, as the first iteration of this pull was doing. |
…linux Pull swiftlang#597 incorrectly removed this, as it's still needed on ELF platforms.
Updated this to only add back the flag on linux, should be good to go now. |
Oh, good thing we watched that. Let’s run CI on this PR + build a toolchain to be sure this doesn’t break anything. @swift-ci Please test |
Tests passed, toolchain build passed and installing SourceKit-LSP took <20s so it doesn’t seem to trigger a full rebuild. Let’s merge it. |
Pull #597 incorrectly removed this, as it's still needed on ELF platforms.
That pull noted some SPM changes invalidate the need for this flag, but that's irrelevant since this flag is passed directly to the Swift compiler.
As a result of this flag's removal last year, the 5.8 snapshots for linux have this extraneous
/home/build-user/
rpath:@ahoppen, please review.