Skip to content

[SR-327] Add --outdir argument to swiftc #42949

Open
@swift-ci

Description

Previous ID SR-327
Radar None
Original Reporter jpakkane (JIRA User)
Type New Feature
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels New Feature, Driver
Assignee @modocache
Priority Medium

md5: ffc5d47714bb694b2a42adb551584a44

relates to:

  • SR-7704 swiftc -emit-module -c, driver documentation and diagnostics
  • SR-6079 Incremental compilation should not require an output file map
  • SR-6271 Unable to emit assembly from swift compiler to multiple files

Issue Description:

Currently swiftc writes all its output to current working directory. Please consider adding a --outdir argument so you can instruct swiftc to write its output to a different directory.

This makes it easier to integrate swiftc with other build systems. For example on Ninja you need to write all paths relative to the top level Ninja file directory. This leads to the weird situation that you need to manually cd into the output directory and invoke swiftc with paths that are different to what the Ninja file has.

As an example suppose you have a swift project with sources in Sources and you want to build in a directory called build and place the temporary files in a directory called build/tmpdir then you Ninja dependency looks [roughly] like this

executable [depends on] ../Sources/myexe.swift

but the compilation command is this:

cd tmpdir; swiftc -c ../../Sources/myexe.swift; cd ..

Note the extra '..' in the source file. This makes integration work needlessly complicated. With --outdir the command would look like this:

swiftc --outdir=tmpdir -c ../Sources/myexe.swift

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

compilerThe Swift compiler itselffeatureA feature request or implementationlegacy driverArea → compiler: the integrated C++ legacy driver. Succeeded by the swift-driver project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions