Bug 276891 - databases/redis failed to build
Summary: databases/redis failed to build
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Muhammad Moinur Rahman
URL:
Keywords:
: 291329 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-02-08 11:40 UTC by Jekyll Chen
Modified: 2025-12-08 22:02 UTC (History)
11 users (show)

See Also:
bugzilla: maintainer-feedback? (bofh)
zarychtam: merge-quarterly?


Attachments
databases/redis build log (56.58 KB, text/plain)
2024-02-08 11:40 UTC, Jekyll Chen
no flags Details
Patch to Makefile (480 bytes, patch)
2024-04-23 08:56 UTC, Andrew
no flags Details | Diff
Redis 8.4.0 compile fix patch (2.57 KB, patch)
2025-12-02 11:07 UTC, Eero Hänninen
no flags Details | Diff
Redis 8.4.0 compile fix ver 2 (2.71 KB, patch)
2025-12-03 07:54 UTC, Eero Hänninen
no flags Details | Diff
Redis 8.4.0 compile fix ver 2 Poudriere build log (104.39 KB, text/plain)
2025-12-03 07:56 UTC, Eero Hänninen
no flags Details
Redis 8.4.0 compile fix ver 3 (2.73 KB, patch)
2025-12-06 19:55 UTC, Eero Hänninen
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jekyll Chen 2024-02-08 11:40:47 UTC
Created attachment 248254 [details]
databases/redis build log

The environment is FreeBSD 13.2-RELEASE-p9 with security/openssl installed.


cc  -lpthread -lm -lexecinfo -Wl,-rpath,/usr/local/lib -fstack-protector-strong  -pthread  -o redis-server adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o eval.o bio.o rio.o rand.o memtest.o syscheck.o crcspeed.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o lolwut.o lolwut5.o lolwut6.o acl.o tracking.o socket.o tls.o sha256.o timeout.o setcpuaffinity.o monotonic.o mt19937-64.o resp_parser.o call_reply.o script_lua.o script.o functions.o function_lua.o commands.o strl.o connection.o unix.o logreqres.o ../deps/hiredis/libhiredis.a ../deps/lua/src/liblua.a ../deps/hdr_histogram/libhdrhistogram.a ../deps/fpconv/libfpconv.a -lm ../deps/hiredis/libhiredis_ssl.a -L/usr/local/lib -lssl -L/usr/local/lib -lcrypto
ld: error: undefined symbol: SSL_get_peer_certificate
>>> referenced by tls.c
>>>               tls.o:(connTLSGetPeerCert)
>>> did you mean: SSL_get0_peer_certificate
>>> defined in: /usr/local/lib/libssl.so
cc: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[3]: *** [Makefile:408: redis-server] Error 1
gmake[3]: *** Waiting for unfinished jobs....
gmake[3]: Leaving directory '/usr/ports/databases/redis/work/redis-7.2.4/src'
gmake[2]: *** [Makefile:6: all] Error 2
gmake[2]: Leaving directory '/usr/ports/databases/redis/work/redis-7.2.4'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/databases/redis
*** Error code 1

