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

swift-api-extract crashes when a swiftmodule has a native dependency

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler
    • Labels:
      None
    • Environment:

      MacOS 11.2.1

      Darwin miguels-mac-pro.lan 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64

      Using swift-DEVELOPMENT-SNAPSHOT-2021-03-02-a

       

      Description

      I took the new swift-api-extract for a ride, and found that while it can dump the API for .swiftmodules, if this swiftmodule depends on a native library, the program crashes with the following assertion:

       

      <unknown>:0: error: missing required module 'NativeDep'

      Assertion failed: (!Files.empty() && "No files added yet"), function getMainFile, file /Users/buildnode/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/FileUnit.h, line 423.

       

      I have provided a self-contained test case that shows the problem.

      If you checkout this git repo. or use the attached sample you can see it.

      https://github.com/migueldeicaza/SwiftApiExtractIssue

      And run "make", this will build, and then attempt to use swift-api-extract, which will crash with the above message.   It seems to want a .swiftmodule for the NativeDep library, but since it is a C library, there is no swiftmodule available for it.

       

        Attachments

          Activity

            People

            Assignee:
            stevenwu Steven Wu
            Reporter:
            migueldeicaza Miguel de Icaza
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: