Commit Graph

456 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis
8207212f0b [driver/index] Fix an issue where the -index-file invocation was not working when there are 5 or more input files
When the supplementary-outputs file is written for an -index-file invocation it writes out the first input file
given in arguments instead of the input file that is provided by -index-file-path option. This then causes the frontend
index invocation to fail with an error because there is a mismatch in the primary input file and the input file that is written
in the supplementary-outputs file.
2018-04-12 19:37:44 -07:00
Argyrios Kyrtzidis
0682756a72 Merge pull request #15743 from nathawes/rdar38231888-sourcekit-error-when-parsing-the-compiler-arguments
[Driver] Add -driver-filelist-threshold to set the number of inputs beyond which filelists are used
2018-04-12 19:10:40 -07:00
Nathan Hawes
0a4204e99f [Driver] Add -driver-filelist-threshold to set the number of inputs beyond which filelists are used
When generating a compiler invocation in driver::createCompilerInvocation()
we end up using filelists if the number of inputs is > 128 (to work around
command line arg limits). We never actually write them out though, and so
fail when parsing the frontend arguments that reference them.

As this function is called frequently by SourceKit and command line limits
aren't a concern here, this patch makes the 128 threshold value configurable
via a new -driver-filelist-threshold option. This is set to its maximum value
in driver::createCompilerInvocation() to ensure filelists aren't used. This
new option makes the existing -driver-use-filelists (that forces filelists to
be used) redundant as it's now equivalent to -driver-filelist-threshold=0.

Resolves rdar://problem/38231888
2018-04-12 05:24:03 -07:00
Jordan Rose
36150a8696 [Driver] Disallow -autolink-force-load with -incremental
6af333f3 changed the implementation of -autolink-force-load to only
generate one symbol, but the /placement/ of that one symbol depends on
the order of input files, and -incremental supports adding a file
without rebuilding all other files. We don't have any need for these
two to play nice together right now, so just disallow it.
2018-04-06 20:06:24 -07:00
David Ungar
906e1cadc3 Add some "consts" to the Driver. 2018-04-06 18:47:48 -07:00
Graydon Hoare
a9916dfd23 [BatchMode] Address review comments. 2018-04-04 16:29:02 -07:00
Graydon Hoare
0b4e7db476 [BatchMode] Consolidate reasoning about -{enable,disable}-batch-mode flag.
Previous to this change, the initial inspection of the -{enable,disable}-batch-mode
flag was made separate from the subsequent overriding by -wmo; this in turn meant
that the driver might decide it's "in batch mode" in one place (in particular,
when judging whether to ignore the -num-threads flag) and "in wmo mode" elsewhere
(when judging whether to emit one or multiple outputs, which depends on the
-num-threads flag).

Divergence between these two views caused the driver to effectively drop
the -num-threads flag even when overriding batch mode with wmo; since xcode
assumes that passing -wmo -num-threads _will_ cause multiple outputs, this
in turn caused linking to fail since the expected output files were not found.
2018-04-04 15:21:12 -07:00
Rintaro Ishizaki
2cec8dfc99 [Driver] Factor out build-record filename construction
* Retrive filename for read and write at the same time.
* Read LastBuildTime directly from the build record.
2018-04-03 20:39:55 +09:00
Rintaro Ishizaki
18ceef56e3 [Driver] Use separated build record file for '-emit-module' only mode
* In full compilation '-c' with '-emit-module', output duplicated build
  record file for full compilation *and* emit module ('~moduleonly') mode.
