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

swift emits a temporary swiftmodule when swiftmodule of main module is passed with -emit-executable

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Duplicate
    • Component/s: Compiler
    • Labels:

      Description

      I am not really sure if this a bug or not. Basically I am trying to fix https://bugs.swift.org/browse/SR-3280 by passing swiftmodule file of main executable along with objects in swiftpm's link command.

      It works but swift tries to generate a temporary module which makes it want all the search paths again. For example this is what happens on linux:

      $ cat main.swift
      let str = "Hello world"
      print(str)

      $ swiftc -module-name foo -g -emit-object -c main.swift
      $ swiftc -module-name foo -g -emit-module -emit-module-path foo.swiftmodule main.swift

      Now, as per SR-3280, this produces executable but is not debuggable.
      $ swiftc -module-name foo -g -o foo -emit-executable main.o
      $ lldb foo -o "b main.swift:2" -o r -o "po str" -b

      (lldb) po str
      error: in auto-import:
      failed to get module 'foo' from AST context
      

      Passing swiftmodule makes the executable debuggable as expected:
      $ swiftc -module-name foo -g -o foo -emit-executable main.o foo.swiftmodule
      $ lldb foo -o "b main.swift:2" -o r -o "po str" -b

      (lldb) po str
      "Hello world"
      

      But it also generates an intermediate swiftmodule:
      $ swiftc -module-name foo -g -o foo -emit-executable main.o foo.swiftmodule -###

      /usr/bin/swift-autolink-extract main.o -o /tmp/main-d50a74.autolink
      /usr/bin/swift -frontend -emit-module foo.swiftmodule -parse-as-library -target x86_64-unknown-linux-gnu -disable-objc-interop -g -emit-module-doc-path /tmp/foo-0b3cfe.swiftdoc -color-diagnostics -module-name foo -o /tmp/foo-0b3cfe.swiftmodule
      /usr/bin/swift -modulewrap /tmp/foo-0b3cfe.swiftmodule -target x86_64-unknown-linux-gnu -o /tmp/foo-429e33.o
      /usr/bin/clang++ -fuse-ld=gold -target x86_64-unknown-linux-gnu -Xlinker -rpath -Xlinker /usr/lib/swift/linux /usr/lib/swift/linux/x86_64/swift_begin.o /tmp/foo-429e33.o main.o -L /usr/lib/swift/linux -lswiftCore --target=x86_64-unknown-linux-gnu @/tmp/main-d50a74.autolink /usr/lib/swift/linux/x86_64/swift_end.o -o foo
      

      Shouldn't swift not do that because it already has foo.swiftmodule and run the modulewrap command directly?

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                aciid Ankit Aggarwal
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: