Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"cargo build" failed on s390x platform #986

Closed
xieqiang2020 opened this issue May 13, 2020 · 13 comments
Closed

"cargo build" failed on s390x platform #986

xieqiang2020 opened this issue May 13, 2020 · 13 comments
Milestone

Comments

@xieqiang2020
Copy link

Hi, I tried to build ring on s390x platform but got error:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', build.rs:364:34

From build.xs, line 364:

    let (_, _, perlasm_format) = ASM_TARGETS
        .iter()
        .find(|entry| {
            let &(entry_arch, entry_os, _) = *entry;
            entry_arch == &target.arch && is_none_or_equals(entry_os, &target.os)
        })
        .unwrap();

I searched ASM_TARGETS from build.xs:

const ASM_TARGETS: &[(&str, Option<&str>, &str)] = &[
    ("x86_64", Some("ios"), "macosx"),
    ("x86_64", Some("macos"), "macosx"),
    ("x86_64", Some(WINDOWS), "nasm"),
    ("x86_64", None, "elf"),
    ("aarch64", Some("ios"), "ios64"),
    ("aarch64", None, "linux64"),
    ("x86", Some(WINDOWS), "win32n"),
    ("x86", Some("ios"), "macosx"),
    ("x86", None, "elf"),
    ("arm", Some("ios"), "ios32"),
    ("arm", None, "linux32"),
];

It seems the error is due to no s390x support?

My question are:

  1. Does ring support s390x?
  2. If it does, how should I build it?
  3. If it doesn't, will it support s390x in the future? And if possible, at what time?

Thanks

The trace of "cargo build" is as below (RUST_BACKTRACE=1):

[linux1@linuxone ring]$ cargo build
   Compiling ring v0.16.13 (/home/linux1/ring)
error: failed to run custom build command for `ring v0.16.13 (/home/linux1/ring)`

Caused by:
  process didn't exit successfully: `/home/linux1/ring/target/debug/build/ring-596b2342a1654bcb/build-script-build` (exit code: 101)
