Bug 225600 - lang/rust fails with error: the clang compiler does not support '-march=native'
Summary: lang/rust fails with error: the clang compiler does not support '-march=native'
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm64 Any
: --- Affects Some People
Assignee: FreeBSD Rust Team
URL: http://thunderx1.nyi.freebsd.org/data...
Keywords:
Depends on:
Blocks: 201763
  Show dependency treegraph
 
Reported: 2018-02-01 05:13 UTC by gergely.czuczy
Modified: 2018-02-22 22:06 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (rust)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gergely.czuczy 2018-02-01 05:13:42 UTC
Hello,

I'm trying to build rust (dep for firefox) on -CURRENT/aarch64, and it fails with the following error:

[  6%] Building CXX object src/wasm/CMakeFiles/wasm.dir/wasm-binary.cpp.o
gmake[7]: Leaving directory '/usr/ports/lang/rust/work/rustc-1.23.0-src/build/aarch64-unknown-freebsd/stage0-rustc/aarch64-unknown
-freebsd/release/build/rustc_binaryen-cfb76adb9420e94c/out/build'
gmake[6]: Leaving directory '/usr/ports/lang/rust/work/rustc-1.23.0-src/build/aarch64-unknown-freebsd/stage0-rustc/aarch64-unknown
-freebsd/release/build/rustc_binaryen-cfb76adb9420e94c/out/build'
gmake[5]: Leaving directory '/usr/ports/lang/rust/work/rustc-1.23.0-src/build/aarch64-unknown-freebsd/stage0-rustc/aarch64-unknown
-freebsd/release/build/rustc_binaryen-cfb76adb9420e94c/out/build'
gmake[4]: Leaving directory '/usr/ports/lang/rust/work/rustc-1.23.0-src/build/aarch64-unknown-freebsd/stage0-rustc/aarch64-unknown
-freebsd/release/build/rustc_binaryen-cfb76adb9420e94c/out/build'

--- stderr
c++: error: the clang compiler does not support '-march=native'
c++: error: the clang compiler does not support '-march=native'
gmake[7]: *** [src/asmjs/CMakeFiles/asmjs.dir/build.make:63: src/asmjs/CMakeFiles/asmjs.dir/asm_v_wasm.cpp.o] Error 1
gmake[7]: *** [src/ir/CMakeFiles/ir.dir/build.make:63: src/ir/CMakeFiles/ir.dir/ExpressionAnalyzer.cpp.o] Error 1
gmake[6]: *** [CMakeFiles/Makefile2:610: src/asmjs/CMakeFiles/asmjs.dir/all] Error 2
gmake[6]: *** Waiting for unfinished jobs....
gmake[6]: *** [CMakeFiles/Makefile2:555: src/ir/CMakeFiles/ir.dir/all] Error 2
c++: error: the clang compiler does not support '-march=native'
gmake[7]: *** [src/wasm/CMakeFiles/wasm.dir/build.make:63: src/wasm/CMakeFiles/wasm.dir/literal.cpp.o] Error 1
gmake[7]: *** Waiting for unfinished jobs....
c++: error: the clang compiler does not support '-march=native'
c++: error: the clang compiler does not support '-march=native'
gmake[7]: *** [src/wasm/CMakeFiles/wasm.dir/build.make:87: src/wasm/CMakeFiles/wasm.dir/wasm.cpp.o] Error 1
gmake[7]: *** [src/wasm/CMakeFiles/wasm.dir/build.make:111: src/wasm/CMakeFiles/wasm.dir/wasm-binary.cpp.o] Error 1
gmake[6]: *** [CMakeFiles/Makefile2:885: src/wasm/CMakeFiles/wasm.dir/all] Error 2
gmake[5]: *** [CMakeFiles/Makefile2:171: CMakeFiles/binaryen.dir/rule] Error 2
gmake[4]: *** [Makefile:190: binaryen] Error 2
thread 'main' panicked at '
command did not execute successfully, got: exit code: 2

build script failed, must exit now', src/vendor/cmake/src/lib.rs:631:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.

warning: build failed, waiting for other jobs to finish...
error: build failed
thread 'main' panicked at 'command did not execute successfully: "/usr/ports/lang/rust/work/rustc-1.23.0-src/build/aarch64-unknown-freebsd/stage0/bin/cargo" "build" "--target" "aarch64-unknown-freebsd" "--release" "--frozen" "--features" " jemalloc llvm" "--manifest-path" "/usr/ports/lang/rust/work/rustc-1.23.0-src/src/rustc/Cargo.toml" "--message-format" "json"
expected success, got: exit code: 101', src/bootstrap/compile.rs:882:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.

# uname -a
FreeBSD build-pine64.bealak.harmless.hu 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r328533M: Mon Jan 29 15:43:25 CET 2018     toor@marvin.harmless.hu:/tank/rpi3/crochet/work.pine64vanilla/obj/tank/rpi3/src/arm64.aarch64/sys/GENERIC-NODEBUG  arm64


It's after the clang-6.0.0 import.

Could you please fix this?

Best regards,
Gergely
Comment 1 Jean-Sébastien Pédron freebsd_committer freebsd_triage 2018-02-01 08:25:15 UTC
Hi!

