Skip to content

Commit 829a718

Browse files
authored
Rollup merge of #98778 - dpaoliello:rawdylibbin, r=michaelwoerister
Enable raw-dylib for bin crates Fixes #93842 When a `raw-dylib` is used in a `bin` crate, we need to link to the library name specified.
2 parents 9ed515f + b8213bb commit 829a718

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,7 +2212,9 @@ fn add_local_native_libraries(
22122212
NativeLibKind::Dylib { as_needed } => {
22132213
cmd.link_dylib(name, verbatim, as_needed.unwrap_or(true))
22142214
}
2215-
NativeLibKind::Unspecified => cmd.link_dylib(name, verbatim, true),
2215+
NativeLibKind::RawDylib | NativeLibKind::Unspecified => {
2216+
cmd.link_dylib(name, verbatim, true)
2217+
}
22162218
NativeLibKind::Framework { as_needed } => {
22172219
cmd.link_framework(name, as_needed.unwrap_or(true))
22182220
}
@@ -2233,10 +2235,6 @@ fn add_local_native_libraries(
22332235
cmd.link_staticlib(name, verbatim)
22342236
}
22352237
}
2236-
NativeLibKind::RawDylib => {
2237-
// FIXME(#58713): Proper handling for raw dylibs.
2238-
bug!("raw_dylib feature not yet implemented");
2239-
}
22402238
}
22412239
}
22422240
}

src/test/run-make/raw-dylib-c/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ else
1616
endif
1717
$(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs
1818
$(RUSTC) --crate-type bin driver.rs -L "$(TMPDIR)"
19+
$(RUSTC) --crate-type bin --crate-name raw_dylib_test_bin lib.rs
1920
"$(TMPDIR)"/driver > "$(TMPDIR)"/output.txt
21+
"$(TMPDIR)"/raw_dylib_test_bin > "$(TMPDIR)"/output_bin.txt
2022

2123
ifdef RUSTC_BLESS_TEST
2224
cp "$(TMPDIR)"/output.txt output.txt
2325
else
2426
$(DIFF) output.txt "$(TMPDIR)"/output.txt
27+
$(DIFF) output.txt "$(TMPDIR)"/output_bin.txt
2528
endif

src/test/run-make/raw-dylib-c/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ pub fn library_function() {
2020
extern_fn_3();
2121
}
2222
}
23+
24+
fn main() {
25+
library_function();
26+
}

0 commit comments

Comments
 (0)