@@ -16,6 +16,7 @@ use rustc_metadata::fs::METADATA_FILENAME;
16
16
use rustc_metadata:: EncodedMetadata ;
17
17
use rustc_session:: cstore:: MetadataLoader ;
18
18
use rustc_session:: Session ;
19
+ use rustc_span:: sym;
19
20
use rustc_target:: abi:: Endian ;
20
21
use rustc_target:: spec:: { ef_avr_arch, RelocModel , Target } ;
21
22
@@ -272,35 +273,37 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
272
273
Architecture :: Riscv32 | Architecture :: Riscv64 => {
273
274
// Source: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/079772828bd10933d34121117a222b4cc0ee2200/riscv-elf.adoc
274
275
let mut e_flags: u32 = 0x0 ;
275
- let features = & sess . target . options . features ;
276
+
276
277
// Check if compressed is enabled
277
- if features . contains ( "+c" ) {
278
+ if sess . unstable_target_features . contains ( & sym :: c ) {
278
279
e_flags |= elf:: EF_RISCV_RVC ;
279
280
}
280
281
281
- // Select the appropriate floating-point ABI
282
- if features. contains ( "+d" ) {
283
- e_flags |= elf:: EF_RISCV_FLOAT_ABI_DOUBLE ;
284
- } else if features. contains ( "+f" ) {
285
- e_flags |= elf:: EF_RISCV_FLOAT_ABI_SINGLE ;
286
- } else {
287
- e_flags |= elf:: EF_RISCV_FLOAT_ABI_SOFT ;
282
+ // Set the appropriate flag based on ABI
283
+ // This needs to match LLVM `RISCVELFStreamer.cpp`
284
+ match & * sess. target . llvm_abiname {
285
+ "ilp32" | "lp64" => ( ) ,
286
+ "ilp32f" | "lp64f" => e_flags |= elf:: EF_RISCV_FLOAT_ABI_SINGLE ,
287
+ "ilp32d" | "lp64d" => e_flags |= elf:: EF_RISCV_FLOAT_ABI_DOUBLE ,
288
+ "ilp32e" => e_flags |= elf:: EF_RISCV_RVE ,
289
+ _ => bug ! ( "unknown RISC-V ABI name" ) ,
288
290
}
291
+
289
292
e_flags
290
293
}
291
294
Architecture :: LoongArch64 => {
292
295
// Source: https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc#e_flags-identifies-abi-type-and-version
293
296
let mut e_flags: u32 = elf:: EF_LARCH_OBJABI_V1 ;
294
- let features = & sess. target . options . features ;
295
297
296
- // Select the appropriate floating-point ABI
297
- if features . contains ( "+d" ) {
298
- e_flags |= elf :: EF_LARCH_ABI_DOUBLE_FLOAT ;
299
- } else if features . contains ( "+f" ) {
300
- e_flags |= elf:: EF_LARCH_ABI_SINGLE_FLOAT ;
301
- } else {
302
- e_flags |= elf :: EF_LARCH_ABI_SOFT_FLOAT ;
298
+ // Set the appropriate flag based on ABI
299
+ // This needs to match LLVM `LoongArchELFStreamer.cpp`
300
+ match & * sess . target . llvm_abiname {
301
+ "ilp32s" | "lp64s" => e_flags |= elf :: EF_LARCH_ABI_SOFT_FLOAT ,
302
+ "ilp32f" | "lp64f" => e_flags |= elf:: EF_LARCH_ABI_SINGLE_FLOAT ,
303
+ "ilp32d" | "lp64d" => e_flags |= elf :: EF_LARCH_ABI_DOUBLE_FLOAT ,
304
+ _ => bug ! ( "unknown RISC-V ABI name" ) ,
303
305
}
306
+
304
307
e_flags
305
308
}
306
309
Architecture :: Avr => {
0 commit comments