Skip to content

[build] Remove runpath from build host from shared ICU libraries on linux #64365

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
Mar 16, 2023

Conversation

finagolfin
Copy link
Member

I suggested the --enable-rpath flag in #40340 to add $ORIGIN more than a year ago, but I didn't realize it also adds the libdir to the runpath:

> find swift-DEVELOPMENT-SNAPSHOT-2023-03-10-a-ubuntu20.04/usr/ -name "lib*\.so*"|xargs readelf -d|ag "File:|runpath"|ag /home/ -B1
File: swift-DEVELOPMENT-SNAPSHOT-2023-03-10-a-ubuntu20.04/usr/lib/liblldb.so.13.0.0git
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/home/build-user/build/buildbot_linux/llvm-linux-x86_64/./lib:/home/build-user/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux:$ORIGIN/../lib/swift/linux]
File: swift-DEVELOPMENT-SNAPSHOT-2023-03-10-a-ubuntu20.04/usr/lib/liblldb.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/home/build-user/build/buildbot_linux/llvm-linux-x86_64/./lib:/home/build-user/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux:$ORIGIN/../lib/swift/linux]
File: swift-DEVELOPMENT-SNAPSHOT-2023-03-10-a-ubuntu20.04/usr/lib/swift/linux/libicuucswift.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/home/build-user/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux/x86_64]
File: swift-DEVELOPMENT-SNAPSHOT-2023-03-10-a-ubuntu20.04/usr/lib/swift/linux/libicuucswift.so.65
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/home/build-user/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux/x86_64]
File: swift-DEVELOPMENT-SNAPSHOT-2023-03-10-a-ubuntu20.04/usr/lib/swift/linux/libicudataswift.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/home/build-user/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux/x86_64]
File: swift-DEVELOPMENT-SNAPSHOT-2023-03-10-a-ubuntu20.04/usr/lib/swift/linux/libicui18nswift.so.65.1
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/home/build-user/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux/x86_64]
File: swift-DEVELOPMENT-SNAPSHOT-2023-03-10-a-ubuntu20.04/usr/lib/swift/linux/libicui18nswift.so.65
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/home/build-user/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux/x86_64]
File: swift-DEVELOPMENT-SNAPSHOT-2023-03-10-a-ubuntu20.04/usr/lib/swift/linux/libicudataswift.so.65.1
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/home/build-user/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux/x86_64]
File: swift-DEVELOPMENT-SNAPSHOT-2023-03-10-a-ubuntu20.04/usr/lib/swift/linux/libicudataswift.so.65
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/home/build-user/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux/x86_64]
File: swift-DEVELOPMENT-SNAPSHOT-2023-03-10-a-ubuntu20.04/usr/lib/swift/linux/libicuucswift.so.65.1
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/home/build-user/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux/x86_64]
File: swift-DEVELOPMENT-SNAPSHOT-2023-03-10-a-ubuntu20.04/usr/lib/swift/linux/libicui18nswift.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/home/build-user/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux/x86_64]
File: swift-DEVELOPMENT-SNAPSHOT-2023-03-10-a-ubuntu20.04/usr/lib/liblldb.so.13git
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/home/build-user/build/buildbot_linux/llvm-linux-x86_64/./lib:/home/build-user/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux:$ORIGIN/../lib/swift/linux]
File: swift-DEVELOPMENT-SNAPSHOT-2023-03-10-a-ubuntu20.04/usr/lib/clang/13.0.0/lib/linux/libclang_rt.memprof-x86_64.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/home/build-user/build/buildbot_linux/llvm-linux-x86_64/./lib]
File: swift-DEVELOPMENT-SNAPSHOT-2023-03-10-a-ubuntu20.04/usr/lib/clang/13.0.0/lib/linux/libclang_rt.ubsan_minimal-x86_64.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/home/build-user/build/buildbot_linux/llvm-linux-x86_64/./lib

See if this fixes it by using the more traditional LDFLAGS instead.

@bnbarham, please run the CI on this and I'll check that it works.

@bnbarham
Copy link
Contributor

@swift-ci please test

@finagolfin
Copy link
Member Author

Strangely, the flag got chomped down to -Wl,-rpath=RIGIN, I guess it interpreted it as the bash variable $O:

clang++ -O3 -fPIC -W -Wall -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long -std=c++11  -Qunused-arguments -Wno-parentheses-equality -Wglobal-constructors -Wl,-rpath=RIGIN   -shared -Wl,-Bsymbolic -Wl,-soname -Wl,libicutuswift.so.65 -o ../../lib/libicutuswift.so.65.1 filestrm.o package.o pkgitems.o swapimpl.o toolutil.o unewdata.o collationinfo.o denseranges.o ucm.o ucmstate.o uoptions.o uparse.o ucbuf.o xmlparser.o writesrc.o pkg_icu.o pkg_genc.o pkg_gencmn.o ppucd.o flagparser.o filetools.o udbgutil.o dbgutil.o ucln_tu.o -L../../lib -licui18nswift -L../../lib -licuucswift -L../../stubdata -licudataswift -lpthread -lm

I hate these bash escaping rules, let's try the three-slash variant.

@finagolfin
Copy link
Member Author

@mhjacobson, if you're still up, please run the CI on this.

@mhjacobson
Copy link
Contributor

@swift-ci please smoke test

@finagolfin
Copy link
Member Author

Sigh, that didn't work either.

@finagolfin
Copy link
Member Author

Found the magic incantation that appears to work, after testing it locally.

@bnbarham, please run the CI again and I will add an integration test next, to make sure this doesn't regress again.

@bnbarham
Copy link
Contributor

@swift-ci please test

@finagolfin
Copy link
Member Author

OK, CI passed now that the rpath was set properly, and I checked the build log to make sure it's set to the right value.

This is ready for review and merge, @bnbarham.

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.

If this should stay a shared library this seems reasonable enough to me. Though it seems like the only thing that uses this now is foundation? In which case... maybe we should just statically link it?

@finagolfin
Copy link
Member Author

I am not sure about the considerations that go into making such a change. For one, ICU uses different licenses than Foundation, which might then require some legal vetting.

I'm just trying to clean up all these CI runpaths leaking into the final toolchain, not going to attempt a bigger change like that, though it may make sense one day.

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