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

swiftc -emit-module -c, driver documentation and diagnostics



    • Type: Improvement
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:


      Here is the likely story of someone trying to use the swiftc driver for the first time. Maybe they need to troubleshooot their build or provide a reduced test case.

      `swiftc -help` lists a set of options. It doesn't explain which modes are supported by the driver: building an exe, building a dylib, building a swiftmodule, building a set of .o files, or whatever.

      Since that isn't helpful, the next step is to look at the Swift package manager's output when they build their project. `swift build` output shows them something like:

      swiftc -emit-module -c fileA.swift fileB.swift -module-name ModuleName -parse-as-library -whole-module-optimization -O <some obscure references to package manager artifacts>

      followed by

      swiftc -target x86_64-apple-macosx10.10 -sdk ... fileA.o fileB.o -o ExecutableName

      That obviously implies that running swiftc on a set of swift files with "-emit-module -c" will produce a bunch of object files. So they try this:

      swiftc -emit-module -c fileA.swift fileB.swift -module-name ReducedModuleName

      The command runs with no diagnostics whatsoever, but fails to produce
      any .o files, which is utterly baffling and gives no hint as to what to try next.

      We obviously need to explain how to use the driver in `swiftc -help` or directly link to a documentation section.

      We also need to print some diagnostics when someone tries to use the driver the same way that swiftpm does, explaining, in brief, how to correctly form a command line for what they are obviously trying to do.

      I'm leaving it to Jordan Rose to make more specific suggestions and possibly split this up.


          Issue Links



              Unassigned Unassigned
              atrick Andrew Trick
              0 Vote for this issue
              1 Start watching this issue