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

Unable to emit assembly from swift compiler to multiple files

    XMLWordPrintable

    Details

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

      Description

      When compiling multiple Swift files (because they have inter-relationships between them, for example) it's not possible to get the assembly written out to a file. The only output possibility is to stdout.

      This command will print out the assembly of the file to stdout:

      {{
      swiftc -module-name example -emit-assembly main.swift dependency.swift
      }}

      However, if you try and get it to write to separate files, it doesn't because multiple -o files are not permitted:

      {{
      swiftc -module-name example -emit-assembly main.swift -o main.s dependency.swift -o dependency.s
      error: cannot specify -o when generating multiple output files
      }}

      Normally with clang this would be taken care of simply by passing -S (which is also the same for the swift compiler) and the output would be written to <filename>.s for each individual file. However, for -S in swiftc, it assumes that you want to write to stdout:

      https://github.com/apple/swift/blob/56a1663c9859f1283904cb0be4774a4e79d60a22/lib/Frontend/CompilerInvocation.cpp#L420-L426

      What I'd like to do is be able to generate individual files, or be allowed to have a means of disabling the automatic-stdout option for the -emit phases (probably the same for ll as well). This would require either an additional option that disables this option, or have a means to allow a per-file output when multiple source files are used.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                alblue Alex Blewitt
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: