swiftlang / swift-docker

Docker Official Image packaging for Swift
https://swift.org
Apache License 2.0
1.35k stars 182 forks source link

Swift 5.9-dev: CentOS7: Symlink libstdc++_nonshared.a into static swift #352

Closed etcwilde closed 11 months ago

etcwilde commented 11 months ago

The swift compiler and runtime libraries are built against the devtoolset-8 on centOS-7. The devtoolset has additional functionality on top of the base centos-7 libstdc++. When the standard library is built as a dynamic library, the extra functionality is linked into the DSO directly, so the dependency is hidden. When the standard library is built as a static archive, it the extra functionality isn't. This is correct behavior to avoid over-linking in the final executable, but it means that the library needs to be present when building statically and in a place that the compiler will look for resources.

This symlinks the backpack library with the additional functionality, along with the linker script to tell the linker to link it into anything that needs to use libstdc++.so.

rdar://114669418

etcwilde commented 11 months ago

@swift-ci please test

etcwilde commented 11 months ago

No package devtoolset-8 available. hmm... well that's interesting. Will have to take a look on Monday.

Yeah, we'll probably need it for main. I tried 5.8 with a little statically-linked hello-world and that seemed to work. I can try something a little more complicated though and see if we need this trick there too.

etcwilde commented 11 months ago

Okay, confirmed that statically linking both 5.8 and nightly-5.8 work without these changes. nightly-main and nightly-5.9 needed the change, and the eventual 5.9 will need this symlink dance.

etcwilde commented 11 months ago

@swift-ci please test

tomerd commented 11 months ago

@shahmishal ptal