-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SR-7038] in 4.1, -static-stdlib doesn't seem to work anymore #49586
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
Comments
@jckarter, what's ImageInspectionShared? |
@swift-ci create |
A while back I factored out the runtime code that looks at the images in the process in order to find the conformance/type/etc. tables for dynamic lookup. There was a specialized version for static linking since in a statically-linked executable there's only ever one image and we can directly link to its start/end symbols. @compnerd recently overhauled how this stuff works for ELF and COFF systems, and the static executable case may have fallen by the wayside. |
This seems to work with a 4.1 built from source, but I didn't actually try it with a toolchain (just using the build directory). I'll check that next. |
Oops, I had old build products lying around. libswiftImageInspectionStatic.a is indeed missing now. |
…but that still didn't keep me from linking with the newer compiler. |
Maybe that indicates a version mismatch between compiler and libraries. It could be that Saleem's changes made the extra .a file for static builds unnecessary. |
Oops again. I was on master, not 4.1. But both the master and 4.1 downloadable toolchains seem to fail in this way, even though my local build does not. |
Looks to me like this is from: commit 0c42b57 ELF: restructure image metadata registration That included this change to stdlib/public/runtime/CMakeLists.txt: @@ -92,14 +87,6 @@ if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
string(TOLOWER "${sdk}" lowercase_sdk)
# These two libraries are only used with the static swiftcore
- add_swift_library(swiftImageInspectionStatic STATIC
- ImageInspectionStatic.cpp
- StaticBinaryELF.cpp
- C_COMPILE_FLAGS ${swift_runtime_library_compile_flags}
- LINK_FLAGS ${swift_runtime_linker_flags})
- set_target_properties(swiftImageInspectionStatic PROPERTIES
- ARCHIVE_OUTPUT_DIRECTORY "${SWIFTSTATICLIB_DIR}/${lowercase_sdk}")
-
add_swift_library(swiftImageInspectionShared STATIC
ImageInspectionELF.cpp
C_COMPILE_FLAGS ${swift_runtime_library_compile_flags} However, that library is still referenced in utils/static-executable-args.lnk. Saleem, can we just remove it from there? |
Yeah, I think that we can just remove it since that no longer does anything. The registration is done via the `swiftrt.o` file. I'll upload a change for that. |
@compnerd thanks for your patch. However I did try that locally (see last comment in the problem description) and that did not fix the problem me. Did you try creating a static stdlib/executable? |
Oops. I missed that, Johannes. Reopening this. |
Hmm, interesting, I am not able to reproduce the issue.
I did however have to manually extract the target from ninja and build it ( |
@compnerd it might well be a packaging issue but it's a major regression. Swift 4.0.x doesn't suffer from this, here's the repo:
which prints the above error. The next thing I did is to edit both
|
Comment by Cyril Lashkevich (JIRA) Also static version of libdispatch is missing in swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-25-a-ubuntu16.04 For test program like this: import Dispatch
dispatchMain() I got:
|
Saleem, don't forget to do a clean build. I also couldn't reproduce the issue and it turns out there was an old version of the library in my build directory. Cyril: that's a separate issue, I think. Can you file a different bug for that? |
Comment by Cyril Lashkevich (JIRA) |
Yeah, that won't work. You cannot just edit the linker response file. The libraries were changed as well (earlier). Can you ensure that you are building with the right set of libraries? The verbose link should show you the actual libraries in use. @belkadan - from a clean build, |
I tried the latest 4.1 snapshot:
|
same for the latest dev snapshot:
|
I see there is still a reference to that library in utils/gen-static-stdlib-link-args. Is that what we're missing? |
Nope that PR wasn't right. It turns out that the "Shared" library is actually static and that we simply weren't building it. #14880 |
thanks @bob-wilson |
I'm hoping this is fix but I haven't actually verified that yet. Let's wait until someone can verify the fix before pulling it over to the 4.1 branch. |
With today's dev snapshot, the static-stdlib option is working but the static-executable option gets a link failure:
|
If I manually add "-lswiftImageInspectionShared" to the link, then I get this:
|
If I edit static-executable-args.lnk to add "-lswiftImageInspectionShared" where we used to have "-lswiftImageInspectionStatic", that avoids the undefined reference to dladdr. The other linker complaint about dlopen is just a warning, so that sort of works. |
Here's a PR for that change: #14929 Someone who really understands this needs to review that. |
This should be fully resolved now on master. I've created a PR for the 4.1 branch: #14937 |
thanks @compnerd and @bob-wilson I can confirm this is fixed now. But as soon as |
Additional Detail from JIRA
md5: 3fe03957d3ec077a1ac3669583413927
Issue Description:
repro:
create a new SwiftPM package (
cd /tmp && mkdir test && cd test && swift package init --type=executable
try to build (
rm -rf .build && swift build -Xswiftc -static-stdlib
)alternatively
expected:
with 4.0.2 release it works fine:
actual
with today's 4.1 dev snapshot ({{swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-19-a }}) however:
things that are odd:
lswiftImageInspectionShared/Static
seems gone:in the
.lnk
file, it still lists-lswiftImageInspectionStatic
:but
However, removing those
-lswiftImageInspection*
entries from the.lnk
files also doesn't seem to fix it:so maybe
libswiftImageIntrospection*
is still needed but no longer part of the distribution?The text was updated successfully, but these errors were encountered: