@@ -16,6 +16,7 @@ use rustc_metadata::fs::METADATA_FILENAME;
1616use rustc_metadata:: EncodedMetadata ;
1717use rustc_session:: cstore:: MetadataLoader ;
1818use rustc_session:: Session ;
19+ use rustc_span:: sym;
1920use rustc_target:: abi:: Endian ;
2021use rustc_target:: spec:: { ef_avr_arch, RelocModel , Target } ;
2122
@@ -272,35 +273,37 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
272273 Architecture :: Riscv32 | Architecture :: Riscv64 => {
273274 // Source: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/079772828bd10933d34121117a222b4cc0ee2200/riscv-elf.adoc
274275 let mut e_flags: u32 = 0x0 ;
275- let features = & sess . target . options . features ;
276+
276277 // Check if compressed is enabled
277- if features . contains ( "+c" ) {
278+ if sess . unstable_target_features . contains ( & sym :: c ) {
278279 e_flags |= elf:: EF_RISCV_RVC ;
279280 }
280281
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" ) ,
288290 }
291+
289292 e_flags
290293 }
291294 Architecture :: LoongArch64 => {
292295 // Source: https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc#e_flags-identifies-abi-type-and-version
293296 let mut e_flags: u32 = elf:: EF_LARCH_OBJABI_V1 ;
294- let features = & sess. target . options . features ;
295297
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" ) ,
303305 }
306+
304307 e_flags
305308 }
306309 Architecture :: Avr => {
0 commit comments