Stop.
make: stopped in /usr/ports/databases/redis
root@FreeBSD[/usr/ports/databases/redis]#
Comment 1 Jekyll Chen 2024-02-08 11:42:14 UTC
For me it looks like the same issue as https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=274512 , the hotfix provided there also works here.
Comment 2 Yasuhiro Kimura freebsd_committer freebsd_triage 2024-02-08 14:29:19 UTC
(In reply to Jekyll Chen from comment #0)

Do you add 'DEFAULT_VERSIONS+=ssl=openssl' in /etc/make.conf?
Comment 3 Jekyll Chen 2024-02-09 04:43:54 UTC
(In reply to Yasuhiro Kimura from comment #2)
Yes, I added it since long ago.
I tried commenting it out, and it warns "You have security/openssl installed but do not have DEFAULT_VERSIONS+=ssl=openssl set in your make.conf" and build still failed.
Comment 4 Yasuhiro Kimura freebsd_committer freebsd_triage 2024-02-09 07:00:06 UTC
(In reply to Jekyll Chen from comment #3)

I tried following steps.

1. Make clean install of 13.2-RELEASE amd64
2. Checkout latest main branch of ports tree
3. Add 'DEFAULT_VERSIONS+=ssl=openssl' to /etc/make.conf
4. cd /usr/ports/databases/redis
5. make

And build succeeds without any problem.
Comment 5 Jekyll Chen 2024-02-09 07:03:33 UTC
(In reply to Yasuhiro Kimura from comment #4)
Is there anything I can do for trouble shooting?
Comment 6 Yasuhiro Kimura freebsd_committer freebsd_triage 2024-02-09 07:16:59 UTC
(In reply to Jekyll Chen from comment #5)

Q1. Did you make clean install of 13.2-RELEASE or upgrade from pervious version?
Q2. Are all installed packages built after 'DEFAULT_VERSIONS+=ssl=openssl' is added to /etc/make.conf
Q3. Are there any non-default option settings about all installed packages?
Q4. Do you have any other settings in /etc/make.conf?
Comment 7 Jekyll Chen 2024-02-09 07:25:43 UTC
(In reply to Yasuhiro Kimura from comment #6)

A1. It's been upgraded from previous versions several times with building from source.
A2. I believe so, since it was added long time ago.
A3. I bet yes... but I can't detail what were changed.
A4. The other setting there is OPTIONS_UNSET=X11 .
Comment 8 Yasuhiro Kimura freebsd_committer freebsd_triage 2024-02-09 08:28:51 UTC
(In reply to Jekyll Chen from comment #7)

Are all installed packages up-to-date? If not update all outdated packages and try again.
Comment 9 Jekyll Chen 2024-02-09 09:33:57 UTC
(In reply to Yasuhiro Kimura from comment #8)

They are. Only redis is behind head.
Comment 10 Yasuhiro Kimura freebsd_committer freebsd_triage 2024-02-09 12:50:30 UTC
(In reply to Jekyll Chen from comment #9)

Umm...then my suggestion is to deinstall all packages and reinstall them again. IMHO such weirdness sometimes happnes if you have used FreeBSD ports collecton under non-cleanroom environment. That's why I switched to use poudriere except one system that is used for ports development. And for the system I periodically do the cleanup of installed packages by deinstalling all of them and installing
necessary ones again.
Comment 11 Jekyll Chen 2024-02-10 15:33:28 UTC
(In reply to Yasuhiro Kimura from comment #10)

I'm trying portmaster -af and will update the result. Thank you.
Comment 12 Jekyll Chen 2024-02-10 17:49:40 UTC
(In reply to Yasuhiro Kimura from comment #10)

Unfortunately, portmaster -af failed again.
However, I compared the failed log with succeeded log from my other machine, I found that there are two additional "-L/usr/local/lib" near the end of the failing command below. I tried manually running the command with them deleted and the command executed successfully. Do you have any idea what might cause this issue?

cc  -lpthread -lm -lexecinfo -Wl,-rpath,/usr/local/lib -fstack-protector-strong  -pthread  -o redis-server adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o eval.o bio.o rio.o rand.o memtest.o syscheck.o crcspeed.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o lolwut.o lolwut5.o lolwut6.o acl.o tracking.o socket.o tls.o sha256.o timeout.o setcpuaffinity.o monotonic.o mt19937-64.o resp_parser.o call_reply.o script_lua.o script.o functions.o function_lua.o commands.o strl.o connection.o unix.o logreqres.o ../deps/hiredis/libhiredis.a ../deps/lua/src/liblua.a ../deps/hdr_histogram/libhdrhistogram.a ../deps/fpconv/libfpconv.a -lm ../deps/hiredis/libhiredis_ssl.a -L/usr/local/lib -lssl -L/usr/local/lib -lcrypto
Comment 13 Andrew 2024-04-23 08:56:50 UTC
Created attachment 250169 [details]
Patch to Makefile

Just hit the problem, compiling 2024Q2 on releng/13.3.

Solved by patching as suggested in the 1st comment of bug 274512
Comment 14 Andrew 2024-10-15 18:29:53 UTC
The previous patch is still needed to build the version in 2024Q4 on releng/13.4
Comment 15 Marek Zarychta 2025-11-28 15:29:23 UTC
databases/redis was recently upgraded: 8.2.3 -> 8.4.0, and a new version cannot be build with:
WITH_PIE=YES
WITH_RELRO=YES
WITH_BIND_NOW=YES

As a workaround, the above build options should be disabled on databases/redis:
WITHOUT_PIE_PORTS+= databases/redis
WITHOUT_RELRO_PORTS+= databases/redis
WITHOUT_BIND_NOW_PORTS+= databases/redis

Linking errors for the three together:
ld -o commandfilter.so commandfilter.xo -shared   -Wl,-znow -pie -Wl,-zrelro  
ld -o basics.so basics.xo -shared   -Wl,-znow -pie -Wl,-zrelro  
ld: error: unknown argument '-Wl,-znow'
ld: error: unknown argument '-Wl,-zrelro'
gmake[2]: *** [Makefile:100: commandfilter.so] Error 1
gmake[2]: *** Waiting for unfinished jobs....
ld: error: unknown argument '-Wl,-znow'
ld: error: unknown argument '-Wl,-zrelro'
gmake[2]: *** [Makefile:100: basics.so] Error 1

Linking errors for PIE only:
ld -o commandfilter.so commandfilter.xo -shared   -pie  
ld -o basics.so basics.xo -shared   -pie  
ld: error: -shared and -pie may not be used together
gmake[2]: *** [Makefile:100: commandfilter.so] Error 1
gmake[2]: *** Waiting for unfinished jobs....
ld: error: -shared and -pie may not be used together
gmake[2]: *** [Makefile:100: basics.so] Error 1
Comment 16 Yasuhiro Kimura freebsd_committer freebsd_triage 2025-11-28 15:44:52 UTC
Assing to current maintainer.
Comment 17 Eero Hänninen 2025-12-02 11:07:31 UTC
Created attachment 265772 [details]
Redis 8.4.0 compile fix patch

Hopefully this patch will work for you.

I have a similar problem. I use a custom version of OpenSSL and got:

ld -o commandfilter.so commandfilter.xo -shared  -Wl,-rpath,/usr/local/lib  
ld: error: unknown argument '-Wl,-rpath,/usr/local/lib'
gmake[2]: *** [Makefile:100: commandfilter.so] Error 1
gmake[2]: *** Waiting for unfinished jobs....

It seems that Redis Makefiles don't handle FreeBSD correctly. The ports system expects that the compiler itself calls the linker, but Redis Makefile calls the linker directly and that's where those unknown arguments come from. So I added an 'if' block to tests/modules/Makefile which fixes my compiler problem.

Other changes I made:

    * Added pkgconfig to USES flag - reason: my poudriere gives /bin/sh: pkg-config: not found
    * Added coreutils as build dependency - reason: my poudriere gives /bin/sh: gmd5sum: not found
    * Added an 'if' block to deps/xxhash/Makefile - reason:

gmake[2]: Entering directory '/wrkdirs/usr/ports/databases/redis/work/redis-8.4.0/deps'
(cd hiredis && /usr/local/bin/gmake clean) > /dev/null || true
(cd linenoise && /usr/local/bin/gmake clean) > /dev/null || true
(cd lua && /usr/local/bin/gmake clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && /usr/local/bin/gmake distclean) > /dev/null || true
(cd hdr_histogram && /usr/local/bin/gmake clean) > /dev/null || true
(cd fpconv && /usr/local/bin/gmake clean) > /dev/null || true
(cd fast_float && /usr/local/bin/gmake clean) > /dev/null || true
(cd xxhash && /usr/local/bin/gmake clean) > /dev/null || true
/bin/sh: gmd5sum: not found
gmake[4]: *** tests: No such file or directory.  Stop.
gmake[3]: *** [Makefile:189: clean] Error 2
(rm -f .make-*)
gmake[2]: Leaving directory '/wrkdirs/usr/ports/databases/redis/work/redis-8.4.0/deps'
Comment 18 Marek Zarychta 2025-12-02 17:56:38 UTC
(In reply to Eero Hänninen from comment #17)
Thanks for the patch. This fix is 100% OK for building port WITH_{PIE,RELRO,BIND_NOW,ZEROREGS} and indeed it's doing good job:

/usr/local/bin/redis-server: ELF 64-bit LSB pie executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 15.0 (1500501), FreeBSD-style, stripped

Perhaps you can also do a PORTREVISION bump ?

Dear bofh@, Dear yasu@, please push this patch to the tree.
Comment 19 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2025-12-02 18:28:26 UTC
(In reply to Eero Hänninen from comment #17)
Can you try your patch with:
BINARY_ALIAS=	gmd5sum=md5sum

instead of the BUILD_DEPENDS and let me know the result. I will look into this in the upcoming weekend.
Comment 20 Eero Hänninen 2025-12-03 07:54:43 UTC
Created attachment 265791 [details]
Redis 8.4.0 compile fix ver 2

Sorry for the little delay. I was investigating why Redis upstream is using gmd5sum instead of md5sum (md5 command in GNU mode). Unfortunately I got no answer, as this deps/xxhash/build/make/multiconf.make is pulled in as one piece and there are no other changes (pull request https://github.com/redis/redis/pull/14435). This multiconf.make contains the comment:

# Automatic determination of build artifacts cache directory, keyed on build
# flags, so that we can do incremental, parallel builds of different binaries
# with different build flags without collisions.
UNAME ?= $(shell uname)
ifeq ($(UNAME), Darwin)
  HASH ?= md5
else ifeq ($(UNAME), FreeBSD)
  HASH ?= gmd5sum
else ifeq ($(UNAME), OpenBSD)
  HASH ?= md5
endif

But for me BINARY_ALIAS works correctly, so I made a new patch with a port revision bump.
Comment 21 Eero Hänninen 2025-12-03 07:56:37 UTC
Created attachment 265792 [details]
Redis 8.4.0 compile fix ver 2 Poudriere build log

Just in case added my Poudriere build log with my patch.
Comment 22 James TD Smith 2025-12-06 12:53:03 UTC
I'm still seeing build failures on 13.5 with the patch, the same SSL issue as originally reported. 

Oddly the port was building previously but despite having ssl=openssl in DEFAULT_VERSIONS, redis-server was using the base OpenSSL.

/usr/local/bin/redis-server:
        libthr.so.3 => /lib/libthr.so.3 (0x188b9ac4b000)
        libm.so.5 => /lib/libm.so.5 (0x188b9ba18000)
        libexecinfo.so.1 => /usr/lib/libexecinfo.so.1 (0x188b9ca48000)
        libc++.so.1 => /usr/lib/libc++.so.1 (0x188b9d7bd000)
        libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x188b9e2a5000)
        libssl.so.111 => /usr/lib/libssl.so.111 (0x188b9ea1d000)
        libcrypto.so.111 => /lib/libcrypto.so.111 (0x188b9fa2c000)
        libc.so.7 => /lib/libc.so.7 (0x188ba0ef1000)
        libelf.so.2 => /lib/libelf.so.2 (0x188ba0191000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x188ba2341000)
        [vdso] (0x7ffffffff650)

Adding CFLAGS+= -I${OPENSSLINC} and LDFLAGS+= -L${OPENSSLLIB} as suggested in one of the previous comments allows building 8.4.0 which is now correctly linked against the OpenSSL from ports:

/usr/local/bin/redis-server:
        libm.so.5 => /lib/libm.so.5 (0x2068b02b3000)
        libc++.so.1 => /usr/lib/libc++.so.1 (0x2068b163d000)
        libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x2068b0439000)
        libthr.so.3 => /lib/libthr.so.3 (0x2068b06bc000)
        libexecinfo.so.1 => /usr/lib/libexecinfo.so.1 (0x2068b19f6000)
        libssl.so.12 => /usr/local/lib/libssl.so.12 (0x2068b335d000)
        libcrypto.so.12 => /usr/local/lib/libcrypto.so.12 (0x2068b1ac0000)
        libc.so.7 => /lib/libc.so.7 (0x2068b2838000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x2068b43b1000)
        libelf.so.2 => /lib/libelf.so.2 (0x2068b4cc9000)
        [vdso] (0x7ffffffff650)

Can someone who's built it on 14.x check if it's using the right SSL library?
Comment 23 Marek Zarychta 2025-12-06 13:23:57 UTC
(In reply to James TD Smith from comment #22)
Try adding  localbase:ldflags to USES section in port's Makefile.
Comment 24 Marek Zarychta 2025-12-06 15:13:42 UTC
I have tested the patch building Redis on 13.5, 14.3 and 15.0. The patch is great, but concerning OpenSSL, we need one more fix:
Without adding localbase:ldflags to the USES section, the port fails to build on FreeBSD versions prior to 14.0.
Starting with FreeBSD 14.0, OpenSSL 3 (or newer) is included in the base system. In this case Redis ends up linking against the OpenSSL library from ports while using only the headers from the base system, which is almost certainly incorrect.

In my opinion, localbase:ldflags should be added unconditionally to the USES for this port to ensure consistent and correct linking across all supported FreeBSD versions. 

Eero, please update patch v2 and mark previous patches as obsolete so Muhammad can push it without modifications.
Comment 25 Eero Hänninen 2025-12-06 19:55:00 UTC
Created attachment 265933 [details]
Redis 8.4.0 compile fix ver 3

Thank you and here is a new patch.
Comment 26 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2025-12-07 12:10:33 UTC
(In reply to Eero Hänninen from comment #25)
The actual conversation has actually diverted and I am having a hard time figuring out. Can you please confirm that this patch solves:
1. OpenSSL issue when OpenSSL is not the base
2. PIE/RELRO/BIND_NOW builds?
Comment 27 Eero Hänninen 2025-12-07 20:31:54 UTC
(In reply to Muhammad Moinur Rahman from comment #26)
I have tested with poudriere against FreeBSD versions 13.5, 14.3, and 15.0 on amd64 architecture, and I can confirm that in my test cases everything compiled correctly.
My make.conf was (sorry for the unneeded lines):

OPTIONS_UNSET=X11 NLS INFO MAN KDE DOCS SMB
OPTIONS_SET=MYSQL SQL POSTFIX PATCHES ENCODINGS THREADS
DEFAULT_VERSIONS+=mysql=118m
DEFAULT_VERSIONS+=pgsql=17
DEFAULT_VERSIONS+=nodejs=24
LICENSES_ACCEPTED+=DCC
DEFAULT_VERSIONS+=ssl=openssl35
WITH_PIE=YES
WITH_RELRO=YES
WITH_BIND_NOW=YES

Tested all four combinations of the openssl line and the last 3 lines being commented out or uncommented.

Is there a need for a test case where a port is compiled directly in /usr/ports, OpenSSL from ports is installed, and make.conf specifies base system OpenSSL?
Comment 28 Marek Zarychta 2025-12-08 08:51:43 UTC
(In reply to Muhammad Moinur Rahman from comment #26)
Ad. 1: Please see my comments #23 and #24; 
Ad. 2: The original Eero's patch solved the problem reported in comment #15 and also bug 291329.

TL;DR: Adding "localbase:ldflags" to the USES section solves the build problem on FreeBSD 13.5 with OpenSSL from ports. The most recent version of Eero's patch incorporates this change and his fixes to perform the build and linking correctly, so after pushing the fix ver 3, both bug 276891 and bug 291329 should be closed.
Comment 29 commit-hook freebsd_committer freebsd_triage 2025-12-08 22:01:05 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5996ac3220cee861e722ac19d5db85970a5297b6

commit 5996ac3220cee861e722ac19d5db85970a5297b6
Author:     Eero Hanninen <fax@nohik.ee>
AuthorDate: 2025-12-02 06:15:25 +0000
Commit:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
CommitDate: 2025-12-08 21:59:54 +0000

    databases/redis: Compile fixes

    PR:             276891
    Reported by:    jekyll530@hotmail.com

 databases/redis/Makefile                                 |  4 +++-
 databases/redis/files/patch-deps_xxhash_Makefile (new)   | 16 ++++++++++++++++
 databases/redis/files/patch-tests_modules_Makefile (new) | 14 ++++++++++++++
 3 files changed, 33 insertions(+), 1 deletion(-)
Comment 30 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2025-12-08 22:01:29 UTC
*** Bug 291329 has been marked as a duplicate of this bug. ***