Skip to content
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

[5.9] Remove extra paths added to LD_LIBRARY_PATH on Linux when running tests #6691

Merged

Conversation

bnbarham
Copy link
Contributor

@bnbarham bnbarham commented Jul 10, 2023

  • Explanation: Removes an old workaround that breaks running tests when there's already a swift on PATH that isn't the swift currently being run.
  • Scope: swift test on Linux platforms
  • Risk: Low, our tests would fail if this was still needed.
  • Testing: Toolchain build and test on all Linux platforms.
  • Original PR: Remove extra paths added to LD_LIBRARY_PATH on Linux when running tests #6684

These break running tests when there's already a swift on PATH that
isn't the swift currently being run. There shouldn't be a need for these
as the run path of the compiled binary is already the correct path (ie.
the library path of the swift that built it and `$ORIGIN`).

(cherry picked from commit 5c7db58)
@neonichu
Copy link
Contributor

Low, our tests would fail if this was still needed.

I'm not sure that is actually true. When I introduced the workaround, the shipped nightly toolchain was broken which I think implies that the tests were passing despite that being the case.

@bnbarham
Copy link
Contributor Author

bnbarham commented Jul 10, 2023

Low, our tests would fail if this was still needed.

I'm not sure that is actually true. When I introduced the workaround, the shipped nightly toolchain was broken which I think implies that the tests were passing despite that being the case.

That's... odd. That's what the integration tests are for 🤔. Plus indexstore-db/sourcekit-lsp/etc are use the just built toolchain (that's where the tests were failing with this workaround). Do you know what was failing exactly?

@neonichu
Copy link
Contributor

neonichu commented Jul 10, 2023

Not exactly. IIRC, I was basically not able to use swift test without manually setting LD_LIBRARY_PATH.

@DougGregor
Copy link
Member

@swift-ci please build toolchain

@tomerd tomerd added the swift 5.9 This PR targets the 5.9 branch label Jul 25, 2023
@tomerd
Copy link
Contributor

tomerd commented Jul 25, 2023

@bnbarham does this need to be merged?

@bnbarham
Copy link
Contributor Author

We still need to make sure it doesn't cause the issue @neonichu mentioned above.

@@ -141,16 +141,6 @@ enum TestingSupport {
if let location = toolchain.xctestPath {
env.prependPath("Path", value: location.pathString)
}
#elseif os(Linux)
var libraryPaths = ["/usr/lib/swift/linux"]
Copy link
Member

Choose a reason for hiding this comment

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

This line is clearly wrong and should be removed no matter if the others are.

@finagolfin
Copy link
Member

There were clearly issues with this repo when Swift is pre-installed in the PATH, ie it would silently pick that prebuilt toolchain up and you wouldn't notice until some breaking change, as I've seen this problem on Android too.

If you want to remove this, you really need to make sure it's unneeded by adding some debug logging to some tests and checking that they're not building with the wrong toolchain or linking against the wrong runtime libraries.

@bnbarham
Copy link
Contributor Author

There were clearly issues with this repo when Swift is pre-installed in the PATH, ie it would silently pick that prebuilt toolchain up and you wouldn't notice until some breaking change, as I've seen this problem on Android too.

If you want to remove this, you really need to make sure it's unneeded by adding some debug logging to some tests and checking that they're not building with the wrong toolchain or linking against the wrong runtime libraries.

I haven't gone as far as to add debug logging here, but I have a 5.8 on PATH and using the downloaded toolchain with this patch:

  • swift test for a local package passes
  • That xctest binary has Library runpath: [/home/build-user/ws/tmp/pmtest/usr/lib/swift/linux:$ORIGIN]

With the latest 5.9 snapshot swift test fails with:

/home/build-user/ws/tmp/test-package/.build/x86_64-unknown-linux-gnu/debug/test-packagePackageTests.xctest: symbol lookup error: /home/build-user/ws/tmp/test-package/.build/x86_64-unknown-linux-gnu/debug/test-packagePackageTests.xctest: undefined symbol: swift_getTypeByMangledNameInContext2

@finagolfin
Copy link
Member

swift test for a local package passes

I assume you mean /home/build-user/ws/tmp/pmtest/usr/bin/swift test passes, ie you are running SPM 5.9 not 5.8 from your PATH. I suggest you run it again in verbose mode with -v and simply check all the absolute paths it spits out, to make sure it's only using paths to the 5.9 toolchain.

@bnbarham
Copy link
Contributor Author

I assume you mean /home/build-user/ws/tmp/pmtest/usr/bin/swift test passes, ie you are running SPM 5.9 not 5.8 from your PATH.

Yes.

I suggest you run it again in verbose mode with -v and simply check all the absolute paths it spits out, to make sure it's only using paths to the 5.9 toolchain.

I already did, there's no mention of the 5.8 toolchain.

Copy link
Member

@finagolfin finagolfin left a comment

Choose a reason for hiding this comment

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

I just built and tested NIO with 5.8.1 in my PATH but using the latest trunk snapshot and didn't see anything wrong in the verbose log either. It's possible that subsequent pulls to swift-driver's Toolchain.lookup() have made this testing block no longer needed.

@bnbarham
Copy link
Contributor Author

I just built and tested NIO with 5.8.1 in my PATH but using the latest trunk snapshot and didn't see anything wrong in the verbose log either. It's possible that subsequent pulls to swift-driver's Toolchain.lookup() have made this testing block no longer needed.

I'm more concerned with the 5.8 PR that I haven't had a chance to validate yet. I suspect there's a good chance it still has whatever bug had caused this to be needed in the first place. If that's the case it'll need to be changed to add the path of the currently running swift, rather than the first swift on PATH.

@bnbarham
Copy link
Contributor Author

@swift-ci please test

@neonichu
Copy link
Contributor

@swift-ci please smoke test

@neonichu
Copy link
Contributor

I wonder if we should just have "test" be an alias of "smoke test" at this point? It looks like "test" starts the Windows build but nothing else, so there's no reason to actually have "test" be a separate thing at this point, right? It's just unnecessary confusing. @tomerd wdyt?

@tomerd
Copy link
Contributor

tomerd commented Aug 10, 2023

+1

@neonichu
Copy link
Contributor

Thanks for testing this @bnbarham, sounds like this should be good to merge, but we'll also need @tomerd and @airspeedswift at this point for 5.9

@MaxDesiatov
Copy link
Contributor

MaxDesiatov commented Aug 16, 2023

Will this need to use release/5.9.0 as the base branch? Or maybe in that case that would need a separate PR as we'd want to see it in release/5.9 too.

@DougGregor
Copy link
Member

Will this need to use release/5.9.0 as the base branch? Or maybe in that case that would need a separate PR as we'd want to see it in release/5.9 too.

We will need both

@bnbarham
Copy link
Contributor Author

Heh, you must have commented on this just as I was putting up #6822 😅 (4 minutes apart apparently!)

@bnbarham bnbarham merged commit df48749 into swiftlang:release/5.9 Aug 16, 2023
@bnbarham bnbarham deleted the cherry-remove-linux-test-ld-path branch August 16, 2023 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
swift 5.9 This PR targets the 5.9 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants