Skip to content

Commit 7a22222

Browse files
committed
Support raw-dylib link kind on ELF
raw-dylib is a link kind that allows rustc to link against a library without having any library files present. This currently only exists on Windows. rustc will take all the symbols from raw-dylib link blocks and put them in an import library, where they can then be resolved by the linker. While import libraries don't exist on ELF, it would still be convenient to have this same functionality. Not having the libraries present at build-time can be convenient for several reasons, especially cross-compilation. With raw-dylib, code linking against a library can be cross-compiled without needing to have these libraries available on the build machine. If the libc crate makes use of this, it would allow cross-compilation without having any libc available on the build machine. This is not yet possible with this implementation, at least against libc's like glibc that use symbol versioning. The raw-dylib kind could be extended with support for symbol versioning in the future. This implementation is very experimental and I have not tested it very well. I have tested it for a toy example and the lz4-sys crate, where it was able to successfully link a binary despite not having a corresponding library at build-time.
1 parent 8e59cf9 commit 7a22222

File tree

68 files changed

+669
-116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+669
-116
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3542,6 +3542,7 @@ dependencies = [
35423542
"libc",
35433543
"object 0.36.7",
35443544
"pathdiff",
3545+
"rand",
35453546
"regex",
35463547
"rustc_abi",
35473548
"rustc_arena",

compiler/rustc_codegen_ssa/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ cc = "=1.2.7"
1414
either = "1.5.0"
1515
itertools = "0.12"
1616
pathdiff = "0.2.0"
17+
rand = "0.8.4"
1718
regex = "1.4"
1819
rustc_abi = { path = "../rustc_abi" }
1920
rustc_arena = { path = "../rustc_arena" }

0 commit comments

Comments
 (0)