Skip to content

[SR-7039] can't use -static-stdlib (or -static-executable) with any Dispatch using app #662

Closed
@weissi

Description

@weissi
Previous ID SR-7039
Radar rdar://problem/38913393
Original Reporter @weissi
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 6
Component/s libdispatch
Labels Bug
Assignee @spevans
Priority Medium

md5: b75d9276b711df9f7b981f99923ed483

is duplicated by:

  • SR-7085 Link error related to libdispatch when using -static-stdlib on Linux

relates to:

  • SR-9368 libdispatch_static unit tests are disabled
  • SR-10625 tests for -static-*

Issue Description:

repro

mkdir /tmp/test && cd /tmp/test && swift package init --type=executable
cat > Sources/test/main.swift <<EOF
import Dispatch
let q = DispatchQueue(label: "q")
q.sync { print("hello") }
EOF
swift build -Xswiftc -static-stdlib

expected

works, just like without the -static-stdlib

actual

$ rm -rf .build && /usr/local/swift/swift-4.0.2-RELEASE-ubuntu16.04/usr/bin/swift build -Xswiftc -static-stdlib
Compile Swift Module 'test' (1 sources)
Linking ./.build/x86_64-unknown-linux/debug/test
/usr/bin/ld.gold: error: cannot find -ldispatch
/tmp/test/Sources/test/main.swift:2: error: undefined reference to '_T08Dispatch0A5QueueCMa'
/tmp/test/Sources/test/main.swift:2: error: undefined reference to '_T08Dispatch0A5QueueCACSS5label_AA0A3QoSV3qosAC10AttributesV10attributesAC20AutoreleaseFrequencyO011autoreleaseI0ACSg6targettcfcfA0_'
/tmp/test/Sources/test/main.swift:2: error: undefined reference to '_T08Dispatch0A5QueueCACSS5label_AA0A3QoSV3qosAC10AttributesV10attributesAC20AutoreleaseFrequencyO011autoreleaseI0ACSg6targettcfcfA1_'
/tmp/test/Sources/test/main.swift:2: error: undefined reference to '_T08Dispatch0A5QueueCACSS5label_AA0A3QoSV3qosAC10AttributesV10attributesAC20AutoreleaseFrequencyO011autoreleaseI0ACSg6targettcfcfA2_'
/tmp/test/Sources/test/main.swift:2: error: undefined reference to '_T08Dispatch0A5QueueCACSS5label_AA0A3QoSV3qosAC10AttributesV10attributesAC20AutoreleaseFrequencyO011autoreleaseI0ACSg6targettcfcfA3_'
/tmp/test/Sources/test/main.swift:2: error: undefined reference to '_T08Dispatch0A5QueueCACSS5label_AA0A3QoSV3qosAC10AttributesV10attributesAC20AutoreleaseFrequencyO011autoreleaseI0ACSg6targettcfC'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
error: terminated(1): /usr/local/swift/swift-4.0.2-RELEASE-ubuntu16.04/usr/bin/swift-build-tool -f /tmp/test/.build/debug.yaml main

cause

libdispatch.a isn't shipped even though it could be. Since this patch libdispatch.a should work but it needs to be compiled with

./configure --enable static=yes

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions