Replace env PATH manipulation with Swift driver's -tools-directory flag
to specify location of fake linker.
This seems to work with lit's internal shell, though I'm not 100% certain
it's the right approach.
bdf60152f0 added some extra padding to
forFilelistCapture to avoid it being exactly 4096 bytes, triggering a
tail bug. Rather than do that, just run the sed's first so that the
input is quite small (definitely under 4096 bytes).
Resolves rdar://105395733.
`test/Driver/filelists.swift` writes out the swift driver jobs to a file
called `%t/forFilelistCapture`. We then `tail -2 | head -1` that file to
get the first line, run some seds, and expect that to the output file
list (eg. from the swift-frontend command). Unfortunately if that file
happens to end up being 4096 in length, `tail` skips the first line and
thus the seds run on *second* line. That produces `/usr/bin/ld` instead,
which obviously doesn't contain the output files!
Add a comment to the end of the file so that it's unlikely to be 4096
in length. Technically we could still hit it if we removed a bunch of
arguments, but this is fine until that bug is fixed.
lit.py currently allows any substring of `target_triple` to be used as a
feature in REQUIRES/UNSUPPORTED/XFAIL. This results in various forms of
the OS spread across the tests and is also somewhat confusing since they
aren't actually listed in the available features.
Modify all OS-related features to use the `OS=` version that Swift adds
instead. We can later remove `config.target_triple` so that these don't
the non-OS versions don't work in the first place.
This commit adds LTO support for handling linker options and LLVM BC
emission. Even for ELF, swift-autolink-extract is unnecessary because
linker options are embeded in LLVM BC content when LTO.
The `-force-single-frontend-invocation` flag predates WMO and is now an
alias for `-whole-module-optimization`. We should use the latter and let
the former fade into history.
The `not env` pattern will result in negating the results of `env`, not
the results of the inferior command. This is dependent on the
implementation of the shell and env. Use the more portable form.
- Many tests got broken because of two things:
- AST dump now outputs to stdout, but many tests expected stderr. This was a straightforward fix.
- Many tests call swift with specific parameters; specifically, many call `swift frontend` directly. This makes them go through the compiler in unexpected ways, and specifically it makes them not have primary files, which breaks the new AST dump implementation. This commit adds the old implementation as a fallback for those cases, except it dumps to `stdout` to maintain some consistence.
Finally, the `/test/Driver/filelists.swift` failed for unknown reasons. It seems its output now had some lines out of order, and fixing the order made the test pass. However, as the reasons why it failed are unknown, this fix might not have been a good idea. Corrections are welcome.
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
This should make it easier to rerun crashed jobs that use filelists;
previously you'd have to run the top-level driver command again with
-save-temps. I didn't want to save /all/ temporary files because that
often includes things like .o files, which could fill up your disk
pretty quickly. But we can always tweak this later.
- Stronger CHECK lines.
- Don't try to link when there's a fake frontend.
- Give the fake 'ld' an explicit .py suffix, and use a symlink to access it, which
uncovered the first two problems.
This is only the driver side of the work; the frontend doesn't understand
this new -output-filelist option yet. Next commit.
More https://bugs.swift.org/browse/SR-280.
This is simply a newline-separated list of files, matching the format
from Darwin ld's -filelist option.
Part 2 of https://bugs.swift.org/browse/SR-280.