Bug 228082 - math/gmp does not compile on some ARM64 hosts
Summary: math/gmp does not compile on some ARM64 hosts
Status: Closed Not A Bug
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm64 Any
: --- Affects Many People
Assignee: Alex Dupre
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-08 21:07 UTC by Curtis Villamizar
Modified: 2018-05-11 21:29 UTC (History)
1 user (show)

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


Attachments
patch for math/gmp port rooted at /usr/ports. (692 bytes, patch)
2018-05-08 21:07 UTC, Curtis Villamizar
no flags Details | Diff
compile output on Orange Pi PC Plus (54.60 KB, text/plain)
2018-05-09 18:33 UTC, Curtis Villamizar
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Curtis Villamizar 2018-05-08 21:07:26 UTC
Created attachment 193189 [details]
patch for math/gmp port rooted at /usr/ports.

the math/gmp port does not compile on some arm64 hosts.  This includes Raspberry Pi 3 and Orange Pi based on AllWinner H3 but is likely to include many others.  Some assembly language code won't compile.

Since arm64 assembly code does work on some arm platform (presumably) its best to have the option to include that code if it works.  Others will have to not use the assembly code until it gets fixed for more arm64 platforms.

The workaround/fix is to patch Makefile creating OPTION named AVOID_ASM.  If AVOID_ASM option is set then CONFIGURE_ARGS+= --disable-assembly which simply avoids the problem at some cost in performance, which beats not compiling.
Comment 1 Mikael Urankar freebsd_committer freebsd_triage 2018-05-09 13:18:01 UTC
It builds fine for me on 12-current with clang6. Can you paste the build log?
Comment 2 Curtis Villamizar 2018-05-09 18:33:09 UTC
Created attachment 193218 [details]
compile output on Orange Pi PC Plus

Fails on Orange Pi PC Plus which uses a AllWinner H3 SOC.
It now compiles on RPi3.
Trace was for "uname -a ; echo ; make".
Comment 3 Mikael Urankar freebsd_committer freebsd_triage 2018-05-09 18:43:29 UTC
I'm confused, the problem is on aarch64 or armv7 ?
It seems a mix of armv6 and armv7 :
r12-20180429/src/arm.armv6/sys/GENERIC
checking build system type... armv7-portbld-freebsd12.0
Comment 4 Curtis Villamizar 2018-05-09 19:34:47 UTC
I had previously had a problem with both platforms, RPi3 and OPi.  Since you mentioned "it worked for me" I recompiled on both and found that now RPi3 works but OPi still won't compile with latest code on same base and port revision.

The rpi3 is aarch64.

On the OPi it seems the kernel build is armv6 but ports is detecting armv7.  In the crochet file I have "TARGET_ARCH=armv6".  If you think that will help I'll change that to armv7 and recompile the kernel and try the ports again.  If so, then all of the crochet Orange Pi board setup files are wrong (so far they are all H3, I think).

If changing to "TARGET_ARCH=armv7" in the crochet setup file might help, let me know and it might be a while before I have that done (takes a while to compile).
Comment 5 Mikael Urankar freebsd_committer freebsd_triage 2018-05-10 09:19:20 UTC
It also builds fine on armv6 and armv7, do you have anything in make.conf? What's your compiler?
Comment 6 Curtis Villamizar 2018-05-10 16:02:56 UTC
# cat /etc/make.conf
cat: /etc/make.conf: No such file or directory
# cc -v
FreeBSD clang version 6.0.0 (tags/RELEASE_600/final 326565) (based on LLVM 6.0.0)
Target: armv6-unknown-freebsd12.0-gnueabihf
Comment 7 Mikael Urankar freebsd_committer freebsd_triage 2018-05-11 11:31:50 UTC
Ok I'm able to reproduce this issue when my system reports itself as armv7 (hw.machine_arch) but my compiler produces armv6 binary (Target: armv6-unknown-freebsd12.0-gnueabihf), which is not a supported configuration.
You can workaround the problem with : env ARCH=armv6 make
or : recompile your world/kernel for armv7
or : look at what changed in base r324341 and build an armv6 kernel
Comment 8 Curtis Villamizar 2018-05-11 21:27:58 UTC
The problem is that the system was built with crochet and that the crochet board file for the AllWinner H3 boards contains TARGET_ARCH=armv6.  I changed that to TARGET_ARCH=armv7 and all is fine.

Sorry to take a while to get back to you but it took a while for me to get a new micro SD image and then build math/gmp on it plus the ports it depends on.

I'll close this, though exposing the --without-assembly in a option in the port might still not be a bad idea.
Comment 9 Curtis Villamizar 2018-05-11 21:28:27 UTC
I'll also make a pull request on the crochet project.