Skip to content

Commit 2a177b7

Browse files
author
Jorge Aparicio
committed
add some documentation to the unstable book
1 parent 95bb454 commit 2a177b7

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

src/doc/unstable-book/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
- [link_llvm_intrinsics](link-llvm-intrinsics.md)
107107
- [linkage](linkage.md)
108108
- [linked_list_extras](linked-list-extras.md)
109+
- [linker-flavor](linker-flavor.md)
109110
- [log_syntax](log-syntax.md)
110111
- [lookup_host](lookup-host.md)
111112
- [loop_break_value](loop-break-value.md)
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# `linker-flavor`
2+
3+
The tracking issue for this feature is: None
4+
5+
------------------------
6+
7+
Every `rustc` target defaults to some linker. For example, Linux targets default
8+
to gcc. In some cases, you may want to override the default; you can do that
9+
with the unstable CLI argument: `-Z linker-flavor`.
10+
11+
Here how you would use this flag to link a Rust binary for the
12+
`thumbv7m-none-eabi` using LLD instead of GCC.
13+
14+
``` text
15+
$ xargo rustc --target thumbv7m-none-eabi -- \
16+
-C linker=ld.lld \
17+
-Z linker-flavor=ld \
18+
-Z print-link-args | tr ' ' '\n'
19+
"ld.lld"
20+
"-L"
21+
"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib"
22+
"$PWD/target/thumbv7m-none-eabi/debug/deps/app-512e9dbf385f233c.0.o"
23+
"-o"
24+
"$PWD/target/thumbv7m-none-eabi/debug/deps/app-512e9dbf385f233c"
25+
"--gc-sections"
26+
"-L"
27+
"$PWD/target/thumbv7m-none-eabi/debug/deps"
28+
"-L"
29+
"$PWD/target/debug/deps"
30+
"-L"
31+
"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib"
32+
"-Bstatic"
33+
"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib/libcore-e1ccb7dfb1cb9ebb.rlib"
34+
"-Bdynamic"
35+
```
36+
37+
Whereas the default is:
38+
39+
```
40+
$ xargo rustc --target thumbv7m-none-eabi -- \
41+
-C link-arg=-nostartfiles \
42+
-Z print-link-args | tr ' ' '\n'
43+
"arm-none-eabi-gcc"
44+
"-L"
45+
"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib"
46+
"$PWD/target/thumbv7m-none-eabi/debug/deps/app-961e39416baa38d9.0.o"
47+
"-o"
48+
"$PWD/target/thumbv7m-none-eabi/debug/deps/app-961e39416baa38d9"
49+
"-Wl,--gc-sections"
50+
"-nodefaultlibs"
51+
"-L"
52+
"$PWD/target/thumbv7m-none-eabi/debug/deps"
53+
"-L"
54+
"$PWD/target/debug/deps"
55+
"-L"
56+
"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib"
57+
"-Wl,-Bstatic"
58+
"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib/libcore-e1ccb7dfb1cb9ebb.rlib"
59+
"-nostartfiles"
60+
"-Wl,-Bdynamic"
61+
```

0 commit comments

Comments
 (0)