Skip to content

Commit c202937

Browse files
committed
Add the new linker-flavor field to target json
See rust-lang/rust#40018
1 parent 239e96e commit c202937

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

blog/content/post/03-set-up-rust.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Rust allows us to define [custom targets] through a JSON configuration file. A m
9797
{
9898
"llvm-target": "x86_64-unknown-linux-gnu",
9999
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
100+
"linker-flavor": "gcc",
100101
"target-endian": "little",
101102
"target-pointer-width": "64",
102103
"arch": "x86_64",
@@ -113,6 +114,11 @@ The `llvm-target` field specifies the target triple that is passed to LLVM. [Tar
113114

114115
The `data-layout` field is also passed to LLVM and specifies how data should be laid out in memory. It consists of various specifications seperated by a `-` character. For example, the `e` means little endian and `S128` specifies that the stack should be 128 bits (= 16 byte) aligned. The format is described in detail in the [LLVM documentation][data layout] but there shouldn't be a reason to change this string.
115116

117+
The `linker-flavor` field was recently introduced in [#40018] with the intention to add support for the LLVM linker [LLD], which is platform independent. In the future, this might allow easy cross compilation without the need to install a gcc cross compiler for linking.
118+
119+
[#40018]: https://github.com/rust-lang/rust/pull/40018
120+
[LLD]: https://lld.llvm.org/
121+
116122
The other fields are used for conditional compilation. This allows crate authors to use `cfg` variables to write special code for depending on the OS or the architecture. There isn't any up-to-date documentation about these fields but the [corresponding source code][target specification] is quite readable.
117123

118124
[data layout]: http://llvm.org/docs/LangRef.html#data-layout

x86_64-blog_os.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"llvm-target": "x86_64-unknown-linux-gnu",
33
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
4+
"linker-flavor": "gcc",
45
"target-endian": "little",
56
"target-pointer-width": "64",
67
"arch": "x86_64",

0 commit comments

Comments
 (0)