add tests for s390x-unknown-none-softfloat

tests will check:
- correct emit of assembly for softfloat target
- incompatible set features will emit warnings/errors
- incompatible target tripples in crates will not link
This commit is contained in:
Eddy (Eduard) Stefes 2026-01-22 13:50:54 +01:00
parent 2b1dc3144b
commit 51affa0394
10 changed files with 182 additions and 1 deletions

View file

@ -0,0 +1,64 @@
//@ add-minicore
//@ revisions: enable-softfloat disable-softfloat
//@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=3 --crate-type=lib
//@[enable-softfloat] compile-flags: --target=s390x-unknown-none-softfloat
//@[enable-softfloat] needs-llvm-components: systemz
//@[disable-softfloat] compile-flags: --target=s390x-unknown-linux-gnu
//@[disable-softfloat] needs-llvm-components: systemz
//@ ignore-backends: gcc
#![feature(no_core, lang_items)]
#![no_std]
#![no_core]
extern crate minicore;
use minicore::*;
extern "C" {
fn extern_func(value: f64) -> f64;
}
// CHECK-LABEL: test_softfloat
#[no_mangle]
extern "C" fn test_softfloat() -> f64 {
let value = 3.141_f64;
// without softfloat we load the value direct to the first float register
// we do NOT construct a softfloat in r2 (first non-float arg register)
// disable-softfloat: ld %f{{.*}}, 0(%r{{.*}})
// disable-softfloat-NOT: llihf %r{{.*}}, 1074340036
// disable-softfloat-NOT: oilf %r{{.*}}, 2611340116
// with softfloat we construct the softfloat arg in r2
// we do NOT pass anything by f0 (first float arg register)
// float registers can not be accessed
// enable-softfloat: llihf %r{{.*}}, 1074340036
// enable-softfloat-NEXT: oilf %r{{.*}}, 2611340116
// enable-softfloat-NOT: ld %f{{.*}}, 0(%r{{.*}})
unsafe { extern_func(value) };
// disable-softfloat-NEXT: brasl %r{{.*}}, extern_func@PLT
// enable-softfloat-NEXT: brasl %r{{.*}}, extern_func@PLT
// for return we check that without softfloat we write to float register
// disable-softfloat: ld %f{{.*}}, 0(%r{{.*}})
// disable-softfloat-NOT: llihf %r{{.*}}, 1072841097
// disable-softfloat-NOT: oilf %r{{.*}}, 927712936
#[cfg(not(target_feature = "soft-float"))]
{
1.141_f64
}
// for return we check that WITH softfloat we write to genral purpose register
// enable-softfloat: llihf %r{{.*}}, 1072841097
// enable-softfloat-NEXT: oilf %r{{.*}}, 927712936
// enable-softfloat-NOT: ld %f{{.*}}, 0(%r{{.*}})
#[cfg(target_feature = "soft-float")]
{
2.718_f64
}
// enable-softfloat: br %r{{.*}}
// disable-softfloat: br %r{{.*}}
}

View file

@ -0,0 +1,12 @@
warning: target feature `soft-float` cannot be enabled with `-Ctarget-feature`: unsupported ABI-configuration feature
|
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
warning: target feature `soft-float` must be disabled to ensure that the ABI of the current target can be implemented correctly
|
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
warning: 2 warnings emitted

View file

@ -0,0 +1,7 @@
warning: target feature `vector` must be disabled to ensure that the ABI of the current target can be implemented correctly
|
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
warning: 1 warning emitted

View file

