Bug 280081 - security/libgcrypt:fails to build
Summary: security/libgcrypt:fails to build
Status: Closed Not Accepted
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Cy Schubert
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-02 04:38 UTC by Ivan Rozhuk
Modified: 2024-07-02 20:19 UTC (History)
3 users (show)

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


Attachments
patch (741 bytes, patch)
2024-07-02 19:11 UTC, Ivan Rozhuk
rozhuk.im: maintainer-approval?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Rozhuk 2024-07-02 04:38:08 UTC
make showconfig
===> The following configuration options are available for libgcrypt-1.11.0:
     DOCS=off: Build and/or install documentation
     INFO=off: Build and/or install GNU info pages
     STATIC=on: Build static executables and/or libraries
===> Use 'make config' to modify these settings


...
--- random.lo ---
libtool: compile:  cc -DHAVE_CONFIG_H -I. -I.. -I../src -I../src -I/usr/local/include -O2 -pipe -O3 -pipe -funroll-loops -mretpoline -fno-delete-null-pointer-checks -fstack-protector-strong -fno-strict-aliasing -fdebug-prefix-map=/tmp/ports/usr/ports/security/libgcrypt/work/libgcrypt-1.11.0=. -fvisibility=hidden -fno-delete-null-pointer-checks -Wall -MT random.lo -MD -MP -MF .deps/random.Tpo -c random.c -o random.o >/dev/null 2>&1
--- rndjent.lo ---
In file included from ./rndjent.c:99:
./jitterentropy-base.c:58:3: error: "The CPU Jitter random number generator must not be compiled with optimizations. See documentation. Use the compiler switch -O0 for compiling jitterentropy.c."
   58 |  #error "The CPU Jitter random number generator must not be compiled with optimizations. See documentation. Use the compiler switch -O0 for compiling jitterentropy.c."
      |   ^
--- rndgetentropy.lo ---
mv -f .deps/rndgetentropy.Tpo .deps/rndgetentropy.Plo
--- random-csprng.lo ---
mv -f .deps/random-csprng.Tpo .deps/random-csprng.Plo
--- random-system.lo ---
mv -f .deps/random-system.Tpo .deps/random-system.Plo
--- rndhw.lo ---
mv -f .deps/rndhw.Tpo .deps/rndhw.Plo
--- random-drbg.lo ---
mv -f .deps/random-drbg.Tpo .deps/random-drbg.Plo
--- rndjent.lo ---
1 error generated.
*** [rndjent.lo] Error code 1

make[2]: stopped in /tmp/ports/usr/ports/security/libgcrypt/work/libgcrypt-1.11.0/random
--- random.lo ---
mv -f .deps/random.Tpo .deps/random.Plo
1 error

make[2]: stopped in /tmp/ports/usr/ports/security/libgcrypt/work/libgcrypt-1.11.0/random
Comment 1 Cy Schubert freebsd_committer freebsd_triage 2024-07-02 04:45:28 UTC
(In reply to Ivan Rozhuk from comment #0)

No such problem here.

Making install in tests
cd /export/wrkdir/amd64/export/freebsd/git/ports/security/libgcrypt/work/libgcrypt-1.11.0 && install  -m 0644 AUTHORS ChangeLog ChangeLog-2011 INSTALL NEWS THANKS TODO  doc/HACKING doc/README.apichanges /export/wrkdir/amd64/export/freebsd/git/ports/security/libgcrypt/work/stage/usr/local/share/doc/libgcrypt
====> Compressing man pages (compress-man)
====> Running Q/A tests (stage-qa)
slippy$ make showconfig
===> The following configuration options are available for libgcrypt-1.11.0:
     DOCS=on: Build and/or install documentation
     INFO=on: Build and/or install GNU info pages
     STATIC=on: Build static executables and/or libraries
===> Use 'make config' to modify these settings
slippy$ pwd
/home/cy/freebsd/git/ports/security/libgcrypt
slippy$ 

Tell me more about your system.

- uname -a
- what other ports/packages are installed?
- if running stable/current, what build options were used?
Comment 2 Daniel Engberg freebsd_committer freebsd_triage 2024-07-02 05:19:55 UTC
"-O3 -pipe -funroll-loops -mretpoline" looks to be injected in build
Comment 3 Cy Schubert freebsd_committer freebsd_triage 2024-07-02 05:49:02 UTC
(In reply to Daniel Engberg from comment #2)

Agreed. random.lo and rndjent.lo build fine with -O2 and nothing else.

What does the environment look like and is there a CFLAGS= in make.conf?
Comment 4 Ivan Rozhuk 2024-07-02 08:45:23 UTC
root@rimwks:/usr/ports/security/libgcrypt# make -V CFLAGS
-O2 -pipe -O3 -pipe -funroll-loops -mretpoline -fno-delete-null-pointer-checks  -fstack-protector-strong -fno-strict-aliasing  -fdebug-prefix-map=/tmp/ports/usr/ports/security/libgcrypt/work/libgcrypt-1.11.0=.
Comment 5 Ivan Rozhuk 2024-07-02 10:10:14 UTC
(In reply to Cy Schubert from comment #1)

# uname -a
FreeBSD rimwks.local 14.1-STABLE FreeBSD 14.1-STABLE RIM_WKS amd64


It is desktop/workstation, but same problem on server configs with "small" ports count.


http://netlab.dhis.org/download/software/os_cfg/FBSD/14/base/
+
http://netlab.dhis.org/download/software/os_cfg/FBSD/14/srv/

it is almost all configs for OS related things.
Comment 6 Cy Schubert freebsd_committer freebsd_triage 2024-07-02 14:05:17 UTC
(In reply to Ivan Rozhuk from comment #4)

Please remove CFLAGS=-O3 -pipe -funroll-loops -mretpoline from your make.conf. libgcrypt does not support -O3.

This is why it says:

#error "The CPU Jitter random number generator must not be compiled with optimizations. See documentation. Use the compiler switch -O0 for compiling jitterentropy.c."

Again, libgcrypt does not support CFLAGS=-O3.
Comment 7 Cy Schubert freebsd_committer freebsd_triage 2024-07-02 14:38:12 UTC
(In reply to Ivan Rozhuk from comment #5)

http://netlab.dhis.org/download/software/os_cfg/FBSD/14/base/ includes CFLAGS=-O3. Confirmed on my sandbox machine that -O3 causes this build failure. Remove -O3 from make.conf.
Comment 8 Ivan Rozhuk 2024-07-02 14:49:04 UTC
(In reply to Cy Schubert from comment #7)

I will not change my make.conf due to ONE port.

Please sanitize CFLAGS in ports makefile.

Something like:
CFLAGS:=	${CFLAGS:N-O*}
should work.
Comment 9 Cy Schubert freebsd_committer freebsd_triage 2024-07-02 16:27:33 UTC
(In reply to Ivan Rozhuk from comment #8)

This is overly aggressive as it removes -O2 defaulted by ports plumbing. This is unacceptable. Sorry.

The only compromise might be to  control this through an option, which you would have to set when using CFLAGS in make.conf. This will have to be acceptable or you'd need to submit a patch to resolve this without affecting the builds as they are today.
Comment 10 Daniel Engberg freebsd_committer freebsd_triage 2024-07-02 17:53:03 UTC
The only supported optimization option apart from ones that individual ports offer is CPUTYPE (-march), anything else is not supported and have "wont fix"/"you're on your own" status. Setting CPUTYPE will however break some ports due to how upstream handles builds so it's best effort status.

We're not going to sanitize C/CXXFLAGS treewide or per port because someone wants to run custom flags which otherwise breaks builds. If you want to do so you need to maintain your own patchset.
Comment 11 Ivan Rozhuk 2024-07-02 18:03:09 UTC
-O2 is not ports default, as I remember it is system default, with "-pipe".


CFLAGS sanitizing is widely used in ports tree:
# grep -rsp 'CFLAGS:N-' /usr/ports/
/usr/ports/Mk/Features/debug.mk:CFLAGS:=		${CFLAGS:N-O*:N-fno-strict*} ${DEBUG_FLAGS}
/usr/ports/Mk/bsd.gcc.mk:CFLAGS:=		${CFLAGS:N-mretpoline}
/usr/ports/audio/linux-c7-alsa-plugins-oss/Makefile:		CFLAGS="${CFLAGS:N-march=*} ${COMPAT32_CFLAGS_${ARCH}}" \
/usr/ports/audio/linux-c7-alsa-plugins-oss/Makefile:		CFLAGS="${CFLAGS:N-march=*}" LDFLAGS="${LDFLAGS}" \
/usr/ports/databases/rrdtool12/Makefile:CFLAGS:=	${CFLAGS:N-ffast-math}
/usr/ports/devel/boost-all/compiled.mk:MAKE_ARGS+=	cxxflags="${CXXFLAGS:N-O*}" cflags="${CFLAGS:N-O*}"
/usr/ports/devel/liboil/Makefile:CFLAGS:=	${CFLAGS:N-O*} -O2
/usr/ports/devel/linux_libusb/Makefile:CFLAGS:=	${CFLAGS:N-march=*}
/usr/ports/editors/e93/files/patch-Makefile:+	$(CC) $(CFLAGS:N-D*:N-I*) $(OBJECTS) -Lxgui -lgui \
/usr/ports/games/vavoom/Makefile:CFLAGS:=	${CFLAGS:N-fno-strict-aliasing}
/usr/ports/games/vavoom/Makefile:CXXFLAGS:=	${CFLAGS:N-fno-strict-aliasing}
/usr/ports/lang/gcc15-devel/Makefile:CFLAGS:=	${CFLAGS:N-mretpoline} -D__USE_ISOC11
/usr/ports/lang/gcc10/Makefile:CFLAGS:=	${CFLAGS:N-mretpoline}
/usr/ports/lang/gcc11-devel/Makefile:CFLAGS:=	${CFLAGS:N-mretpoline}
/usr/ports/lang/gcc11/Makefile:CFLAGS:=	${CFLAGS:N-mretpoline}
/usr/ports/lang/gcc12-devel/Makefile:CFLAGS:=	${CFLAGS:N-mretpoline}
/usr/ports/lang/gcc12/Makefile:CFLAGS:=	${CFLAGS:N-mretpoline}
/usr/ports/lang/gcc13-devel/Makefile:CFLAGS:=	${CFLAGS:N-mretpoline}
/usr/ports/lang/gcc13/Makefile:CFLAGS:=	${CFLAGS:N-mretpoline}
/usr/ports/lang/gcc14-devel/Makefile:CFLAGS:=	${CFLAGS:N-mretpoline} -D__USE_ISOC11
/usr/ports/lang/gcc6-aux/Makefile.common:CFLAGS:=		${CFLAGS:N-march=*}
/usr/ports/lang/gcc14/Makefile:CFLAGS:=	${CFLAGS:N-mretpoline} -D__USE_ISOC11
/usr/ports/lang/scm/Makefile:CFLAGS:=	${CFLAGS:N-O*} -O0
/usr/ports/math/librsb/Makefile:OPTIMIZE_CONFIGURE_ENV=	SPCFLAGS="${CFLAGS:N-O*}"
/usr/ports/multimedia/x265/Makefile:CFLAGS:=	${CFLAGS:N-O*} -O0 -g
/usr/ports/shells/es/Makefile:CFLAGS:=	${CFLAGS:N-O*}


To unbreak build you can remove just -O3 (4,5..?) or force -O2
CFLAGS:=	${CFLAGS:N-O3}
CFLAGS:=	${CFLAGS:N-O*} -O2


Anyway, removing any CFLAGS option from make.conf due to one silly port is not a good way.
Comment 12 Ivan Rozhuk 2024-07-02 18:08:32 UTC
(In reply to Daniel Engberg from comment #10)
> The only supported optimization option apart from ones that individual ports offer is CPUTYPE (-march), anything else is not supported and have "wont fix"/"you're on your own" status.

Is this official FreeBSD foundation position that related at least in porters handbook?


> We're not going to sanitize C/CXXFLAGS treewide or per port because someone wants to run custom flags which otherwise breaks builds.

This is port specific issue, why you extrapolate it to all ports?
-O3 works for me with ~1k ports, only for wine I have workaround with CFLAGS.
Comment 14 Ivan Rozhuk 2024-07-02 18:50:10 UTC
(In reply to Daniel Engberg from comment #13)

It say: "The port must respect CFLAGS.".
So please respect mine -O3 like all other ports.
Comment 15 Daniel Engberg freebsd_committer freebsd_triage 2024-07-02 18:54:45 UTC
Which we do and it fails, closing this as there's no point in discussing this any further.
Comment 16 Ivan Rozhuk 2024-07-02 19:01:55 UTC
(In reply to Daniel Engberg from comment #15)

As usual: it work on my comp with holly defaults.
Comment 17 Ivan Rozhuk 2024-07-02 19:11:29 UTC
Created attachment 251838 [details]
patch

for peoples than do not use holly defaults.
Comment 18 Cy Schubert freebsd_committer freebsd_triage 2024-07-02 19:56:54 UTC
(In reply to Ivan Rozhuk from comment #17)

This patch was rejected once. It's still rejected. It overrides CFLAGS as set by bsd.port.mk. If you are to do a patch, it MUST edit the CFLAGS such that -O<whatever bsd.port.mk sets> is not overriden by the port. This is why I rejected the patch the first time and this is why I reject the patch now.
Comment 19 Ivan Rozhuk 2024-07-02 20:19:38 UTC
(In reply to Cy Schubert from comment #18)

Whatever, continue keep ports ugly and broken.

CFLAGS:=	${CFLAGS:N-O*} -O2
is ok for me.
You can play with
CFLAGS:=	${CFLAGS:N-O3:N-O4:N-O5}

I do not see here constructive options to fix, only "no, no, use holly defaults!".
https://www.youtube.com/watch?v=SE0fhflzoHM
I do not play in such games.

Current status of this: BROKEN due to no maintainers support outside they home PC.