Skip to content

Commit

Permalink
Add the new linker-flavor field to target json
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-opp committed Apr 12, 2017
1 parent a1a135a commit 512cfe7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions blog/content/post/03-set-up-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Rust allows us to define [custom targets] through a JSON configuration file. A m
{
"llvm-target": "x86_64-unknown-linux-gnu",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
"linker-flavor": "gcc",
"target-endian": "little",
"target-pointer-width": "64",
"arch": "x86_64",
Expand All @@ -113,6 +114,11 @@ The `llvm-target` field specifies the target triple that is passed to LLVM. [Tar

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.

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.

[#40018]: https://github.com/rust-lang/rust/pull/40018
[LLD]: https://lld.llvm.org/

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.

[data layout]: http://llvm.org/docs/LangRef.html#data-layout
Expand Down
1 change: 1 addition & 0 deletions x86_64-blog_os.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"llvm-target": "x86_64-unknown-linux-gnu",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
"linker-flavor": "gcc",
"target-endian": "little",
"target-pointer-width": "64",
"arch": "x86_64",
Expand Down

0 comments on commit 512cfe7

Please sign in to comment.