Closed Hentioe closed 5 years ago
TARGET = Some("x86_64-unknown-linux-gnu")
arm-openwrt-linux-gcc: error: unrecognized command line option '-m64'
You need to use cargo --target
to tell the Rust toolchain what target you are targetting.
@Hentioe Did using cargo --target
solve your problem? Should this be closed?
This is my .cargo/config:
[target.arm-unknown-linux-musleabihf]
linker = "arm-openwrt-linux-gcc"
Full command:
CC=arm-openwrt-linux-gcc \
cargo build --target=arm-unknown-linux-musleabihf --release
Cross-compilation, of course I know that I need to use the target
parameter. But even so, I still can't compile the ring library. The error is the above error :(
@Hentioe I've been doing a lot of cross compilation of ring so I can try to help you. Can you put in a gist the outputs of:
cat .cargo/config
which arm-openwrt-linux-gcc
CC=arm-openwrt-linux-gcc cargo build -vv --target=arm-unknown-linux-musleabihf --release
@Hentioe Are you trying to cross-compile something that uses ring (indirectly) in its build.rs
build script?
Please post the entire build log as an attachment.
@briansmith
I am just trying to compile a getting started project of the Rocket framework. The following is the complete compilation output:
Compiling cc v1.0.28
Compiling unicode-normalization v0.1.7
Compiling percent-encoding v1.0.1
Compiling libc v0.2.43
Compiling byteorder v1.2.7
Compiling untrusted v0.6.2
Compiling serde v1.0.80
Compiling lazy_static v1.2.0
Compiling void v1.0.2
Compiling safemem v0.3.0
Compiling yansi v0.5.0
Compiling language-tags v0.2.2
Compiling typeable v0.1.2
Compiling traitobject v0.1.0
Compiling indexmap v1.0.2
Compiling state v0.4.1
Compiling unicode-xid v0.1.0
Compiling proc-macro2 v0.4.26
Compiling unicode-bidi v0.3.4
Compiling unicase v1.4.2
Compiling memchr v2.1.1
Compiling pear_codegen v0.1.2
Compiling log v0.4.6
Compiling httparse v1.3.3
Compiling unreachable v1.0.0
Compiling base64 v0.9.3
Compiling num_cpus v1.8.0
Compiling time v0.1.40
Compiling isatty v0.1.9
Compiling rocket_codegen v0.4.0
Compiling rocket v0.4.0
Compiling base64 v0.10.1
Compiling ring v0.13.5
Compiling log v0.3.9
Compiling smallvec v0.6.5
Compiling idna v0.1.5
Compiling mime v0.2.6
Compiling quote v0.6.11
error: failed to run custom build command for `ring v0.13.5`
process didn't exit successfully: `/storage/code/rocket-gs/target/release/build/ring-66b8b21f5b59f3a0/build-script-build` (exit code: 101)
--- stdout
ASDF_DIR: /home/hentioe/.asdf
AUTOJUMP_ERROR_PATH: /home/hentioe/.local/share/autojump/errors.log
AUTOJUMP_SOURCED: 1
CARGO: /home/hentioe/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo
CARGO_CFG_DEBUG_ASSERTIONS:
CARGO_CFG_PROC_MACRO:
CARGO_CFG_TARGET_ARCH: x86_64
CARGO_CFG_TARGET_ENDIAN: little
CARGO_CFG_TARGET_ENV: gnu
CARGO_CFG_TARGET_FAMILY: unix
CARGO_CFG_TARGET_FEATURE: fxsr,mmx,sse,sse2
CARGO_CFG_TARGET_HAS_ATOMIC: 16,32,64,8,cas,ptr
CARGO_CFG_TARGET_OS: linux
CARGO_CFG_TARGET_POINTER_WIDTH: 64
CARGO_CFG_TARGET_THREAD_LOCAL:
CARGO_CFG_TARGET_VENDOR: unknown
CARGO_CFG_UNIX:
CARGO_FEATURE_DEFAULT: 1
CARGO_FEATURE_DEV_URANDOM_FALLBACK: 1
CARGO_FEATURE_USE_HEAP: 1
CARGO_HOME: /home/hentioe/.cargo
CARGO_MAKEFLAGS: --jobserver-fds=3,32 -j --jobserver-auth=3,32 -j
CARGO_MANIFEST_DIR: /home/hentioe/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.13.5
CARGO_MANIFEST_LINKS: ring-asm
CARGO_PKG_AUTHORS: Brian Smith <brian@briansmith.org>
CARGO_PKG_DESCRIPTION: Safe, fast, small crypto using Rust.
CARGO_PKG_HOMEPAGE:
CARGO_PKG_NAME: ring
CARGO_PKG_REPOSITORY: https://github.com/briansmith/ring
CARGO_PKG_VERSION: 0.13.5
CARGO_PKG_VERSION_MAJOR: 0
CARGO_PKG_VERSION_MINOR: 13
CARGO_PKG_VERSION_PATCH: 5
CARGO_PKG_VERSION_PRE:
CC: arm-openwrt-linux-gcc
CHROME_DESKTOP: code-url-handler.desktop
DBUS_SESSION_BUS_ADDRESS: unix:path=/run/user/1000/bus
DEBUG: false
DESKTOP_SESSION: gnome
DESKTOP_STARTUP_ID: gnome-shell-1462-CL-MANJARO-/opt/visual-studio-code/code-27_TIME17973454
DISPLAY: :1
EDITOR: /usr/bin/nano
GDMSESSION: gnome
GDM_LANG: zh_CN.UTF-8
GIO_LAUNCHED_DESKTOP_FILE: /usr/share/applications/visual-studio-code.desktop
GIO_LAUNCHED_DESKTOP_FILE_PID: 13455
GJS_DEBUG_OUTPUT: stderr
GJS_DEBUG_TOPICS: JS ERROR;JS LOG
GTK_IM_MODULE: fcitx
HOME: /home/hentioe
HOST: x86_64-unknown-linux-gnu
LANG: en_US.UTF-8
LANGUAGE: zh_CN:en_US:en
LC_ADDRESS: zh_CN.UTF-8
LC_ALL: C.UTF-8
LC_CTYPE: zh_CN.UTF-8
LC_IDENTIFICATION: zh_CN.UTF-8
LC_MEASUREMENT: zh_CN.UTF-8
LC_MONETARY: zh_CN.UTF-8
LC_NAME: zh_CN.UTF-8
LC_NUMERIC: zh_CN.UTF-8
LC_PAPER: zh_CN.UTF-8
LC_TELEPHONE: zh_CN.UTF-8
LC_TIME: zh_CN.UTF-8
LD_LIBRARY_PATH: /storage/code/rocket-gs/target/release/deps:/home/hentioe/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib:/home/hentioe/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib
LESS: -R
LOGNAME: hentioe
LSCOLORS: Gxfxcxdxbxegedabagacad
LS_COLORS: rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
MAIL: /var/spool/mail/hentioe
MAVEN_OPTS: -Xmx512m
MOZ_PLUGIN_PATH: /usr/lib/mozilla/plugins
NUM_JOBS: 8
OLDPWD: /storage/code/rocket-gs
OPENWRT_SDK_HOME: /fast/development/toolchains/openwrt-sdk-18.06.1-ipq40xx_gcc-7.3.0_musl_eabi.Linux-x86_64
OPT_LEVEL: 3
OUT_DIR: /storage/code/rocket-gs/target/release/build/ring-80d619feb9ceb73f/out
PAGER: less
PAPERSIZE: a4
PATH: /home/hentioe/.cargo/bin:/home/hentioe/.deno/bin:/home/hentioe/.asdf/shims:/home/hentioe/.asdf/shims:/home/hentioe/.asdf/bin:/home/hentioe/.deno/bin:/home/hentioe/.cargo/bin:/home/hentioe/bin:/home/hentioe/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin:/fast/development/android-sdk/platform-tools:/fast/development/toolchains/openwrt-sdk-18.06.1-ipq40xx_gcc-7.3.0_musl_eabi.Linux-x86_64/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/fast/development/android-sdk/platform-tools:/fast/development/toolchains/openwrt-sdk-18.06.1-ipq40xx_gcc-7.3.0_musl_eabi.Linux-x86_64/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/bin:/fast/development/toolchains/openwrt-sdk-18.06.1-ipq40xx_gcc-7.3.0_musl_eabi.Linux-x86_64/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.3.0_musl_eabi/bin
PROFILE: release
PWD: /storage/code/rocket-gs
QT_IM_MODULE: fcitx
QT_QPA_PLATFORMTHEME: qt5ct
RUSTC: rustc
RUSTDOC: rustdoc
RUSTUP_HOME: /home/hentioe/.rustup
RUSTUP_TOOLCHAIN: nightly-x86_64-unknown-linux-gnu
RUST_RECURSION_COUNT: 1
SESSION_MANAGER: local/CL-MANJARO:@/tmp/.ICE-unix/1414,unix/CL-MANJARO:/tmp/.ICE-unix/1414
SHELL: /usr/bin/zsh
SHLVL: 4
SSH_AUTH_SOCK: /run/user/1000/keyring/ssh
SSL_CERT_DIR: /etc/ssl/certs
SSL_CERT_FILE: /etc/ssl/cert.pem
STAGING_DIR: /fast/development/toolchains/openwrt-sdk-18.06.1-ipq40xx_gcc-7.3.0_musl_eabi.Linux-x86_64/staging_dir
TARGET: x86_64-unknown-linux-gnu
TERM: xterm-256color
TERM_PROGRAM: vscode
TERM_PROGRAM_VERSION: 1.30.2
USER: hentioe
USERNAME: hentioe
WINDOWPATH: 2
XAUTHORITY: /run/user/1000/gdm/Xauthority
XDG_CURRENT_DESKTOP: GNOME
XDG_DATA_DIRS: /home/hentioe/.local/share/flatpak/exports/share/:/var/lib/flatpak/exports/share/:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
XDG_MENU_PREFIX: gnome-
XDG_RUNTIME_DIR: /run/user/1000
XDG_SEAT: seat0
XDG_SESSION_DESKTOP: gnome
XDG_SESSION_ID: 2
XDG_SESSION_TYPE: x11
XDG_VTNR: 2
XMODIFIERS: @im=fcitx
ZSH: /home/hentioe/.oh-my-zsh
_: /home/hentioe/.cargo/bin/cargo
OPT_LEVEL = Some("3")
TARGET = Some("x86_64-unknown-linux-gnu")
HOST = Some("x86_64-unknown-linux-gnu")
CC_x86_64-unknown-linux-gnu = None
CC_x86_64_unknown_linux_gnu = None
HOST_CC = None
CC = Some("arm-openwrt-linux-gcc")
CFLAGS_x86_64-unknown-linux-gnu = None
CFLAGS_x86_64_unknown_linux_gnu = None
HOST_CFLAGS = None
CFLAGS = None
DEBUG = Some("false")
running "arm-openwrt-linux-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2""-Winline" "-Winvalid-pch" "-Wmissing-declarations" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-Wno-cast-align" "-fstack-protector" "-g3" "-DNDEBUG" "-D_XOPEN_SOURCE=700" "-c" "-o/storage/code/rocket-gs/target/release/build/ring-80d619feb9ceb73f/out/aes-x86_64-elf.o" "/home/hentioe/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.13.5/pregenerated/aes-x86_64-elf.S"
--- stderr
bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
arm-openwrt-linux-gcc: error: unrecognized command line option '-m64'
thread 'main' panicked at 'execution failed', /home/hentioe/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.13.5/build.rs:645:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
warning: build failed, waiting for other jobs to finish...
^C Building [=========================================> ] 84/110: serde, idna, idna
It tells me that the ring-0.13.5
compilation failed.
@pietro
.cargo/config:
[target.arm-unknown-linux-musleabihf]
linker = "arm-openwrt-linux-gcc"
arm-openwrt-linux-gcc
is the official SDK for the ipq40xx
architecture from OpenWrt(18.06.0).
(download address)
I successfully compiled many Rust projects onto OpenWrt, but now I suspect it is blocked by the ring
.
Are you using CC
to set the compiler or TARGET_CC
? Try using TARGET_CC
.
Also, if that doesn't work, please try git clone https://github.com/briansmith/webpki && cd webpki && cargo test
using the same configuration (setting CC
or TARGET_CC
as you do in your own project) and see if it reproduces.
Here is my guess: One of your dependencies has a build dependency on ring (in its build.rs). Thus, ring has to be compiled twice, once for the host and once for the target. You can see that the build that is failing is for TARGET = Some("x86_64-unknown-linux-gnu")
and HOST = Some("x86_64-unknown-linux-gnu")
.
I suspect the solution is to unset CC
and set TARGET_CC
instead.
See https://github.com/briansmith/ring/issues/578#issuecomment-354508786; it seems like TARGET_CC
is probably the solution since the symptoms match exactly.
@briansmith Thank you for pointing out the reason! Recently it was the Chinese New Year, I didn't have a lot of time to test this problem, give me a few days to test, then I will close it.
Output:
arm-openwrt-linux-gcc
does not have the-m64
parameter, how should it be removed?