* In '-emit-module' only mode, use '~moduleonly' build record.
2018-04-02 21:04:13 +09:00
David Ungar
43b89133af Warn if explicit batch mode is overridden. 2018-03-28 17:31:34 -07:00
David Ungar
4fa3001bd1 Harden compiler against -num-threads and -enable-batch-mode. 2018-03-26 17:04:31 -07:00
Sho Ikeda
1508b6f131 [gardening][Driver] Replace typedef with using 2018-03-23 19:14:50 +09:00
David Ungar
807dd5864e Renamed swift::types to swift::file_types. 2018-03-22 08:40:06 -07:00
David Ungar
90773d298c Write out filemaps for supplementary outputs.
Add -driver-force-one-batch-repartition and enhance  batch_mode-overlong_argv test.
2018-03-20 09:42:13 -07:00
Sho Ikeda
cea6c03eb2 [gardening] Use !empty() over size() > 0 2018-03-08 09:21:09 +09:00
David Ungar
90d2740817 Merge pull request #14961 from davidungar/PR-18-10-HHH
[Batch mode] Restore -### functionality for batch-mode by extending OutputLevel.
2018-03-06 09:54:03 -08:00
Jordan Rose
be4c2b97fc Merge pull request #14950 from Nonchalant/sr_7040_redundant_D
[SR-7040] Redundant prefix of compilation flag specific error
2018-03-06 08:56:27 -08:00
David Ungar
17a81f6981 Restore -### functionality for batch-mode by extending OutputLevel. 2018-03-05 11:07:20 -08:00
Nonchalant
3fca891628 active conditional compilations: show friendly error message 2018-03-03 13:02:16 +09:00
George Karpenkov
a65da887f2 Determine whether a given sanitizer is available based on the presenc… (#14919)
Determine whether a given sanitizer is available based on the presence of the library.

rdar://37192887
2018-03-02 16:57:45 -08:00
Graydon Hoare
45c78c4f7d [BatchMode] Add a pile of asserts to CommandOutput. 2018-02-28 14:07:25 -08:00
Ben Langmuir
d991452367 Merge pull request #14746 from benlangmuir/working-directory
[driver] Add -working-directory option
2018-02-21 14:56:56 -08:00
Ben Langmuir
20cb3e3eb2 [driver] Add -working-directory option
Adds a -working-directory option which can be used to modify how
relative paths are resolved. It affects all other paths used in driver
options (controlled by a new ArgumentIsPath flag on options) as well as
the contents of output file maps and auxilliary file paths generated
implicitly by the compiler itself.

rdar://37713856
2018-02-21 09:42:05 -08:00
Graydon Hoare
263c4c54d5 [BatchMode] Preserve intra-batch order, add a seed mode. 2018-02-20 18:31:41 -08:00
Graydon Hoare
3d9ce0afb9 [BatchMode] Store -{enable,disable}-batch-mode as a flag in Compilation. 2018-02-15 15:38:09 -08:00
Graydon Hoare
a2c718777d [BatchMode] Pass OutputInfo to Compilation on construction. 2018-02-15 15:38:08 -08:00
Graydon Hoare
f9d7bd2584 [BatchMode] Add PrettyStackTrace helpers to Driver. 2018-02-09 14:10:46 -08:00
Graydon Hoare
ef61f721d4 [BatchMode] Change all CommandOutputs to use a shared OutputFileMap. 2018-02-09 14:08:50 -08:00
Graydon Hoare
dd75636377 [BatchMode] Add -driver-print-derived-output-file-map 2018-02-09 14:06:23 -08:00
Saleem Abdulrasool
b49d69f4b3 Driver: avoid unnecessary break after return in switch
Adjust the style to avoid the unnecessary break after the return in the
switch cases.  NFC.
2018-02-07 15:11:16 -08:00
Graydon Hoare
d139ab2968 [BatchMode] Expand lifetime of ToolChain, pass reference to it to Compilation. 2018-01-24 10:31:19 -08:00
Graydon Hoare
18023832e9 [BatchMode] Fix mis-chosen name in previous PR, NFC. 2018-01-24 10:31:19 -08:00
Graydon Hoare
c4e58af039 [BatchMode] Add BatchModeCompile, multi-input form of StandardCompile. 2018-01-24 10:31:19 -08:00
Graydon Hoare
e738d01940 [BatchMode] Split some code out of getOutputFilename in Driver.cpp, NFC. 2018-01-19 12:38:31 -08:00
Graydon Hoare
ba4335b17d [BatchMode] Split up Driver::buildJobsForAction, NFC. 2018-01-19 12:36:03 -08:00
Brian Gesiak
97f7f276e9 Merge pull request #12708 from modocache/sr-2660-swiftmodule-inputs-with-g
[SR-2660][Driver] Pass .swiftmodule to linker
2017-11-13 22:26:21 -05:00
Brian Gesiak
fe56692063 [SR-2660][Driver] Pass .swiftmodule to linker
Summary:
The following two invocations of `swiftc` behave differently, despite
their only difference being the `-g` option:

```
swiftc foo.swift bar.o baz.swiftmodule -o foo
swiftc -g foo.swift bar.o baz.swiftmodule -o foo
```

The first invocation compiles `foo.swift`, links it with `bar.o`, and
passes the AST information from `baz.swiftmodule` to the linker. The
second invocation results in the following error:

```
<unknown>:0: error: cannot load module 'baz' as 'foo'
```

The source of the problem is that the driver determines whether to
generate a module based on the debug info level that has been
requested, and merges all .swiftmodule inputs if a module is being
generated.

Modify this behavior to instead pass .swiftmodule inputs directly to the
linker if our output is to be linked. This results in both the `swiftc` and
the `swiftc -g` invocations above succeeding.

Test Plan:
1. `utils/build-script --test` passes.
2. After cloning https://github.com/modocache/SR-2660 and modifying its
   `build-driver.sh` to point at the local Swift source build
   directory, running `build-driver.sh` succeeds, and lldb is able to
   print descriptions with accurate debug info.
2017-11-13 13:52:46 -05:00
swift-ci
b382fa1f76 Merge pull request #12443 from modocache/driver-inferred-dylib-name-fixme 2017-11-01 16:10:49 -07:00
Adam Nemet
66085a8aef Save optimization remarks in an external YAML file
This brings the capability from clang to save remarks in an external YAML files.
YAML files can be viewed with tools like the opt-viewer.

Saving the remarks is activated with the new option -save-optimization-record.

Similarly to -emit-tbd, I've only added support for single-compile mode for now.
In this case the default filename is determined by
getOutputFilenameFromPathArgOrAsTopLevel, i.e. unless explicitly specified
with -save-optimization-record-path, the file is placed in the directory of the
main output file as <modulename>.opt.yaml.
2017-10-27 10:14:27 -07:00
Brian Gesiak
b81ad22cab [SR-2660][Driver] Handle .swiftmodule inputs
Allow users to pass `.swiftmodule` files into the Swift driver when
compiling without `-g`. The `.swiftmodule` files are then passed to the
linker via `-add_ast_path` so that LLDB can access their AST
information.

This addresses one of two driver changes suggested in the comments of
https://bugs.swift.org/browse/SR-2660.
2017-10-19 15:03:03 -07:00
Brian Gesiak
e2aa7a619c [Driver] Infer target-specific dylib names
When the Swift driver is invoked with the `-emit-library` option, but
without an `-o` option that specifies the emitted library's filename,
logic in the `getOutputFilename()` function derives a filename:
`"lib" + <a plasible base name>"`, and then the value of the
`LTDL_SHLIB_EXT` macro.

There are two problems here:

1. Windows shared library file names, by convention, do not begin with "lib".
2. The `LTDL_SHLIB_EXT` macro is set by
   `llvm/cmake/modules/HandleLLVMOptions.cmake`, based on
   `CMAKE_SHARED_LIBRARY_SUFFIX`, a built-in CMake variable that is set
   at the time LLVM is configured to be built. So, if LLVM and Swift
   were built on a Linux machine, but the `swiftc` executable that was
   built was then invoked to produce a shared library for a Darwin target,
   the library would have a ".so" suffix, not ".dylib". (It's for this
   reason that the tests for this name inference, in
   `test/Driver/linker.swift`, must use a regular expression that
   matches both ".dylib" and ".so", despite specifying a Darwin
   `-target`.)

In order to produce conventionally correct prefixes and suffixes based
on the target, modify the `getOutputFilename()` function to take an
`llvm::Triple` argument.
2017-10-15 00:25:14 -04:00
swift-ci
64f5b45eb1 Merge pull request #12263 from modocache/remove-old-input-type-arg-code-and-fixme 2017-10-05 20:35:48 -07:00
Brian Gesiak
3f8e8084ff [Driver] Remove unused input type code (NFCI)
Summary:
When the Swift driver executable was first added in
ed2038585f,
the code included a FIXME to support input types, like Clang's
`-x <language>` option. Perhaps as a first step in implementing this
functionality, it also included dead code that manipulated an input type
argument, even though the variable for storing the argument was never
written to.

Remove the unused input type code, and the FIXME. The FIXME is now
tracked with a Swift bug URL, so that a discussion on next steps can be had:
https://bugs.swift.org/browse/SR-6054

Test plan: `utils/build-script --release --test`
2017-10-04 13:53:14 -04:00
Brian Gesiak
6652e8f699 [Driver] Remove obsolete "APPLE-ONLY" comments
A post-commit reviewer on https://github.com/apple/swift/pull/10716
asked that the comments be removed. Remove them, as they're no longer
demarcating code that is internal to Apple.
2017-10-04 00:34:56 -04:00
Vedant Kumar
1621facc6c [SwiftPGO] Add driver support for -profile-use=<path>
This option tells the compiler where to find a profdata file. The
information in this file enables PGO. For more information about the PGO
infrastructure, look for the -profile-generate option and for the
llvm-profdata tool [1].

[1] http://llvm.org/docs/CommandGuide/llvm-profdata.html
2017-09-26 10:52:08 -07:00
Calvin Hill
aee81d272f Add Initial platform support for Haiku. (#11583) 2017-09-22 21:06:56 -04:00
Huon Wilson
08a2e35b3f Merge pull request #11563 from huonw/emit-module-path-wmo
[Driver] Obey -emit-module-path in -wmo that only does -emit-module.
2017-08-23 14:07:56 -07:00
Huon Wilson
151bbf95a3 [Driver] Obey -emit-module-path in -wmo that only does -emit-module. 2017-08-23 11:18:52 -07:00
Jordan Rose
0a4cf89a33 Merge pull request #11482 from jrose-apple/take-action
[Driver] Clean up ownership of Action objects
2017-08-16 09:40:17 -07:00
Jordan Rose
47872d9190 [Driver] Transfer all ownership of Actions to the Compilation.
Previously, Actions were responsible for freeing their inputs...
except for the ones that weren't. Or the ones that were supposed
to, but then they needed to share an input, so they couldn't anymore.
If this sounds ridiculous, you're right; now Actions are just
immediately allocated and owned by the Compilation.

The graph structure of the actions is still useful for some things; in
particular, "top-level" actions get to put their outputs somewhere
permanent rather than TMPDIR. But I expect these things to get cleaned
up in the future too.
2017-08-11 21:09:34 -07:00