Skip to content

Commit 859d803

Browse files
committed
Merge branch 'master' into release-0.7.3
2 parents e910d17 + 28d2a21 commit 859d803

File tree

6 files changed

+87
-10
lines changed

6 files changed

+87
-10
lines changed

Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cargo-auditable/src/rustc_wrapper.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ fn rustc_command_with_audit_data(rustc_path: &OsStr) -> Option<Command> {
128128
// Prevent the symbol from being removed as unused by the linker
129129
if is_apple(&target_info) {
130130
if args.bare_linker() {
131-
command.arg("-Clink-arg=-u,_AUDITABLE_VERSION_INFO");
131+
command.arg("-Clink-arg=-u");
132+
command.arg("-Clink-arg=_AUDITABLE_VERSION_INFO");
132133
} else {
133134
command.arg("-Clink-arg=-Wl,-u,_AUDITABLE_VERSION_INFO");
134135
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# copied from https://github.com/EFForg/rayhunter/blob/adeeb751667d3b44ba6ad215a1bc0ac73d90ae72/.cargo/config.toml#L1
2+
# as a motivating example for bare linker support
3+
4+
[target.aarch64-apple-darwin]
5+
linker = "rust-lld"
6+
rustflags = ["-C", "target-feature=+crt-static"]
7+
8+
[target.aarch64-unknown-linux-musl]
9+
linker = "rust-lld"
10+
rustflags = ["-C", "target-feature=+crt-static"]
11+
12+
# apt install build-essential libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf
13+
[target.armv7-unknown-linux-gnueabihf]
14+
linker = "arm-linux-gnueabihf-gcc"
15+
rustflags = ["-C", "target-feature=+crt-static"]
16+
17+
[target.armv7-unknown-linux-musleabihf]
18+
linker = "rust-lld"
19+
rustflags = ["-C", "target-feature=+crt-static"]
20+
21+
[target.armv7-unknown-linux-musleabi]
22+
linker = "rust-lld"
23+
rustflags = ["-C", "target-feature=+crt-static"]
24+
25+
# Disable rust-lld for x86 macOS because the linker crashers when compiling
26+
# the installer in release mode with debug info on.
27+
# [target.x86_64-apple-darwin]
28+
# linker = "rust-lld"
29+
# rustflags = ["-C", "target-feature=+crt-static"]
30+
31+
[target.x86_64-unknown-linux-musl]
32+
linker = "rust-lld"
33+
rustflags = ["-C", "target-feature=+crt-static"]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "bare_linker"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
8+
[workspace]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello, world!");
3+
}

cargo-auditable/tests/it.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,3 +585,35 @@ fn test_proc_macro_inner(sbom: bool) {
585585
.expect("Could not find 'syn' in the embedded dependency list!");
586586
assert_eq!(syn_info.kind, DependencyKind::Build);
587587
}
588+
589+
#[test]
590+
fn test_bare_linker() {
591+
test_bare_linker_inner(false);
592+
test_bare_linker_inner(true);
593+
}
594+
fn test_bare_linker_inner(sbom: bool) {
595+
// Path to workspace fixture Cargo.toml
596+
let cargo_toml =
597+
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/bare_linker/Cargo.toml");
598+
// The motivating example is https://github.com/EFForg/rayhunter/blob/main/.cargo/config.toml
599+
// and the config file fixture is based on that.
600+
// There doesn't seem to be a way to build with a bare linker for GNU targets, only Apple and Musl,
601+
// so this tests really only does anything on those.
602+
let config_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
603+
.join("tests/fixtures/bare_linker/.cargo/config.toml");
604+
605+
let bins = run_cargo_auditable(
606+
cargo_toml,
607+
&["--config", config_path.to_str().unwrap()],
608+
&[],
609+
sbom,
610+
);
611+
eprintln!("Test fixture binary map: {bins:?}");
612+
613+
// bare_linker should only depend on itself
614+
let bare_linker_bin = &bins.get("bare_linker").unwrap()[0];
615+
let dep_info = get_dependency_info(bare_linker_bin);
616+
eprintln!("{bare_linker_bin} dependency info: {dep_info:?}");
617+
assert!(dep_info.packages.len() == 1);
618+
assert!(dep_info.packages.iter().any(|p| p.name == "bare_linker"));
619+
}

0 commit comments

Comments
 (0)