@ -0,0 +1,38 @@
//@ add-minicore
//@ revisions: disable-softfloat enable-softfloat
//@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=3 --crate-type=lib
// we expect the build to fail in the feature
//@ build-pass
//@ [enable-softfloat] compile-flags: --target=s390x-unknown-none-softfloat
//@ [enable-softfloat] compile-flags: -C target-feature=+vector
//@ [enable-softfloat] needs-llvm-components: systemz
//@ [disable-softfloat] compile-flags: --target=s390x-unknown-linux-gnu
//@ [disable-softfloat] compile-flags: -C target-feature=+soft-float
//@ [disable-softfloat] needs-llvm-components: systemz
//@ ignore-backends: gcc
//[disable-softfloat]~? WARN target feature `soft-float` must be disabled to ensure that the ABI of the current target can be implemented correctly
//[disable-softfloat]~? WARN target feature `soft-float` cannot be enabled with `-Ctarget-feature`
//[enable-softfloat]~? WARN target feature `vector` must be disabled to ensure that the ABI of the current target can be implemented correctly
#![feature(no_core, lang_items)]
#![no_std]
#![no_core]
extern crate minicore;
use minicore::*;
extern "C" {
fn extern_func(value: f64) -> f64;
}
#[no_mangle]
extern "C" fn test_softfloat() -> f64 {
let value = 3.141_f64;
unsafe { extern_func(value) } ;
2.718_f64
}

View file

@ -1,4 +1,4 @@
warning: target feature `soft-float` cannot be enabled with `-Ctarget-feature`: currently unsupported ABI-configuration feature
warning: target feature `soft-float` cannot be enabled with `-Ctarget-feature`: unsupported ABI-configuration feature
|
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>

View file

@ -0,0 +1,8 @@
//@ add-minicore
//@ no-prefer-dynamic
//@ compile-flags: --target=s390x-unknown-linux-gnu
//@ needs-llvm-components: systemz
#![feature(no_core)]
#![crate_type = "rlib"]
#![no_core]

View file

@ -0,0 +1,8 @@
//@ add-minicore
//@ no-prefer-dynamic
//@ compile-flags: --target=s390x-unknown-none-softfloat
//@ needs-llvm-components: systemz
#![feature(no_core)]
#![crate_type = "rlib"]
#![no_core]

View file

@ -0,0 +1,12 @@
error[E0461]: couldn't find crate `enabled_softfloat` with expected target triple s390x-unknown-linux-gnu
--> $DIR/incompatible_softfloat_targets.rs:17:1
|
LL | extern crate enabled_softfloat;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the following crate versions were found:
crate `enabled_softfloat`, target triple s390x-unknown-none-softfloat: $TEST_BUILD_DIR/auxiliary/libenabled_softfloat.rlib
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0461`.

View file

@ -0,0 +1,12 @@
error[E0461]: couldn't find crate `disabled_softfloat` with expected target triple s390x-unknown-none-softfloat
--> $DIR/incompatible_softfloat_targets.rs:19:1
|
LL | extern crate disabled_softfloat;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the following crate versions were found:
crate `disabled_softfloat`, target triple s390x-unknown-linux-gnu: $TEST_BUILD_DIR/auxiliary/libdisabled_softfloat.rlib
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0461`.

View file

@ -0,0 +1,20 @@
//@ add-minicore
//@ aux-build: disabled_softfloat.rs
//@ aux-build: enabled_softfloat.rs
//@ revisions: disable-softfloat enable-softfloat
//@ check-fail
//@ [enable-softfloat] compile-flags: --target=s390x-unknown-none-softfloat
//@ [enable-softfloat] needs-llvm-components: systemz
//@ [disable-softfloat] compile-flags: --target=s390x-unknown-linux-gnu
//@ [disable-softfloat] needs-llvm-components: systemz
//@ ignore-backends: gcc
#![feature(no_core)]
#![crate_type = "rlib"]
#![no_core]
extern crate enabled_softfloat;
//[disable-softfloat]~^ ERROR couldn't find crate `enabled_softfloat` with expected target triple s390x-unknown-linux-gnu
extern crate disabled_softfloat;
//[enable-softfloat]~^ ERROR couldn't find crate `disabled_softfloat` with expected target triple s390x-unknown-none-softfloat