Source: rustc Version: 1.31.0+dfsg1-2 Severity: normal Tags: upstream patch User: debian-sparc@lists.debian.org Usertags: sparc64
Hi! The Rust compiler misses some special handling for empty structs in the C ABI. This was discovered today by Michael Karcher who has written a patch to address the issue, it's already sent upstream [1]. I'm attaching the patch. With the patches from #916818, #917000 and #917191, the testsuite failures on sparc64 drop to 9 for me. > [1] https://github.com/rust-lang/rust/pull/57085 -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaub...@debian.org `. `' Freie Universitaet Berlin - glaub...@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
>From 970747edb47795a1012929ea468c2b75f087b289 Mon Sep 17 00:00:00 2001 From: Michael Karcher <git...@mkarcher.dialup.fu-berlin.de> Date: Sun, 23 Dec 2018 20:33:52 +0100 Subject: [PATCH] librustc_codegen_llvm: Don't eliminate empty structs in C ABI on linux-sparc64 This is in accordance with the SPARC Compliance Definition 4.2.1, Page 3P-12. It says that structs of up to 8 bytes (which applies to empty structs as well) are to be passed in one register. --- src/librustc_codegen_llvm/abi.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/librustc_codegen_llvm/abi.rs b/src/librustc_codegen_llvm/abi.rs index b8954dee79..c083137f08 100644 --- a/src/librustc_codegen_llvm/abi.rs +++ b/src/librustc_codegen_llvm/abi.rs @@ -456,6 +456,9 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> { let linux_s390x = target.target_os == "linux" && target.arch == "s390x" && target.target_env == "gnu"; + let linux_sparc64 = target.target_os == "linux" + && target.arch == "sparc64" + && target.target_env == "gnu"; let rust_abi = match sig.abi { RustIntrinsic | PlatformIntrinsic | Rust | RustCall => true, _ => false @@ -526,8 +529,9 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> { if arg.layout.is_zst() { // For some forsaken reason, x86_64-pc-windows-gnu // doesn't ignore zero-sized struct arguments. - // The same is true for s390x-unknown-linux-gnu. - if is_return || rust_abi || (!win_x64_gnu && !linux_s390x) { + // The same is true for s390x-unknown-linux-gnu + // and sparc64-unknown-linux-gnu. + if is_return || rust_abi || (!win_x64_gnu && !linux_s390x && !linux_sparc64) { arg.mode = PassMode::Ignore; } } -- 2.20.1