Skip to content

[Macros] Add the correct RPATH flags to the in-process plugin server host library #75585

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
Aug 9, 2024

Conversation

finagolfin
Copy link
Member

like the in-process plugin server

Also, make sure the in-process plugin server builds for Android.

@rintaro, I noticed this library leaks the builder runpath in the latest trunk toolchain for linux:

> readelf -d swift-DEVELOPMENT-SNAPSHOT-2024-07-29-a-ubi9/usr/lib/swift/host/libSwiftInProcPluginServer.so | ag runpath
 0x000000000000001d (RUNPATH)            Library runpath: [/opt/swift/5.8.1/usr/lib/swift/linux:$ORIGIN]

This pull fixed that when I built it natively on Android, along with the Bionic import.

I will submit an integration test for this new builder path once this is in.

@@ -193,6 +193,9 @@ function(add_pure_swift_host_library name)
# Create the library.
add_library(${name} ${libkind} ${APSHL_SOURCES})
_add_host_swift_compile_options(${name})
if(APSHL_SHARED)
_set_pure_swift_link_flags(${name} "../../")
Copy link
Member Author

Choose a reason for hiding this comment

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

This assumes the library is installed to usr/lib/swift/host/: we'll have to make this a parameter of add_pure_swift_host_library() if it ever starts getting used by libraries installed elsewhere.

Copy link
Member

@rintaro rintaro Aug 8, 2024

Choose a reason for hiding this comment

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

This function is used for building stdlib macro plugins too. (libSwiftMacors.so and libObservationMacros.so) Currently they call _set_pure_swift_link_flags in the call site as the output and install directories are controlled in the call sites. For now could you follow that? I.e. call _set_pure_swift_link_flag in tools/swift-plugin-server/CMakeLists.txt

Copy link
Member Author

Choose a reason for hiding this comment

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

This function is used for building stdlib macro plugins too. (libSwiftMacors.so and libObservationMacros.so) Currently they call _set_pure_swift_link_flags in the call site as the output and install directories are controlled in the call sites.

No, those macro plugins also call this _set_pure_swift_link_flags() function in a generalized add_swift_macro_library() function that uses a single hard-coded install path, just as I'm doing here in add_pure_swift_host_library().

Currently, there is only one shared host library built this way. I added _set_pure_swift_link_flags() to add_pure_swift_host_library() here to make sure the link flags are always added for any future shared host libraries, just as you did before with the two other generalized invocations of _set_pure_swift_link_flags() in add_swift_macro_library() and add_pure_swift_host_tool(), both of which also use hard-coded install paths.

Are you sure you want me to specialize this for the SwiftInProcPluginServer shared library alone?

Copy link
Member

@rintaro rintaro Aug 9, 2024

Choose a reason for hiding this comment

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

Sorry I think I wasn't clear. "this function" I meant was add_pure_swift_host_library()
add_swift_macro_library() is just calling add_pure_swift_host_library() and adding some macro plugin specific configuration to the target. I'm pretty sure your current change adds an incorrect RPATH to them.

Are you sure you want me to specialize this for the SwiftInProcPluginServer shared library alone?

Yes.

Copy link
Member Author

Choose a reason for hiding this comment

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

"this function" I meant was add_pure_swift_host_library()
add_swift_macro_library() is just calling add_pure_swift_host_library() and adding some macro plugin specific configuration to the target. I'm pretty sure your current change adds an incorrect RPATH to them.

Yep, you're right, I missed that. I checked those Macro libraries built natively on Android and this RPATH was incorrectly added there too.

I've now made this change only for the one library instead, as you asked for, and rebased.

@finagolfin
Copy link
Member Author

@kateinoigakukun, would you run the CI on this?

@finagolfin
Copy link
Member Author

Ping @rintaro, not sure you saw this.

@rauhul, please run the CI.

@rauhul
Copy link
Member

rauhul commented Aug 8, 2024

Ping @rintaro, not sure you saw this.

@rauhul, please run the CI.

I'd appreciate not being pinged for parts of the swift project I don't work on/own.

I think it would be better to bring up the access to running ci with the contributor experience group!

@rauhul
Copy link
Member

rauhul commented Aug 8, 2024

@swift-ci please test

@finagolfin
Copy link
Member Author

I'd appreciate not being pinged for parts of the swift project I don't work on/own. I think it would be better to bring up the access to running ci

Sure thing. I remember you running the CI for me on random repos where I never even pinged you or knew that you were involved with in anyway, so I thought you wanted to help. I won't ping you for CI runs on these other repos again.

@AnthonyLatsis
Copy link
Collaborator

AnthonyLatsis commented Aug 8, 2024

Normally the code owners should trigger the bot for you (not sure who owns this part, perhaps Rintaro), but you can also ask @swiftlang/contributor-experience, if, say, you are not getting a timely response.

Though, really, you’ve contributed more than enough to go ahead and request CI/write access.

@finagolfin
Copy link
Member Author

Linux CI failure when running the SwiftPM tests appears spurious.

…host library

Also, make sure it builds for Android.
@finagolfin finagolfin changed the title [Macros] Add the correct RPATH flags to pure Swift host libraries [Macros] Add the correct RPATH flags to the in-process plugin server host library Aug 9, 2024
@rintaro
Copy link
Member

rintaro commented Aug 9, 2024

@swift-ci Please smoke test

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

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

Thank you!

@rintaro rintaro merged commit 5128ceb into swiftlang:main Aug 9, 2024
3 checks passed
@finagolfin
Copy link
Member Author

Thanks for the review, @rintaro.

@finagolfin finagolfin deleted the droid branch August 10, 2024 02:33
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.

4 participants