Commit Graph

25 Commits

Author SHA1 Message Date
Daniel Rodríguez Troitiño
b43d01ff7f [autolink-extract] Support (and ignore) LLVM IR files. (#71142)
In Linux, the current implementation of swift-autolink-extract does not
support LLVM IR files resulting from using LTO.

If one tries to build LLVM using LTO and then try to link one of the
targets that use `swiftc` to link, but link against LLVM object files
(like `swift-plugin-server`), `swift-autolink-extract` will fail saying
that some object files are not valid.

To deal with LLVM IR files correctly, create and pass
a `llvm::LLVMContext` around, which allows the APIs in `llvm::object` to
read LLVM IR files. Additionally, handle the case of `IRObjectFile` when
extracting, but perform no action.
2024-01-31 11:01:39 -08:00
Max Desiatov
ec4ca6631a test/AutolinkExtract/import_archive.swift: check for Wasm object format 2023-07-22 14:22:24 +01:00
Max Desiatov
e3d2e54a90 test/AutolinkExtract/import.swift: check for Wasm object format 2023-07-22 14:21:39 +01:00
Max Desiatov
a44179bc13 test/AutolinkExtract/empty_archive.swift: check for Wasm object format 2023-07-22 14:20:19 +01:00
Max Desiatov
3bc85b8636 test/AutolinkExtract/empty.swift: add support for Wasm binary format
Let's check in tests all supported object formats that need autolinking to work, including Wasm.
2023-07-22 14:18:19 +01:00
Juergen Ributzka
17c5010d0b [swift][AutoLinkExtract] Don't add autolink hint for frameworks. (#65051)
Default system linkers on non-Darwin platforms do not support the `-framework`
argument for framework linking. This change updates autolinking to not emit
`-framework` into the .o _swift1_autolink_entries metadata when there is no
native linker support.

This is related to rdar://106578342.
2023-04-14 09:15:05 -07:00
Artem Chikin
a69ba3a03c [Autolink Extract] Filter out StringProcessing library from being linked more than once.
We cannot filter all libraries because duplicate -l flags have a semantic meaning based on their order, but filtering out just the common Swift libraries should yield a good size improvement already and is safe.
2022-11-29 15:44:29 -08:00
Artem Chikin
3d30527529 [Autolink Extract] Filter out common Swift libraries from being linked more than once
A partial solution to #58380
2022-05-25 15:18:37 -07:00
Artem Chikin
3e8a115195 Revert "[Autolink Extract] Keep a set of linker flags instead of vector" 2022-05-23 16:03:09 -07:00
Artem Chikin
10a187d2ad [Autolink Extract] Keep a set of linker flags instead of vector
Otherwise we can duplicate linker flags across input binaries, which can result in very large linkerr invocation commands.

Resolves https://github.com/apple/swift/issues/58380
2022-05-20 15:18:43 -07:00
Saleem Abdulrasool
9029dc4b1b Driver: remove COFF from autolink-extract (NFC)
COFF has not used autolink-extract for autolinking.  It uses the PE/COFF
mechanism instead of `.drectve`.  This removes the dead code.
2019-08-07 07:42:04 -07:00
Saleem Abdulrasool
ae8ab310ca test: add CODEGENERATOR requirement (NFC)
This test uses the ARM backend code generator, ensure that we have it.
2019-03-02 12:45:49 -08:00
Jordan Rose
444436e313 [test] Don't actually emit a .so for autolink-extract tests (#17938)
Two tests used -emit-library with the same module name and without an
explicit -o path, meaning that the output would go into whatever
lit.py was using as its working directory. If the tests ran at exactly
the same time, they could contend for the output file. We don't actually
use the built library at all in the test, so just drop the -emit-library
entirely.

Also, remove an unused compilation step from another test, which just
checks what happens when swift-autolink-extract doesn't use any
arguments.

rdar://problem/39510413
2018-07-13 12:50:38 -07:00
Arnold Schwaighofer
c5024f96ee Revert "Disable test/AutolinkExtract/import.swift" 2018-03-22 09:07:23 -07:00
Arnold Schwaighofer
96153bbb33 Disable test/AutolinkExtract/import.swift
It started failing after #15408.

SR-7255
rdar://38751453
2018-03-22 07:47:59 -07:00
David Ungar
0d3020a0f6 enable the test 2018-03-01 07:34:14 -08:00
Xi Ge
3d793d25a6 [test] disable AutolinkExtract/import_archive.swift while investigating. rdar://37605557 (#14677)
We've seen this test failing on bot:
https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04/2836/
2018-02-16 08:06:31 -08:00
Dmitri Gribenko
486cab447d tests: replace 'rm -rf %t && mkdir -p %t' with '%empty-directory(%t)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Han Sangjin
0747503b0f [Autolink] Autolinking on COFF for Cygwin/MinGW
Cygwin and MinGW should use the autolink feature in the sameway of Linux
due to the linker's limit. Now swift-autolink-extract recognizes the
COFF format file for Cygwin/MinGW.
2016-08-07 07:20:50 +09:00
Saleem Abdulrasool
f221499bcc test: use llvm tools
Rather than relying on the system to provide ar and nm, use the LLVM equivalent
tools instead.  Since the build is already dependent on llvm and its tools, this
just ensures that the full set is self-contained.  NFC.
2016-06-03 10:17:58 -07:00
practicalswift
4b1e3e427e [gardening] Fix recently introduced typo: "a llvm" → "an llvm" 2016-04-03 09:41:30 +02:00
Saleem Abdulrasool
9571219927 driver: keep options ordered
The linker flags are order dependent.  Ensure that we preserve ordering.  Also
enhance it to support options which may be repeated (e.g. -rpath).
2016-04-01 17:18:25 -07:00
Chris Willmore
2088cd4373 swift-autolink-extract should look inside .a files.
Previously it just gave up when it saw anything other than an ELF .o file. We
could have it ignore .a files, but we might as well do the right thing.

<rdar://problem/23045632>
2015-11-10 12:48:37 -07:00
Graham Batty
078a558b26 Extract autolink information as a compile step.
Swift SVN r25510
2015-02-24 20:33:05 +00:00