Could you please attach the content of /etc/make.conf and provide any other local settings you may have?
Comment 2 gergely.czuczy 2018-02-01 10:19:06 UTC
My make.conf:
# cat /etc/make.conf
DEFAULT_VERSIONS+= python=3.6
OPTIONS_UNSET= TEST NLS DOCS EXAMPLES

and the options for the port:
# cat /var/db/ports/lang_rust/options
# This file is auto-generated by 'make config'.
# Options for rust-1.23.0
_OPTIONS_READ=rust-1.23.0
_FILE_COMPLETE_OPTIONS_LIST=DOCS GDB LLNEXTGEN SOURCES
OPTIONS_FILE_UNSET+=DOCS
OPTIONS_FILE_UNSET+=GDB
OPTIONS_FILE_UNSET+=LLNEXTGEN
OPTIONS_FILE_UNSET+=SOURCES


Nothing else comes to my mind. Let me know if you need anything else for reproduction.
Comment 3 Jan Beich freebsd_committer freebsd_triage 2018-02-01 22:43:09 UTC
FreeBSD supports -march=native only on i386 and amd64
https://lists.freebsd.org/pipermail/freebsd-toolchain/2018-January/003560.html
https://lists.freebsd.org/pipermail/freebsd-arm/2016-February/013190.html

but since Rust 1.23 we have

$ fgrep -B2 -r march=native .
./src/binaryen/CMakeLists.txt-    elseif(TARGET_ARCH STREQUAL "ARM")
./src/binaryen/CMakeLists.txt-      # stub for ARM-specific instructions. GCC6 adds NEON with the below flags
./src/binaryen/CMakeLists.txt:      ADD_COMPILE_FLAG("-march=native")

https://github.com/rust-lang/rust/commit/80ff0f74b0c4
https://github.com/alexcrichton/binaryen/commit/a0b162d13c7e
https://github.com/WebAssembly/binaryen/issues/965

If the intent is to enable NEON then
- aarch64 doesn't need anything, NEON is standard; GCC would barf on -mfpu=neon, anyway
- armv6 needs -march=armv7-a -mfpu=neon
- armv7 has NEON enabled by default; can use armv6 flags but vendor -march= may pessimize custom -march= set via CPUTYPE in /etc/make.conf
Comment 4 Jan Beich freebsd_committer freebsd_triage 2018-02-02 09:23:42 UTC
(In reply to Jan Beich from comment #3)
> - armv7 has NEON enabled by default

Only Clang. GCC still needs -mfpu=neon.

$ cc -v
FreeBSD clang version 6.0.0 (branches/release_60 323948) (based on LLVM 6.0.0)
Target: armv7-unknown-freebsd12.0-gnueabihf
Thread model: posix
InstalledDir: /usr/bin

$ cc -dM -E -</dev/null | fgrep NEON
#define __ARM_NEON 1
#define __ARM_NEON_FP 0x4
#define __ARM_NEON__ 1
$ clang40 -dM -E -</dev/null | fgrep NEON
#define __ARM_NEON 1
#define __ARM_NEON_FP 0x4
#define __ARM_NEON__ 1

$ gcc6 -dM -E -</dev/null | fgrep NEON
$ gcc7 -dM -E -</dev/null | fgrep NEON
$ gcc7 -mfpu=neon -dM -E -</dev/null | fgrep NEON
#define __ARM_NEON_FP 4
#define __ARM_NEON__ 1
#define __ARM_NEON 1
Comment 5 Jan Beich freebsd_committer freebsd_triage 2018-02-02 22:19:30 UTC
pkg-fallout@ haven't reported this bustage yet because thunderx1 hit a kernel panic again. ;\
Comment 6 gergely.czuczy 2018-02-21 12:41:47 UTC
In case you weren't ware of it, I was told by the #bsdmips guys, that there are aarch64 testing machines for such purposes, they've showed me the following links:

https://wiki.freebsd.org/TestClusterOneReservations
https://www.freebsd.org/internal/machines.html

I hope this helps.
Comment 7 gergely.czuczy 2018-02-21 20:37:51 UTC
https://github.com/WebAssembly/binaryen/pull/1192#issuecomment-367461975 has been merged.

@rust guys, would it be possible to patch the port while the fix appears in a release?

Another thing is, when I've manually fixed it locally similarly, there was another build failure, you guys will encounter. Could you please verify the build to succeed on aarch64?
Comment 8 gergely.czuczy 2018-02-21 20:46:08 UTC
Regarding my previous comment, I forgot I manually fixed the native bug locally, and the other error's PR is 225643.
Comment 9 commit-hook freebsd_committer freebsd_triage 2018-02-22 22:05:48 UTC
A commit references this bug:

Author: jbeich
Date: Thu Feb 22 22:05:21 UTC 2018
New revision: 462646
URL: https://svnweb.freebsd.org/changeset/ports/462646

Log:
  lang/rust: unbreak on aarch64 after r459911

  gmake: Leaving directory '.../aarch64-unknown-freebsd/release/build/rustc_binaryen-cfb76adb9420e94c/out/build'
  --- stderr
  c++: error: the clang compiler does not support '-march=native'
  c++: error: the clang compiler does not support '-march=native'

  PR:		225600
  Reported by:	Gergely Czuczy, pkg-fallout
  Obtained from:	upstream (binaryen 1.37.35)
  Approved by:	portmgr blanket

Changes:
  head/lang/rust/files/patch-src_binaryen_CMakeLists.txt