Uploaded image for project: 'Swift'
  1. Swift
  2. SR-7039

can't use -static-stdlib (or -static-executable) with any Dispatch using app

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reopened
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: libdispatch
    • Labels:
      None

      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
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                compnerd Saleem Abdulrasool
                Reporter:
                jw Johannes Weiss
              • Votes:
                6 Vote for this issue
                Watchers:
                18 Start watching this issue

                Dates

                • Created:
                  Updated: