Bug 217271 - security/libgcrypt: Fails to compile for arm64 without NEON instruction set
Summary: security/libgcrypt: Fails to compile for arm64 without NEON instruction set
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm64 Any
: --- Affects Many People
Assignee: Carlos J. Puga Medina
URL: https://bugs.gnupg.org/gnupg/issue2970
Keywords: patch, patch-ready
Depends on:
Blocks:
 
Reported: 2017-02-21 12:43 UTC by Simon Rozman
Modified: 2017-02-28 12:30 UTC (History)
1 user (show)

See Also:
cpm: maintainer-feedback+
cpm: merge-quarterly+


Attachments
Output of `make build` command (259.19 KB, text/plain)
2017-02-21 12:43 UTC, Simon Rozman
no flags Details
libgcrypt patch (5.13 KB, patch)
2017-02-26 18:27 UTC, Kirill Ponomarev
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Rozman 2017-02-21 12:43:42 UTC
Created attachment 180185 [details]
Output of `make build` command

Although the `configure` seems to determine the NEON instruction set is not supported, `make build` compiles assembly files with NEON instructions - resulting in a failure to compile.

`security/libgcrypt` port provides no option to disable assembly.
Comment 1 Carlos J. Puga Medina freebsd_committer 2017-02-21 13:15:36 UTC
(In reply to Simon Rozman from comment #0)

As a workaround, configure libgcrypt with --disable-neon-support

Thanks for reporting
Comment 2 Simon Rozman 2017-02-21 13:42:36 UTC
(In reply to Carlos J. Puga Medina from comment #1)

Same result:
cipher-gcm-armv8-aarch64-ce.S:401:35: error: instruction requires: neon

The port is configured using:
root@rpi3:/usr/ports/security/libgcrypt/work/libgcrypt-1.7.6 # ./config.status --config
'--disable-drng-support' '--disable-neon-support' '--enable-static=yes' '--prefix=/usr/local' '--localstatedir=/var' '--mandir=/usr/local/man' '--disable-silent-rules' '--infodir=/usr/local/info/' '--build=aarch64-portbld-freebsd12.0' 'build_alias=aarch64-portbld-freebsd12.0' 'CC=cc' 'CFLAGS=-O2 -pipe  -fno-strict-aliasing -std=gnu89' 'LDFLAGS=' 'LIBS=' 'CPPFLAGS=' 'CPP=cpp'

Perhaps the libgcrypt-1.7.6 itself has an issue.
Comment 3 Carlos J. Puga Medina freebsd_committer 2017-02-21 14:48:05 UTC
(In reply to Simon Rozman from comment #2)

Second attempt:

Try to disable NEON and ARMv8 crypto support.

--disable-neon-support --disable-arm-crypto-support
Comment 4 Simon Rozman 2017-02-21 21:07:54 UTC
(In reply to Carlos J. Puga Medina from comment #3)

The same. No matter how I play with `configure` parameters, `make` can not avoid compiling the notorious `cipher-gcm-armv8-aarch64-ce.S` file.
Comment 5 Simon Rozman 2017-02-21 21:09:38 UTC
root@rpi3:/usr/ports/security/libgcrypt/work/libgcrypt-1.7.6/cipher # cc --version
FreeBSD clang version 3.9.1 (tags/RELEASE_391/final 289601) (based on LLVM 3.9.1)
Target: aarch64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin
Comment 6 Carlos J. Puga Medina freebsd_committer 2017-02-22 00:12:36 UTC
(In reply to Simon Rozman from comment #5)

Indeed, the NEON instructions cannot be compiled with clang.

checking whether GCC inline assembler supports NEON instructions... n/a
checking whether GCC inline assembler supports AArch32 Crypto Extension instructions... n/a
checking whether GCC inline assembler supports AArch64 NEON instructions... no
checking whether GCC inline assembler supports AArch64 Crypto Extension instructions... yes

It's complaining that it doesn't support ARM NEON

Try using ARM NEON:        no (unsupported by compiler)
Comment 7 Kirill Ponomarev freebsd_committer 2017-02-26 18:27:58 UTC
Created attachment 180321 [details]
libgcrypt patch

This patch fixes the build, please commit
Comment 8 Carlos J. Puga Medina freebsd_committer 2017-02-28 12:03:22 UTC
(In reply to Kirill Ponomarew from comment #7)

It works! Thanks Kirill
Comment 9 commit-hook freebsd_committer 2017-02-28 12:21:40 UTC
A commit references this bug:

Author: cpm
Date: Tue Feb 28 12:21:14 UTC 2017
New revision: 435049
URL: https://svnweb.freebsd.org/changeset/ports/435049

Log:
  security/libgcrypt: fix build on aarch64

  libtool: compile:  cc -DHAVE_CONFIG_H -I. -I.. -I../src -I../src -Wa,--noexecstack -O2 -pipe -fno-strict-aliasing -std=gnu89 -MT cipher-gcm-armv8-aarch64-ce.lo -MD -MP -MF .deps/cipher-gcm-armv8-aarch64-ce.Tpo -c cipher-gcm-armv8-aarch64-ce.S  -fPIC -DPIC -o .libs/cipher-gcm-armv8-aarch64-ce.o
  cipher-gcm-armv8-aarch64-ce.S:190:3: error: instruction requires: neon
  eor v31.16b, v31.16b, v31.16b
    ^

  PR:		217271
  Submitted by:	krion
  Reported by:	Simon Rozman <simon@rozman.si>
  MFH:		2017Q1 (blanket)

Changes:
  head/security/libgcrypt/Makefile
  head/security/libgcrypt/files/
  head/security/libgcrypt/files/extra-patch-aarch64
Comment 10 commit-hook freebsd_committer 2017-02-28 12:28:48 UTC
A commit references this bug:

Author: cpm
Date: Tue Feb 28 12:28:24 UTC 2017
New revision: 435050
URL: https://svnweb.freebsd.org/changeset/ports/435050

Log:
  MFH: r435049

  security/libgcrypt: fix build on aarch64

  libtool: compile:  cc -DHAVE_CONFIG_H -I. -I.. -I../src -I../src -Wa,--noexecstack -O2 -pipe -fno-strict-aliasing -std=gnu89 -MT cipher-gcm-armv8-aarch64-ce.lo -MD -MP -MF .deps/cipher-gcm-armv8-aarch64-ce.Tpo -c cipher-gcm-armv8-aarch64-ce.S  -fPIC -DPIC -o .libs/cipher-gcm-armv8-aarch64-ce.o
  cipher-gcm-armv8-aarch64-ce.S:190:3: error: instruction requires: neon
  eor v31.16b, v31.16b, v31.16b
    ^

  PR:		217271
  Submitted by:	krion
  Reported by:	Simon Rozman <simon@rozman.si>

  Approved by:	ports-secteam (blanket)

Changes:
_U  branches/2017Q1/
  branches/2017Q1/security/libgcrypt/Makefile
  branches/2017Q1/security/libgcrypt/files/
Comment 11 Carlos J. Puga Medina freebsd_committer 2017-02-28 12:30:06 UTC
Committed!

Thanks