@@ -28,7 +28,7 @@ use-cases.
28
28
We’ve observed a considerable amount of desire by users of the language to customize targets they
29
29
use in the ways currently not supported by our current infrastructure (sans making changes to the
30
30
compiler itself, of course), and noted that the current scheme is not very feasible in the long
31
- run. This RFC should go a great amount towards fixing the issues.
31
+ run. This RFC should go a long way towards fixing the issues.
32
32
33
33
Then, there also is a strong need to be able to inspect arbitrary parts of target specification,
34
34
regardless of their origin. For example, in a cross-compilation setting, when the crate uses a
@@ -94,13 +94,14 @@ while LLVM appears to use the highest supported version of Dwarf by default.
94
94
* similarly for many other variables which tweak the way compilation is done.
95
95
96
96
¹: Technically, ` target_pointer_width ` is used in trans, but it does not provide any extra
97
- information over ` data_layout ` , which is what it should be using.
97
+ information over ` data_layout ` , which is already used elsewhere in the compiler to calculate
98
+ layout, sizing information and alignment of all types, including the pointers.
98
99
99
100
This would allow selectively reusing various conditional implementations that are present in the
100
101
compiler for a custom target, when none of the ` is_like_* ` variables would fully suit the target.
101
102
Moreover, being able to specify arbitrary cfg variables would allow easily adapting for various
102
103
miniscule details related to the targets. For example, the targets for ARM CPUs with NEON support
103
- could export ` target_has_neon ` without any extra language support.
104
+ could export ` target_has_neon ` without any extra language or compiler support.
104
105
105
106
That being said, it might make sense to have a whitelist of stable options and cfg variables and
106
107
keep everything else unstable for some duration.
@@ -110,11 +111,11 @@ keep everything else unstable for some duration.
110
111
``` js
111
112
{
112
113
// REQUIRED
113
- " llvm-target " : " x86_64-unknown-linux-gnu" , // LLVM target triple (does not need to match with rustc triple)
114
- " data-layout " : " e-m:e-i64:64-f80:128-n8:16:32:64-S128" , // DataLayout for the target
114
+ " llvm_target " : " x86_64-unknown-linux-gnu" , // LLVM target triple (does not need to match with rustc triple)
115
+ " data_layout " : " e-m:e-i64:64-f80:128-n8:16:32:64-S128" , // DataLayout for the target
115
116
" arch" : " x86_64" , // Architecture of the target
116
117
117
- // OPTIONAL
118
+ // OPTIONAL (should have sane defaults)
118
119
// Configuration variables injected into the compilation units.
119
120
" cfg" : {
120
121
" target_os" : " linux" ,
@@ -131,64 +132,59 @@ keep everything else unstable for some duration.
131
132
},
132
133
133
134
// Type of, and the linker used
134
- " linker-kind" : " gnu" , // previously linker_is_gnu: bool
135
+ " linker_kind" : " gnu" , // previously linker_is_gnu: bool
136
+ // possible values: "gnu", "msvc", "osx"
135
137
" linker" : " cc" ,
136
138
" ar" : " ar" ,
137
- " archive-format" : " gnu" ,
138
-
139
- // Various stuff adjusting how compilation is done
140
- " function-sections" : true ,
141
- " dynamic-linking" : true ,
142
- " disable-redzone" : false ,
143
- " obj-is-bitcode" : false ,
144
- " allow-asm" : true ,
145
- " allows-weak-linkage" : true ,
146
- " no-default-libraries" : true ,
147
- " custom-unwind-resume" : false , // might make sense to merge into below
148
- " eh-method" : " dwarf" , // NEW: what EH method to use
149
- " dll-storage-attrs" : false , // NEW: should use dll storage attrs?
150
- " debug-info" : [" Dwarf" , 4 ], // NEW: what debug info format
151
- " system-abi" : " C" , // NEW: what "system" ABI means
152
- " c-abi-kind" : " cabi_x86_64" , // NEW: what C-ABI implementation to use
153
-
154
- // Various stuff adjusting how linkage is done
155
- " pre-link-args" : [" -Wl,--as-needed" , " -Wl,-z,noexecstack" ],
156
- " post-link-args" : [],
157
- " pre-link-objects-dll" : [],
158
- " pre-link-objects-exe" : [],
159
- " post-link-objects" : [],
160
- " late-link-args" : [],
161
- " gc-sections-args" : [], // NEW: how to strip sections
162
- " rpath-prefix" : " $ORIGIN" , // CHANGED: to allow specifying rpath prefix, null to disable rpath altogether
163
- " no-compiler-rt" : false ,
164
- " metadata-section" : " .note.rustc" , // NEW: name of section for metadata
165
- " has-frameworks" : false , // NEW: is concept of frameworks supported?
166
- " position-independent-executables" : true , // should become a plain linker argument?
139
+ " archive_format" : " gnu" ,
140
+
141
+ " function_sections" : true ,
142
+ " dynamic_linking" : true ,
143
+ " disable_redzone" : false ,
144
+ " obj_is_bitcode" : false ,
145
+ " allow_asm" : true ,
146
+ " allows_weak_linkage" : true ,
147
+ " no_default_libraries" : true ,
148
+ " custom_unwind_resume" : false , // might make sense to merge into below
149
+ " eh_method" : " dwarf" , // NEW: what EH method to use
150
+ " dll_storage_attrs" : false , // NEW: should use dll storage attrs?
151
+ " debug_info" : [" Dwarf" , 4 ], // NEW: what debug info format
152
+ " system_abi" : " C" , // NEW: what "system" ABI means
153
+ " c_abi_kind" : " cabi_x86_64" , // NEW: what C_ABI implementation to use
154
+
155
+ " pre_link_args" : [" _Wl,__as_needed" , " _Wl,_z,noexecstack" ],
156
+ " post_link_args" : [],
157
+ " pre_link_objects_dll" : [],
158
+ " pre_link_objects_exe" : [],
159
+ " post_link_objects" : [],
160
+ " late_link_args" : [],
161
+ " gc_sections_args" : [], // NEW: how to strip sections
162
+ " rpath_prefix" : " $ORIGIN" , // CHANGED: to allow specifying rpath prefix, null to disable rpath altogether
163
+ " no_compiler_rt" : false ,
164
+ " metadata_section" : " .note.rustc" , // NEW: name of section for metadata
165
+ " has_frameworks" : false , // NEW: is concept of frameworks supported?
166
+ " position_independent_executables" : true , // should become a plain linker argument?
167
167
" lib_allocation_crate" : " alloc_system" ,
168
168
" exe_allocation_crate" : " alloc_jemalloc" ,
169
- // should become templates ? `lib{}.so` is much nicer
169
+ // should become a template ? `lib{}.so` is much nicer
170
170
" dll_prefix" : " lib" ,
171
171
" dll_suffix" : " .so" ,
172
172
" exe_suffix" : " " ,
173
173
" staticlib_prefix" : " lib" ,
174
174
" staticlib_suffix" : " .a" ,
175
175
176
- // LLVM options
177
- " cpu" : " x86-64" , // CPU of the target
176
+ " cpu" : " x86_64" , // CPU of the target
178
177
" features" : " " , // LLVM features
179
178
" relocation_model" : " pic" ,
180
179
" code_model" : " default" ,
181
- " eliminate-frame-pointer" : true ,
182
-
183
- // Apparently OS X is so much of a special case that even moving all the special cases into
184
- // configuration is painful.
185
- is_like_osx: false ,
186
-
187
- // is_like_solaris is handled by the extra gc-sections key
188
- // is_like_msvc is handled by the extra metadata-section, linker-kind, eh-method,
189
- // dll-storage-attrs, debug-info keys
190
- // is_like_windows is handled by the extra system-abi and c-abi-kind keys
191
- // is_like_android is handled by the extra debug-info key
180
+ " eliminate_frame_pointer" : true ,
181
+
182
+ // is_like_solaris is handled by the extra gc_sections_args key
183
+ // is_like_msvc is handled by the extra metadata_section, linker_kind, eh_method,
184
+ // dll_storage_attrs, debug_info keys
185
+ // is_like_windows is handled by the extra system_abi and c_abi_kind keys
186
+ // is_like_android is handled by the extra debug_info key
187
+ // is_like_osx is handled by linker_kind: "osx", rpath_prefix, has_frameworks, c_abi_kind
192
188
}
193
189
```
194
190
@@ -241,5 +237,10 @@ values, though.
241
237
This RFC is still very viable without the proposed changes to JSON keys (the “target quirks and
242
238
cfg” as well as the “proposed JSON key-values” sections).
243
239
240
+ Keep distributing all the built-in targets with the rustc package.
241
+
242
+ Since we’re already tweaking the structure of the target json spec, instead of allowing comments in
243
+ JSON, just switch to TOML.
244
+
244
245
# Unresolved questions
245
246
[ unresolved ] : #unresolved-questions
0 commit comments