Skip to content

Support raw-dylib link kind on ELF#135695

Merged
bors merged 1 commit intorust-lang:masterfrom
Noratrieb:elf-raw-dylib
Mar 4, 2025
Merged

Support raw-dylib link kind on ELF#135695
bors merged 1 commit intorust-lang:masterfrom
Noratrieb:elf-raw-dylib

Conversation

@Noratrieb
Copy link
Member

@Noratrieb Noratrieb commented Jan 18, 2025

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.

I was inspired by Björn's comments in https://internals.rust-lang.org/t/bundle-zig-cc-in-rustup-by-default/22096/27
Tracking issue: #135694

r? bjorn3

try-job: aarch64-apple
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
try-job: test-various

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 18, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jan 18, 2025

These commits modify compiler targets.
(See the Target Tier Policy.)

Some changes occurred in src/tools/compiletest

cc @jieyouxu

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@Noratrieb Noratrieb force-pushed the elf-raw-dylib branch 2 times, most recently from 7b85a6a to f339acd Compare January 18, 2025 21:30
@rustbot

This comment was marked as outdated.

@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Jan 18, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compiletest changes LGTM, would be great if you could add the two new directives to the directives listing in r-d-g

@jieyouxu
Copy link
Member

jieyouxu commented Mar 2, 2025

@bors p=5 (rollup scheduling)

@tgross35
Copy link
Contributor

tgross35 commented Mar 2, 2025

Since this is iffy and next in queue, could it get rolled up with a few alwayses? That seems reasonable for all the iffys (otherwise they would be nevers, we're no worse off an iffy fails)

@jieyouxu
Copy link
Member

jieyouxu commented Mar 2, 2025

Yeah that would work. That's why iffy exists in the first place.

@jieyouxu
Copy link
Member

jieyouxu commented Mar 2, 2025

@bors p=0 (to be included in another rollup)

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 3, 2025
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.

I was inspired by Björn's comments in https://internals.rust-lang.org/t/bundle-zig-cc-in-rustup-by-default/22096/27
Tracking issue: rust-lang#135694

r? bjorn3

try-job: aarch64-apple
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
try-job: test-various
@bors
Copy link
Collaborator

bors commented Mar 3, 2025

⌛ Testing commit a954c51 with merge 161f78c...

@bors
Copy link
Collaborator

bors commented Mar 3, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 3, 2025
@Kobzol
Copy link
Member

Kobzol commented Mar 3, 2025

@bors retry network error

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 3, 2025
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
##[endgroup]
Image input checksum bed9166b5ea6c475a5e82dbd59d7a7df1d5cefd4eaf9cdd5ef976d511c06a59516a0dd9789681ba52d63a18529eaaa52a26a746c004596ee9e5d584a3b2de811
##[group]Building docker image for dist-android
Docker version 26.1.3, build b72abbb
Error response from daemon: Get "https://ghcr.io/v2/": Get "https://ghcr.io/token?account=rust-lang-ci&client_id=docker&offline_token=true&service=ghcr.io": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
##[error]Process completed with exit code 1.

@bors
Copy link
Collaborator

bors commented Mar 3, 2025

⌛ Testing commit a954c51 with merge 6d088a8...

@bors
Copy link
Collaborator

bors commented Mar 3, 2025

💔 Test failed - checks-actions

@Kobzol
Copy link
Member

Kobzol commented Mar 3, 2025

@bors retry network error

sigh..

@bors
Copy link
Collaborator

bors commented Mar 3, 2025

⌛ Testing commit a954c51 with merge 5f802db...

@bors
Copy link
Collaborator

bors commented Mar 3, 2025

💔 Test failed - checks-actions

@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@Noratrieb
Copy link
Member Author

@bors retry
@bors treeclosed ghcr network errors

@Noratrieb
Copy link
Member Author

@bors treeclosed=100

@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Collaborator

bors commented Mar 4, 2025

⌛ Testing commit a954c51 with merge f9e0239...

@bors
Copy link
Collaborator

bors commented Mar 4, 2025

☀️ Test successful - checks-actions
Approved by: bjorn3
Pushing f9e0239 to master...

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f9e0239): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary -1.5%, secondary 0.8%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.5% [2.1%, 3.0%] 2
Improvements ✅
(primary)
-1.5% [-1.5%, -1.5%] 1
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) -1.5% [-1.5%, -1.5%] 1

Cycles

Results (secondary -6.3%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-6.3% [-6.4%, -6.2%] 2
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: missing data
Artifact size: 362.04 MiB -> 362.05 MiB (0.00%)

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

Labels

A-compiletest Area: The compiletest test runner A-linkage Area: linking into static, shared libraries and binaries A-run-make Area: port run-make Makefiles to rmake.rs A-rustc-dev-guide Area: rustc-dev-guide A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.