File tree Expand file tree Collapse file tree 8 files changed +39
-36
lines changed
compiler/rustc_codegen_ssa/src/back
native-link-modifier-verbatim-linker
native-link-modifier-verbatim-rustc
native-link-modifier-verbatim Expand file tree Collapse file tree 8 files changed +39
-36
lines changed Original file line number Diff line number Diff line change @@ -439,7 +439,10 @@ impl<'a> Linker for GccLinker<'a> {
439
439
}
440
440
}
441
441
self.hint_dynamic();
442
- self.cmd.arg(format!("-l{}{}", if verbatim { ":" } else { "" }, lib));
442
+ self.cmd.arg(format!(
443
+ "-l{}{lib}",
444
+ if verbatim && self.sess.target.linker_is_gnu { ":" } else { "" },
445
+ ));
443
446
if !as_needed {
444
447
if self.sess.target.is_like_osx {
445
448
// See above FIXME comment
@@ -450,7 +453,10 @@ impl<'a> Linker for GccLinker<'a> {
450
453
}
451
454
fn link_staticlib(&mut self, lib: &str, verbatim: bool) {
452
455
self.hint_static();
453
- self.cmd.arg(format!("-l{}{}", if verbatim { ":" } else { "" }, lib));
456
+ self.cmd.arg(format!(
457
+ "-l{}{lib}",
458
+ if verbatim && self.sess.target.linker_is_gnu { ":" } else { "" },
459
+ ));
454
460
}
455
461
fn link_rlib(&mut self, lib: &Path) {
456
462
self.hint_static();
@@ -504,10 +510,10 @@ impl<'a> Linker for GccLinker<'a> {
504
510
self.hint_static();
505
511
let target = &self.sess.target;
506
512
if !target.is_like_osx {
507
- self.linker_arg("--whole-archive").cmd.arg(format!(
508
- "-l{}{}",
509
- if verbatim { ":" } else { "" } ,
510
- lib
513
+ self.linker_arg("--whole-archive");
514
+ self.cmd.arg(format!(
515
+ "-l{}{lib}" ,
516
+ if verbatim && self.sess.target.linker_is_gnu { ":" } else { "" },
511
517
));
512
518
self.linker_arg("--no-whole-archive");
513
519
} else {
Original file line number Diff line number Diff line change
1
+ # ignore-cross-compile
2
+ # ignore-macos
3
+
4
+ include ../../run-make-fulldeps/tools.mk
5
+
6
+ all :
7
+ # Verbatim allows specify precise name.
8
+ $(RUSTC ) local_native_dep.rs --crate-type=staticlib -o $(TMPDIR ) /local_some_strange_name.ext
9
+ $(RUSTC ) main.rs -Zunstable-options -l static:+verbatim=local_some_strange_name.ext
10
+
11
+ # With verbatim any other name cannot be used (local).
12
+ $(RUSTC) local_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/liblocal_native_dep.a
13
+ $(RUSTC) local_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/local_native_dep.a
14
+ $(RUSTC) local_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/local_native_dep.lib
15
+ $(RUSTC) main.rs -Zunstable-options -l static:+verbatim=local_native_dep 2>&1 | $(CGREP) "local_native_dep"
File renamed without changes.
Original file line number Diff line number Diff line change 1
- extern crate rust_dep;
2
-
3
1
extern "C" {
4
2
fn local_native_f() -> i32;
5
3
}
@@ -8,5 +6,4 @@ pub fn main() {
8
6
unsafe {
9
7
assert!(local_native_f() == 0);
10
8
};
11
- rust_dep::rust_dep()
12
9
}
Original file line number Diff line number Diff line change
1
+ include ../../run-make-fulldeps/tools.mk
2
+
3
+ all :
4
+ # Verbatim allows specify precise name.
5
+ $(RUSTC ) upstream_native_dep.rs --crate-type=staticlib -o $(TMPDIR ) /upstream_some_strange_name.ext
6
+ $(RUSTC ) rust_dep.rs -Zunstable-options -l static:+verbatim=upstream_some_strange_name.ext --crate-type rlib
7
+
8
+ # With verbatim any other name cannot be used (upstream).
9
+ $(RUSTC) upstream_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/libupstream_native_dep.a
10
+ $(RUSTC) upstream_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/upstream_native_dep.a
11
+ $(RUSTC) upstream_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/upstream_native_dep.lib
12
+ $(RUSTC) rust_dep.rs -Zunstable-options -l static:+verbatim=upstream_native_dep --crate-type rlib 2>&1 | $(CGREP) "upstream_native_dep"
File renamed without changes.
File renamed without changes.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments