From fbe3a849072f48d6ed33992536b4cbcb361c6cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Sat, 29 Oct 2016 19:30:47 +0200 Subject: [PATCH] [scons] workaround FreeBSD11 fullstatic link error The error for reference: /usr/lib/libc.a(arc4random.o): In function `arc4random': /usr/src/lib/libc/gen/arc4random.c:(.text+0x410): multiple definition of `arc4random' /usr/local/lib/libcrypto.a(arc4random.o):(.text+0x0): first defined here /usr/lib/libc.a(arc4random.o): In function `arc4random_buf': /usr/src/lib/libc/gen/arc4random.c:(.text+0x580): multiple definition of `arc4random_buf' /usr/local/lib/libcrypto.a(arc4random.o):(.text+0x80): first defined here --- src/SConscript | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/SConscript b/src/SConscript index eabee41a..2f3b5a3b 100644 --- a/src/SConscript +++ b/src/SConscript @@ -35,8 +35,18 @@ def RemoveDuplicateLibs(libs): Import('env') +def WorkaroundFreeBSDLibOrder(libs): + # lib(re)ssl includes (weak) arc4random functions + # which "on purpose" might conflict with those in libc + # => link libc first solves this + # (required for FreeBSD11 fullstatic build) + if 'c' in libs: + return ['c'] + libs + return libs + def GatherLibs(env, *libs): - return RemoveDuplicateLibs(env['LIBS'] + list(libs) + [env['APPEND_LIBS']]) + libs = RemoveDuplicateLibs(env['LIBS'] + list(libs) + [env['APPEND_LIBS']]) + return WorkaroundFreeBSDLibOrder(libs) common_src = Split("base64.c buffer.c log.c \ keyvalue.c chunk.c \