Bug 251106

Summary: security/botan2: does not build in presence of itself
Product: Ports & Packages Reporter: Dmitry Marakasov <amdmi3>
Component: Individual Port(s)Assignee: Dmitry Marakasov <amdmi3>
Status: Closed FIXED    
Severity: Affects Many People CC: acupuncture, fastmint, tremere
Priority: --- Flags: tremere: maintainer-feedback+
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Full build log
none
Patch with workaround
none
Patch from upstream
none
Update Botan to 2.17.2 and add patch from upstream to fix linking issue tremere: maintainer-approval+

Description Dmitry Marakasov freebsd_committer 2020-11-13 17:30:47 UTC
Created attachment 219640 [details]
Full build log

botan2 has problem with library path order which places system library path before local ones, which leads to picking up library from botan2 installed in the system, which breaks the build or may produce broken package.

There doesn't seem to be problems with includes:

c++ -fstack-protector -pthread -std=c++11 -D_REENTRANT  -O2 -pipe -march=skylake -fstack-protector-strong -fno-strict-aliasing   -DBOTAN_IS_BEING_BUILT -Wall -Wextra -Wpedantic -Wshadow -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -msse2 -Ibuild/include -Ibuild/include/external -I/usr/local/include -c src/tests/test_simd.cpp -o build/obj/test/test_simd.o

(/usr/local/include comes AFTER local includes)

However there definitely is a problem with library paths:

c++ -L/usr/local/lib -fstack-protector -pthread build/obj/cli/argon2.o build/obj/cli/asn1.o build/obj/cli/bcrypt.o build/obj/cli/cc_enc.o build/obj/cli/cli.o build/obj/cli/cli_rng.o build/obj/cli/codec.o build/obj/cli/compress.o build/obj/cli/encryption.o build/obj/cli/entropy.o build/obj/cli/hash.o build/obj/cli/hmac.o build/obj/cli/main.o build/obj/cli/math.o build/obj/cli/pbkdf.o build/obj/cli/pk_crypt.o build/obj/cli/psk.o build/obj/cli/pubkey.o build/obj/cli/roughtime.o build/obj/cli/sandbox.o build/obj/cli/speed.o build/obj/cli/timing_tests.o build/obj/cli/tls_client.o build/obj/cli/tls_http_server.o build/obj/cli/tls_proxy.o build/obj/cli/tls_server.o build/obj/cli/tls_utils.o build/obj/cli/tss.o build/obj/cli/utils.o build/obj/cli/x509.o -pthread  -fstack-protector-strong  -L. -lbotan-2 -lboost_system -lbz2 -lcrypto -llzma -lz -o botan
ld: error: undefined symbol: Botan::Stateful_RNG::add_entropy(unsigned char const*, unsigned long)

(/usr/local/lib comes BEFORE local library paths)

This breaks the update of botan2 from 2.15 to 2.17.1.
Comment 1 Dmitry Marakasov freebsd_committer 2020-11-13 17:44:35 UTC
Upstream issue: https://github.com/randombit/botan/issues/2496
Comment 2 Dmitry Marakasov freebsd_committer 2020-11-13 19:18:24 UTC
Created attachment 219643 [details]
Patch with workaround

Suggesting a workaround to fix the update for port users.
Comment 3 Dmitry Marakasov freebsd_committer 2020-11-14 00:46:08 UTC
Created attachment 219660 [details]
Patch from upstream

Upstream has fixed it, I suggest to apply their fix as-is.
Comment 4 Citro├źn 2020-11-14 14:30:35 UTC
(In reply to Dmitry Marakasov from comment #3)

Confirmed. Applied patch, rebuilt. Everything OK.

Thx.
Comment 5 Ralf van der Enden 2020-11-14 16:41:55 UTC
I will regenerate the patch to make portlint happy. Once that's been done it's fine to commit.
Comment 6 Nikos 2020-11-14 17:05:48 UTC
I have the same problem
c++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [Makefile:73: botan] Error 1
gmake[2]: *** Waiting for unfinished jobs....
   INFO: Starting sphinx-build -q -c ./src/configs/sphinx -j 4 -b html ./doc build/docs/handbook
   INFO: Starting rst2man build/botan.rst build/botan.1
gmake[2]: Leaving directory '/usr/ports/security/botan2/work/Botan-2.17.1'
===> 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/security/botan2
*** Error code 1

my os
 FreeBSD 12.2-RELEASE r366954 GENERIC  amd64
Comment 7 Ralf van der Enden 2020-11-14 20:45:38 UTC
Created attachment 219690 [details]
Update Botan to 2.17.2 and add patch from upstream to fix linking issue


Q&A:
testport: OK (12.2; amd64)
portlint: OK (looks fine.)
Comment 8 Ralf van der Enden 2020-11-14 20:46:33 UTC
Regenerated patch to make portlint happy.

While here also update to 2.17.2

Changelog: https://botan.randombit.net/news.html#version-2-17-2-2020-11-13
Comment 9 commit-hook freebsd_committer 2020-11-15 14:07:42 UTC
A commit references this bug:

Author: amdmi3
Date: Sun Nov 15 14:07:15 UTC 2020
New revision: 555220
URL: https://svnweb.freebsd.org/changeset/ports/555220

Log:
  - Update to 2.17.2
  - Fix building in presence of older version of botan2 installed in the system by importing upstream patch

  PR:		251106
  Submitted by:	tremere@cainites.net (maintainer)
  Reported by:	amdmi3, acupuncture@cgocable.ca, fastmint@hush.com

Changes:
  head/security/botan2/Makefile
  head/security/botan2/distinfo
  head/security/botan2/files/
  head/security/botan2/files/patch-fix-link-paths