--- stderr
ENV CARGO=/home/linux1/.rustup/toolchains/stable-s390x-unknown-linux-gnu/bin/cargo
ENV CARGO_CFG_TARGET_ARCH=s390x
ENV CARGO_CFG_TARGET_ENDIAN=big
ENV CARGO_CFG_TARGET_ENV=gnu
ENV CARGO_CFG_TARGET_FAMILY=unix
ENV CARGO_CFG_TARGET_OS=linux
ENV CARGO_CFG_TARGET_POINTER_WIDTH=64
ENV CARGO_CFG_TARGET_VENDOR=unknown
ENV CARGO_CFG_UNIX=
ENV CARGO_FEATURE_ALLOC=1
ENV CARGO_FEATURE_DEFAULT=1
ENV CARGO_FEATURE_DEV_URANDOM_FALLBACK=1
ENV CARGO_FEATURE_ONCE_CELL=1
ENV CARGO_HOME=/home/linux1/.cargo
ENV CARGO_MAKEFLAGS=--jobserver-fds=5,6 -j --jobserver-auth=5,6 -j
ENV CARGO_MANIFEST_DIR=/home/linux1/ring
ENV CARGO_MANIFEST_LINKS=ring-asm
ENV CARGO_PKG_AUTHORS=Brian Smith <brian@briansmith.org>
ENV CARGO_PKG_DESCRIPTION=Safe, fast, small crypto using Rust.
ENV CARGO_PKG_HOMEPAGE=
ENV CARGO_PKG_NAME=ring
ENV CARGO_PKG_REPOSITORY=https://github.com/briansmith/ring
ENV CARGO_PKG_VERSION=0.16.13
ENV CARGO_PKG_VERSION_MAJOR=0
ENV CARGO_PKG_VERSION_MINOR=16
ENV CARGO_PKG_VERSION_PATCH=13
ENV CARGO_PKG_VERSION_PRE=
ENV CC=cc
ENV DEBUG=true
ENV GOPATH=/home/linux1/go
ENV GOROOT=/home/linux1/go1.14.2
ENV HISTCONTROL=ignoredups
ENV HISTSIZE=1000
ENV HOME=/home/linux1
ENV HOST=s390x-unknown-linux-gnu
ENV HOSTNAME=linuxone
ENV LANG=zh_CN.UTF-8
ENV LD_LIBRARY_PATH=/home/linux1/ring/target/debug/deps:/home/linux1/.rustup/toolchains/stable-s390x-unknown-linux-gnu/lib:/home/linux1/.rustup/toolchains/stable-s390x-unknown-linux-gnu/lib
ENV LESSOPEN=||/usr/bin/lesspipe.sh %s
ENV LOGNAME=linux1
ENV LS_COLORS=rs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.Z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*.svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5;13:*.webm=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38;5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv=38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.axv=38;5;13:*.anx=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.mid=38;5;45:*.midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:
ENV MAIL=/var/spool/mail/linux1
ENV NUM_JOBS=2
ENV OLDPWD=/home/linux1
ENV OPT_LEVEL=0
ENV OUT_DIR=/home/linux1/ring/target/debug/build/ring-7a5c1eaa69484850/out
ENV PATH=/home/linux1/.cargo/bin:/home/linux1/.cargo/bin:/home/linux1/go1.14.2/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/linux1/go/bin:/home/linux1/.local/bin:/home/linux1/bin
ENV PROFILE=debug
ENV PWD=/home/linux1/ring
ENV RUSTC=rustc
ENV RUSTDOC=rustdoc
ENV RUSTUP_HOME=/home/linux1/.rustup
ENV RUSTUP_TOOLCHAIN=stable-s390x-unknown-linux-gnu
ENV RUST_BACKTRACE=1
ENV RUST_RECURSION_COUNT=1
ENV SHELL=/bin/bash
ENV SHLVL=1
ENV SSH_CLIENT=***.***.***.***
ENV SSH_CONNECTION=***.***.***.***
ENV SSH_TTY=/dev/pts/1
ENV SSL_CERT_DIR=/etc/pki/tls/certs
ENV SSL_CERT_FILE=/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
ENV TARGET=s390x-unknown-linux-gnu
ENV TERM=xterm-256color
ENV USER=linux1
ENV XDG_RUNTIME_DIR=/run/user/1001
ENV XDG_SESSION_ID=276
ENV _=/home/linux1/.cargo/bin/cargo
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', build.rs:364:34
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1063
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:204
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:224
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:470
  11: rust_begin_unwind
             at src/libstd/panicking.rs:378
  12: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
  13: core::panicking::panic
             at src/libcore/panicking.rs:52
  14: core::option::Option<T>::unwrap
             at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libcore/macros/mod.rs:10
  15: build_script_build::build_c_code
             at ./build.rs:364
  16: build_script_build::ring_build_rs_main
             at ./build.rs:296
  17: build_script_build::main
             at ./build.rs:253
  18: std::rt::lang_start::{{closure}}
             at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libstd/rt.rs:67
  19: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:52
  20: std::panicking::try::do_call
             at src/libstd/panicking.rs:303
  21: __rust_try
  22: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:86
  23: std::panicking::try
             at src/libstd/panicking.rs:281
  24: std::panic::catch_unwind
             at src/libstd/panic.rs:394
  25: std::rt::lang_start_internal
             at src/libstd/rt.rs:51
  26: std::rt::lang_start
             at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libstd/rt.rs:67
  27: main
  28: __libc_start_main
  29: <unknown>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@pietro
Copy link
Contributor

pietro commented May 13, 2020

Ring currently doesn't support s390x. I can't say if it will in the future as that's a decision for @briansmith to make. But you can look at the issue about other platforms like #562 and #389 for information on what would take to add support for new hardware.

@xieqiang2020
Copy link
Author

Ring currently doesn't support s390x. I can't say if it will in the future as that's a decision for @briansmith to make. But you can look at the issue about other platforms like #562 and #389 for information on what would take to add support for new hardware.

@pietro Thanks. I will have a try.

@sipples
Copy link

