Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-6271] Unable to emit assembly from swift compiler to multiple files #48821

Open
alblue opened this issue Nov 1, 2017 · 2 comments
Open

[SR-6271] Unable to emit assembly from swift compiler to multiple files #48821

alblue opened this issue Nov 1, 2017 · 2 comments

Comments

@alblue
Copy link
Contributor

@alblue alblue commented Nov 1, 2017

Previous ID SR-6271
Radar None
Original Reporter @alblue
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Driver
Assignee None
Priority Medium

md5: bb3071f2e46457be531dc5b7605524bf

relates to:

  • SR-327 Add --outdir argument to swiftc

Issue 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:

case FrontendOptions::EmitAssembly: {
if (Opts.OutputFilenames.empty())
Opts.setOutputFilenameToStdout();
else
Suffix = "s";
break;
}

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.

@alblue
Copy link
Contributor Author

@alblue alblue commented Nov 1, 2017

One possible implementation: allow for -o - even in the presence of multiple input files (similar to waht happens today) and then allow -S to write to a .s file.

Another possible implementation: allow another flag to say -dont-use-stdout-for-emit-options, which would just set the suffix.

Not sure which one is least worse, really.

@belkadan
Copy link
Contributor

@belkadan belkadan commented Nov 1, 2017

You can use an output file map for this.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants