Bug 253698 - security/libgcrypt - compilation error when building jitterentropy-base.c for arm on poudriere
Summary: security/libgcrypt - compilation error when building jitterentropy-base.c for...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm Any
: --- Affects Many People
Assignee: Cy Schubert
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-19 17:12 UTC by Yani Karydis
Modified: 2021-03-27 02:57 UTC (History)
3 users (show)

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


Attachments
Poudriere log (146.76 KB, text/plain)
2021-02-19 20:11 UTC, Yani Karydis
no flags Details
poudriere build log (159.91 KB, text/plain)
2021-03-17 02:19 UTC, Daniel Morante
no flags Details
Try this patch. (567 bytes, patch)
2021-03-17 03:49 UTC, Cy Schubert
no flags Details | Diff
Disable the jitter entropy generator on armv6 (446 bytes, patch)
2021-03-17 14:44 UTC, Yani Karydis
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yani Karydis 2021-02-19 17:12:25 UTC
Hello,

I'm receiving the following error when compiling for arm using poudriere. Adding "--disable-jent-support" in the configure options fixes the problem, but I'm not sure what the security implications are. 

libtool: compile:  cc -DHAVE_CONFIG_H -I. -I.. -I../src -I../src -I/usr/local/include -O -pipe -fstack-protector-strong -fno-strict-aliasing -std=gnu89 -fvisibility=hidden -fno-delete-null-pointer-checks -Wall -c ./rndjent.c  -fPIC -DPIC -o .libs/rndjent.o
In file included from ./rndjent.c:86:
./jitterentropy-base.c:53:13: warning: unknown pragma ignored [-Wunknown-pragmas]
#pragma GCC optimize ("O0")
            ^
./jitterentropy-base.c:60:4: error: "The CPU Jitter random number generator must not be compiled with optimizations. See documentation. Use the compiler switch -O0 for compiling jitterentropy-base.c."
  #error "The CPU Jitter random number generator must not be compiled with optimizations. See documentation. Use the compiler switch -O0 for compiling jitterentropy-base.c."
   ^
1 warning and 1 error generated.
*** Error code 1

Stop.
make[3]: stopped in /wrkdirs/usr/ports/security/libgcrypt/work/libgcrypt-1.9.2/random
*** Error code 1
*** Error code 1
*** Error code 1

Stop.
make: stopped in /usr/ports/security/libgcrypt
Comment 1 Cy Schubert freebsd_committer freebsd_triage 2021-02-19 17:51:43 UTC
Can you provide uname -a output please.

Also provide output from cc -v or gcc -v if appropriate, please.

Is your gcc in base or in $LOCALBASE?
Comment 2 Yani Karydis 2021-02-19 20:11:13 UTC
Created attachment 222649 [details]
Poudriere log

I'm attaching the full error log from poudriere, which I think contains the required information. The host environment is running amd64 (12.2-RELEASE-p3 FreeBSD 12.2-RELEASE-p3 r369178), whereas the build environment is armv6 (12.2-RELEASE-p3 FreeBSD 12.2-RELEASE-p3 1202000 arm) using qemu. Both are using the base compiler (clang version 10.0.1).
Comment 3 Daniel Morante 2021-03-17 02:19:16 UTC
Created attachment 223350 [details]
poudriere build log

Also attaching my build log if it helps.
Comment 4 Cy Schubert freebsd_committer freebsd_triage 2021-03-17 02:37:29 UTC
Can you provide uname -a output please.

Also provide output from cc -v or gcc -v if appropriate, please.

Is your gcc in base or in $LOCALBASE?

Without this information I will be forced to close this ticket.
Comment 5 Cy Schubert freebsd_committer freebsd_triage 2021-03-17 03:49:50 UTC
Created attachment 223351 [details]
Try this patch.

Try this patch.
Comment 6 Yani Karydis 2021-03-17 12:19:49 UTC
The patch doesn't work. What does work is adding "--disable-jent-support" to the configure options in the Makefile.

uname -a
FreeBSD microserver.pi-greece.eu 12.2-RELEASE-p4 FreeBSD 12.2-RELEASE-p4 r369363 MICROSERVER12  arm

cc -v
FreeBSD clang version 10.0.1 (git@github.com:llvm/llvm-project.git llvmorg-10.0.1-0-gef32c611aa2)
Target: armv6-unknown-freebsd12.2-gnueabihf
Thread model: posix
InstalledDir: /usr/bin

No gcc
Comment 7 Yani Karydis 2021-03-17 14:44:52 UTC
Created attachment 223362 [details]
Disable the jitter entropy generator on armv6

Here's a Makefile patch that fixes the compilation problem on armv6.
Comment 8 Cy Schubert freebsd_committer freebsd_triage 2021-03-17 14:51:54 UTC
(In reply to Yani Karydis from comment #7)
LGTM.
Comment 9 commit-hook freebsd_committer freebsd_triage 2021-03-17 16:12:05 UTC
A commit references this bug:

Author: cy
Date: Wed Mar 17 16:11:28 UTC 2021
New revision: 568668
URL: https://svnweb.freebsd.org/changeset/ports/568668

Log:
  security/libgcrypt: Fix armv6 build

  Armv6 fails to build jitterentropy-base.c without optimization,
  even though #pragma GCC optimization and #pragma clang optimization
  are specified. For now brute force disable building the jitter
  entropy generator on armv6.

  PR:		253698
  Submitted by:	yani _ pi-greece.eu
  Reported by:	yani _ pi-greece.eu

Changes:
  head/security/libgcrypt/Makefile
Comment 10 NAKAJI Hiroyuki 2021-03-18 07:31:53 UTC
armv7 still gets same error.

--- rndjent.lo ---
`echo /bin/sh ../libtool  --tag=CC    --mode=compile cc -DHAVE_CONFIG_H  -I. -I..  -I../src -I../src   -I/usr/local/include -O -pipe  -fstack-protector-strong -fno-strict-aliasing -std=gnu89  -fvisibility=hidden -fno-delete-null-pointer-checks -Wall -c ./rndjent.c | sed -e 's/-O\([1-9sg][1-9sg]*\)/-O0/g' -e 's/-Ofast/-O0/g' `
libtool: compile:  cc -DHAVE_CONFIG_H -I. -I.. -I../src -I../src -I/usr/local/include -O -pipe -fstack-protector-strong -fno-strict-aliasing -std=gnu89 -fvisibility=hidden -fno-delete-null-pointer-checks -Wall -c ./rndjent.c  -fPIC -DPIC -o .libs/rndjent.o
In file included from ./rndjent.c:86:
./jitterentropy-base.c:53:13: warning: unknown pragma ignored [-Wunknown-pragmas]
#pragma GCC optimize ("O0")
            ^
./jitterentropy-base.c:61:4: error: "The CPU Jitter random number generator must not be compiled with optimizations. See documentation. Use the compiler switch -O0 for compiling jitterentropy-base.c."
  #error "The CPU Jitter random number generator must not be compiled with optimizations. See documentation. Use the compiler switch -O0 for compiling jitterentropy-base.c."
   ^
1 warning and 1 error generated.
*** [rndjent.lo] Error code 1
Comment 11 commit-hook freebsd_committer freebsd_triage 2021-03-27 02:56:29 UTC
A commit references this bug:

Author: cy
Date: Sat Mar 27 02:55:45 UTC 2021
New revision: 569290
URL: https://svnweb.freebsd.org/changeset/ports/569290

Log:
  security/libgcrypt: Fix armv7 build

  Similar to armv6, armv7 fails to build jitterentropy-base.c without
  optimization, falling flat on the #pragma GCC optimize statement.
  Like armv6, avoid building jitterentropy-base.c altogether.

  PR:		253698

Changes:
  head/security/libgcrypt/Makefile
Comment 12 Cy Schubert freebsd_committer freebsd_triage 2021-03-27 02:57:23 UTC
This last commit should fix it.