sipples commented May 29, 2020

@pietro: One common issue @briansmith frequently mentions in the other issue trackers is (Travis) CI support for the particular architecture(s). Fortunately Travis CI introduced support for s390x and ppc64le architectures about 6 months ago (in November, 2019). Details are available here:
https://blog.travis-ci.com/2019-11-12-multi-cpu-architecture-ibm-power-ibm-z
Would it be possible to get a CI readout and see what's still missing? (Brian mentioned that's the typical pathway.) Thanks.

@briansmith
Copy link
Owner

Issue #104 is fixed, so AES-GCM should be working on all platforms where we do not have assembly language AES-GCM in ring. it should work for little-endian s390x. With small changes, which I encourage somebody to do in a PR, it should also work for big-endian s390x. However, I know that Power has something very much line AES-NI, and of course we should add that to ring soon.

PR #996 implements (unoptimized) RSA support for WebAssembly, but also other platforms for which we do not have assembly language GFp_bn_mul_mont, including again s390x.

@sipples
Copy link

sipples commented May 30, 2020

The s390x architecture is always big endian, so that's simple. While Power processors are bi-endian (can operate in either big endian or little endian, and really do in practice), ppc64le (little endian) is that architecture's most popular mode for Linux nowadays and what Travis CI supports at the moment. Yes, these architectures have lots of hardware assists, although software fallback will still be important. For example, on s390x every main processor core has "CPACF" assists, and "Feature Code 3863" enables the full set of CPACF functions including AES128- and AES256-GCM (z14/LinuxONE II generation processors and higher -- and I think the Hitachi AP10000 has this, too). There's no extra charge for FC 3863 (so it's particularly popular), but unfortunately there are a couple countries that evidently block its importation. :-( So, software fallback it is. There are also quite popular Hardware Security Modules (HSMs) on that architecture ("Crypto Expess"), impressively FIPS 140-2 Level 4 certified, but with the same import restrictions.

Anyway, software fallback will be important, so that's the minimum viable starting point. Anything else you see outstanding for software fallback besides #104 big endian (which also affects MIPS and perhaps others)? And am I understanding correctly that #996 is OK now for s390x and ppc64le as far as you can tell? Thanks.

@briansmith
Copy link
Owner

ECC and ChaCha20-Poly1305 will be the next things.

@Demi-Marie
Copy link

Would it be possible to at least give a better error message?

@pietro
Copy link
Contributor

pietro commented Jul 8, 2020

The simplest way to improve the error message would be to change the unwrap() into expect() like:

diff --git a/build.rs b/build.rs
index d7c8466b2..d5812800d 100644
--- a/build.rs
+++ b/build.rs
@@ -375,7 +375,7 @@ fn build_c_code(target: &Target, pregenerated: PathBuf, out_dir: &Path) {
             let &(entry_arch, entry_os, _) = *entry;
             entry_arch == &target.arch && is_none_or_equals(entry_os, &target.os)
         })
-        .unwrap();
+        .expect("Target not supported"));

     let use_pregenerated = !target.is_git;
     let warnings_are_errors = target.is_git;

@mark-stopka
Copy link

I am having the same issue :(

@knarz
Copy link

knarz commented Jul 27, 2020

If you can, please give #1037 a try and see if that fixes your problems.

tasn added a commit to etesync/etebase-py that referenced this issue Sep 16, 2020
It's not supported by sccache at the moment, and thus supporting
building it on travis is a bit of a PITA.

The problem is with sccache's ring dep. Issue:
briansmith/ring#986
tasn added a commit to etesync/etebase-py that referenced this issue Sep 16, 2020
It's not supported by sccache at the moment, and thus supporting
building it on travis is a bit of a PITA.

The problem is with sccache's ring dep. Issue:
briansmith/ring#986
@e-desouza
Copy link

@knarz Seems like this is a workaround. Is ring any less functional on s390x if we implement that work around?

@briansmith
Copy link
Owner

RE that workaround, see PR #1174.

@briansmith
Copy link
Owner

Fixed in 0.17.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants