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
[SR-7039] can't use -static-stdlib (or -static-executable) with any Dispatch using app #662
Comments
I was pretty sure we fixed this in 4.1. Can you check there? |
dgrove-oss (JIRA User), any insights? |
Comment by David Grove (JIRA) At least in the snapshot build I just grabbed, there was a libdisaptch.so, but not a libdispatch.a. I'd speculate there's still a missing bit of CMake configuration that is causing libdispatch.a to either not be built or to not be installed. @compnerd any thoughts?
|
shared builds are the default, and I wouldn't be surprised if we weren't enabling static builds. Passing -DBUILD_SHARED_LIBS=NO to the cmake invocation should help. |
@swift-ci create |
this is still an issue. For example, compiling NIO (https://github.com/apple/swift-nio) fails with
|
Just a note, setting {{BUILD_SHARED_LIBS}} to {{NO}} does in fact build the static libdispatch. |
@compnerd thanks but Still fails on 4.1 release
|
Unfortunately, there is no way to do that currently. CMake only builds a single type of library by default. I think that doing two CMake invocations is probably the best solution here as it avoids any custom machinery for building both types of libraries. I will note that it is possible to generate both libraries, but requires adding custom logic in the CMake build. |
@compnerd the old build system supported that so this is a regression, should we just do two invocations for now to fix this? |
Comment by Matt Wright (JIRA) This seems like you wheelhouse? |
@weissi - yeah, I think that we should do two invocations for now. |
Ok, perfect, thank you! |
Comment by Aleksei Cherepanov (JIRA) @compnerd could you show how to build in this way? |
Comment by Joel Saltzman (JIRA) ftp27 (JIRA User) I think they mean append it to the build commands here: cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DBUILD_SHARED_LIBS=NO <path-to-source> from here at the very bottom: https://github.com/apple/swift-corelibs-libdispatch/blob/master/INSTALL.md Also, I'm not sure what to pass in addition to "swift build -Xswiftc -static-stdlib" to link to the lib |
@compnerd any news on this one? |
PR: #393 |
I believe that this should be working with apple/swift#20793. |
It looks like most of the PRs and issues related to this are closed, but it looks like the swift snapshots for linux do not have a static version of libdispatch included. I might be misunderstanding the intent here but should they now? If not does anyone know about an issue related to that specifically? |
@keith they really should. We need to reopen then |
Still doesn’t work to work |
Still not fixed in Swift 5.0
|
The following PRs should fix this for |
These 2 PRs fix |
Fixed in $ cat Sources/test/main.swift
import Dispatch
let q = DispatchQueue(label: "q")
q.sync { print("hello") }
$ ~/swift-DEVELOPMENT-SNAPSHOT-2019-05-30-a-ubuntu18.04/usr/bin/swiftc -O -o test -static-stdlib -lbsd -lDispatchStubs Sources/test/main.swift
$ ldd test
linux-vdso.so.1 (0x00007ffe18dc3000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9097ac1000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f90978be000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f90976ba000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f909731c000)
libatomic.so.1 => /usr/lib/x86_64-linux-gnu/libatomic.so.1 (0x00007f9097114000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f9096eff000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9096b76000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f909695e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f909656d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f9099c5b000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f9096365000)
$ ls -l test
-rwxrwxr-x 1 spse spse 35512208 May 31 21:00 test
$ ./test
hello
|
Comment by Oleh (JIRA) Swift version 5.1.1 (swift-5.1.1-RELEASE) Target: x86_64-unknown-linux-gnu /usr/bin/ld.gold: error: cannot find -lswiftDispatch /usr/bin/ld.gold: error: cannot find -lFoundation |
Unfortunately this fix went into the Note the |
Should be fixed in swift-5.3.1 now $ swift --version
Swift version 5.3.1 (swift-5.3.1-RELEASE)
Target: x86_64-unknown-linux-gnu
$ swift run -Xswiftc -static-stdlib
[3/3] Linking test
hello
$ ldd .build/debug/test
linux-vdso.so.1 (0x00007ffc27f10000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fded74d8000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fded74d3000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fded74cd000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fded737e000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fded719d000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fded7182000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fded6f8e000)
/lib64/ld-linux-x86-64.so.2 (0x00007fded95ef000)
$ Should also work for $ swift run -Xswiftc -static-executable
[3/3] Linking test
hello
$ ldd .build/debug/test
not a dynamic executable
$
|
Comment by Alexander Skvortsov (JIRA) I can confirm that the fix works on my project, thanks! |
Additional Detail from JIRA
md5: b75d9276b711df9f7b981f99923ed483
is duplicated by:
relates to:
Issue Description:
repro
expected
works, just like without the
-static-stdlib
actual
cause
libdispatch.a
isn't shipped even though it could be. Since this patchlibdispatch.a
should work but it needs to be compiled withThe text was updated successfully, but these errors were encountered: