cbang: cherry-pick cross-compile patch from upstream.
The old patch has a bug with sizeof(long) on 32-bit platform. Close: #22508
This commit is contained in:
parent
8b4aee3857
commit
e5b817dedf
7 changed files with 254 additions and 112 deletions
|
@ -1,52 +0,0 @@
|
||||||
From 9e22c0114d010a35128aa67b0dc38cc23f4d873f Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
|
|
||||||
<congdanhqx@gmail.com>
|
|
||||||
Date: Sun, 17 May 2020 21:53:46 +0700
|
|
||||||
Subject: [PATCH 1/5] config/openssl: correct version check
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
Current code requires all conditions meet to pass the check, thus,
|
|
||||||
return false negative for:
|
|
||||||
- 1.0.2 vs 1.1.0
|
|
||||||
- 1.1.0 vs 2.0.0
|
|
||||||
|
|
||||||
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
|
|
||||||
---
|
|
||||||
config/openssl/__init__.py | 17 ++++++++++-------
|
|
||||||
1 file changed, 10 insertions(+), 7 deletions(-)
|
|
||||||
|
|
||||||
diff --git config/openssl/__init__.py config/openssl/__init__.py
|
|
||||||
index 421271cd..e0d3884a 100644
|
|
||||||
--- config/openssl/__init__.py
|
|
||||||
+++ config/openssl/__init__.py
|
|
||||||
@@ -6,15 +6,18 @@ def check_version(context, version):
|
|
||||||
context.Message("Checking for openssl version >= %s..." % version)
|
|
||||||
|
|
||||||
version = version.split('.')
|
|
||||||
- src = '#include <openssl/opensslv.h>\nint main() {\nreturn ('
|
|
||||||
- src += version[0] + '<= (OPENSSL_VERSION_NUMBER >> 28)'
|
|
||||||
+ src = '''
|
|
||||||
+ #include <openssl/opensslv.h>
|
|
||||||
+ int main() {
|
|
||||||
+ return (OPENSSL_VERSION_NUMBER >= '''
|
|
||||||
+ src += '(' + version[0] + ' >> 28)'
|
|
||||||
if 1 < len(version):
|
|
||||||
- src += ' && ' + version[1] + \
|
|
||||||
- '<= ((OPENSSL_VERSION_NUMBER >> 20) & 0xf)'
|
|
||||||
+ src += ' + (' + version[1] + ' >> 20)'
|
|
||||||
if 2 < len(version):
|
|
||||||
- src += ' && ' + version[2] + \
|
|
||||||
- '<= ((OPENSSL_VERSION_NUMBER >> 12) & 0xf)'
|
|
||||||
- src += ') ? 0 : 1;}\n'
|
|
||||||
+ src += ' + (' + version[2] + ' >> 12)'
|
|
||||||
+ src += ''') ? 0 : 1;
|
|
||||||
+ }
|
|
||||||
+ '''
|
|
||||||
|
|
||||||
ret = context.TryRun(src, '.cpp')[0]
|
|
||||||
|
|
||||||
--
|
|
||||||
2.26.2.672.g232c24e857
|
|
||||||
|
|
40
srcpkgs/cbang/patches/0002-OpenSSL-version-check.patch
Normal file
40
srcpkgs/cbang/patches/0002-OpenSSL-version-check.patch
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
From a25113c30d6ce2e04bb5bab517d109047947647b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Joseph Coffland <joseph@cauldrondevelopment.com>
|
||||||
|
Date: Sun, 31 May 2020 15:04:16 -0700
|
||||||
|
Subject: [PATCH 2/7] OpenSSL version check.
|
||||||
|
|
||||||
|
---
|
||||||
|
config/openssl/__init__.py | 17 ++++++++---------
|
||||||
|
1 file changed, 8 insertions(+), 9 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config/openssl/__init__.py b/config/openssl/__init__.py
|
||||||
|
index 421271cd..3b66738d 100644
|
||||||
|
--- a/config/openssl/__init__.py
|
||||||
|
+++ b/config/openssl/__init__.py
|
||||||
|
@@ -6,15 +6,14 @@ def check_version(context, version):
|
||||||
|
context.Message("Checking for openssl version >= %s..." % version)
|
||||||
|
|
||||||
|
version = version.split('.')
|
||||||
|
- src = '#include <openssl/opensslv.h>\nint main() {\nreturn ('
|
||||||
|
- src += version[0] + '<= (OPENSSL_VERSION_NUMBER >> 28)'
|
||||||
|
- if 1 < len(version):
|
||||||
|
- src += ' && ' + version[1] + \
|
||||||
|
- '<= ((OPENSSL_VERSION_NUMBER >> 20) & 0xf)'
|
||||||
|
- if 2 < len(version):
|
||||||
|
- src += ' && ' + version[2] + \
|
||||||
|
- '<= ((OPENSSL_VERSION_NUMBER >> 12) & 0xf)'
|
||||||
|
- src += ') ? 0 : 1;}\n'
|
||||||
|
+ src = '''
|
||||||
|
+ #include <openssl/opensslv.h>
|
||||||
|
+ int main() {
|
||||||
|
+ int v = (%s << 28) + (%s << 20) + (%s << 12);
|
||||||
|
+ return OPENSSL_VERSION_NUMBER < v;
|
||||||
|
+ }
|
||||||
|
+ ''' % (version[0], version[1] if 1 < len(version) else 0,
|
||||||
|
+ version[2] if 2 < len(version) else 0)
|
||||||
|
|
||||||
|
ret = context.TryRun(src, '.cpp')[0]
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0.rc1.5.gae92ac8ae3
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
From a2d81dfceb153d6388dcff63d8be1140cad7a33e Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
|
|
||||||
<congdanhqx@gmail.com>
|
|
||||||
Date: Sun, 17 May 2020 22:26:09 +0700
|
|
||||||
Subject: [PATCH 2/5] config/openssl: check OPENSSL_VERSION in compile time
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
All of required information are available at compile time, use compile
|
|
||||||
time check to support cross compiling.
|
|
||||||
|
|
||||||
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
|
|
||||||
---
|
|
||||||
config/openssl/__init__.py | 8 +++++---
|
|
||||||
1 file changed, 5 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git config/openssl/__init__.py config/openssl/__init__.py
|
|
||||||
index e0d3884a..580d72e7 100644
|
|
||||||
--- config/openssl/__init__.py
|
|
||||||
+++ config/openssl/__init__.py
|
|
||||||
@@ -9,17 +9,19 @@ def check_version(context, version):
|
|
||||||
src = '''
|
|
||||||
#include <openssl/opensslv.h>
|
|
||||||
int main() {
|
|
||||||
- return (OPENSSL_VERSION_NUMBER >= '''
|
|
||||||
+ int a[(OPENSSL_VERSION_NUMBER >= '''
|
|
||||||
src += '(' + version[0] + ' >> 28)'
|
|
||||||
if 1 < len(version):
|
|
||||||
src += ' + (' + version[1] + ' >> 20)'
|
|
||||||
if 2 < len(version):
|
|
||||||
src += ' + (' + version[2] + ' >> 12)'
|
|
||||||
- src += ''') ? 0 : 1;
|
|
||||||
+ src += ''')];
|
|
||||||
+ a[0] = 0;
|
|
||||||
+ return 0;
|
|
||||||
}
|
|
||||||
'''
|
|
||||||
|
|
||||||
- ret = context.TryRun(src, '.cpp')[0]
|
|
||||||
+ ret = context.TryCompile(src, '.cpp')
|
|
||||||
|
|
||||||
context.Result(ret)
|
|
||||||
return ret
|
|
||||||
--
|
|
||||||
2.26.2.672.g232c24e857
|
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
From 0e24962ff868340636be7a67d7c7e03d2c4dcf15 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
|
||||||
|
<congdanhqx@gmail.com>
|
||||||
|
Date: Sun, 17 May 2020 22:26:09 +0700
|
||||||
|
Subject: [PATCH 4/7] config/openssl: check OPENSSL_VERSION in compile time
|
||||||
|
|
||||||
|
All of required information are available at compile time, use compile
|
||||||
|
time check to support cross compiling.
|
||||||
|
---
|
||||||
|
config/openssl/__init__.py | 7 ++++---
|
||||||
|
1 file changed, 4 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config/openssl/__init__.py b/config/openssl/__init__.py
|
||||||
|
index 3b66738d..8ab89d9f 100644
|
||||||
|
--- a/config/openssl/__init__.py
|
||||||
|
+++ b/config/openssl/__init__.py
|
||||||
|
@@ -9,13 +9,14 @@ def check_version(context, version):
|
||||||
|
src = '''
|
||||||
|
#include <openssl/opensslv.h>
|
||||||
|
int main() {
|
||||||
|
- int v = (%s << 28) + (%s << 20) + (%s << 12);
|
||||||
|
- return OPENSSL_VERSION_NUMBER < v;
|
||||||
|
+ int array[1 - 2 * (OPENSSL_VERSION_NUMBER < (%s << 28) + (%s << 20) + (%s << 12))];
|
||||||
|
+ array[0] = 0;
|
||||||
|
+ return *array;
|
||||||
|
}
|
||||||
|
''' % (version[0], version[1] if 1 < len(version) else 0,
|
||||||
|
version[2] if 2 < len(version) else 0)
|
||||||
|
|
||||||
|
- ret = context.TryRun(src, '.cpp')[0]
|
||||||
|
+ ret = context.TryCompile(src, '.cpp')
|
||||||
|
|
||||||
|
context.Result(ret)
|
||||||
|
return ret
|
||||||
|
--
|
||||||
|
2.27.0.rc1.5.gae92ac8ae3
|
||||||
|
|
|
@ -1,23 +1,18 @@
|
||||||
From df79b8912f92083e7ef51353e762fa1c67b2593b Mon Sep 17 00:00:00 2001
|
From 062c1a54b295b4ff387ebdff84a6a957fccbefd4 Mon Sep 17 00:00:00 2001
|
||||||
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
|
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
|
||||||
<congdanhqx@gmail.com>
|
<congdanhqx@gmail.com>
|
||||||
Date: Sun, 17 May 2020 22:44:25 +0700
|
Date: Sun, 17 May 2020 22:44:25 +0700
|
||||||
Subject: [PATCH 3/5] libevent: use compile time sizeof check
|
Subject: [PATCH 5/7] libevent: use compile time sizeof check
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
Taken from https://github.com/scons/scons/wiki/AutoconfRecipes#ac_check_sizeof
|
Taken from https://github.com/scons/scons/wiki/AutoconfRecipes#ac_check_sizeof
|
||||||
|
|
||||||
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
|
|
||||||
---
|
---
|
||||||
src/libevent/SConscript | 81 +++++++++++++++++++++++++++++++++++++----
|
src/libevent/SConscript | 81 +++++++++++++++++++++++++++++++++++++----
|
||||||
1 file changed, 73 insertions(+), 8 deletions(-)
|
1 file changed, 73 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
diff --git src/libevent/SConscript src/libevent/SConscript
|
diff --git a/src/libevent/SConscript b/src/libevent/SConscript
|
||||||
index 89e770c1..2e8373f9 100644
|
index 1197b8d3..ab1f72ad 100644
|
||||||
--- src/libevent/SConscript
|
--- a/src/libevent/SConscript
|
||||||
+++ src/libevent/SConscript
|
+++ b/src/libevent/SConscript
|
||||||
@@ -18,22 +18,87 @@ conf.AddTest('CheckSYS_TIMERFD_H', CheckSYS_TIMERFD_H)
|
@@ -18,22 +18,87 @@ conf.AddTest('CheckSYS_TIMERFD_H', CheckSYS_TIMERFD_H)
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,5 +110,5 @@ index 89e770c1..2e8373f9 100644
|
||||||
conf.AddTest('CheckSizeOf', CheckSizeOf)
|
conf.AddTest('CheckSizeOf', CheckSizeOf)
|
||||||
|
|
||||||
--
|
--
|
||||||
2.26.2.672.g232c24e857
|
2.27.0.rc1.5.gae92ac8ae3
|
||||||
|
|
|
@ -0,0 +1,169 @@
|
||||||
|
From d9b5bf87e724bfbbad78fe254e902048f8d7e534 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Joseph Coffland <joseph@cauldrondevelopment.com>
|
||||||
|
Date: Mon, 1 Jun 2020 14:55:52 -0700
|
||||||
|
Subject: [PATCH 6/7] Fixes and clean up of sizeof test
|
||||||
|
|
||||||
|
---
|
||||||
|
src/libevent/SConscript | 115 ++++++++++------------------------------
|
||||||
|
1 file changed, 28 insertions(+), 87 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/libevent/SConscript b/src/libevent/SConscript
|
||||||
|
index ab1f72ad..db9884a6 100644
|
||||||
|
--- a/src/libevent/SConscript
|
||||||
|
+++ b/src/libevent/SConscript
|
||||||
|
@@ -17,88 +17,25 @@ def CheckSYS_TIMERFD_H(ctx):
|
||||||
|
conf.AddTest('CheckSYS_TIMERFD_H', CheckSYS_TIMERFD_H)
|
||||||
|
|
||||||
|
|
||||||
|
-# sizeof
|
||||||
|
-# https://github.com/scons/scons/wiki/AutoconfRecipes#ac_check_sizeof
|
||||||
|
-# Sensible default for common types on common platforms.
|
||||||
|
-_DEFAULTS_SIZEOF = {
|
||||||
|
- 'short' : [2],
|
||||||
|
- 'int' : [4, 2],
|
||||||
|
- 'long' : [4, 8],
|
||||||
|
- 'long long' : [8, 4],
|
||||||
|
- 'unsigned short' : [2],
|
||||||
|
- 'unsigned int' : [4, 2],
|
||||||
|
- 'unsigned long' : [4, 8],
|
||||||
|
- 'unsigned long long' : [8, 4],
|
||||||
|
- 'float' : [4],
|
||||||
|
- 'double' : [8],
|
||||||
|
- 'long double' : [12],
|
||||||
|
- 'size_t' : [4, 8],
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-def CheckSizeOf(ctx, type, includes = None):
|
||||||
|
- """This check can be used to get the size of a given type,
|
||||||
|
- or to check whether the type is of expected size.
|
||||||
|
-
|
||||||
|
- Arguments:
|
||||||
|
- - type : str
|
||||||
|
- the type to check
|
||||||
|
- - includes : sequence
|
||||||
|
- list of headers to include in the test code before testing the type
|
||||||
|
- Returns:
|
||||||
|
- status : int
|
||||||
|
- 0 if the check failed, or the found size of the type
|
||||||
|
- if the check succeeded."""
|
||||||
|
- minsz = 0
|
||||||
|
- maxsz = 16
|
||||||
|
-
|
||||||
|
+def CheckSizeOf(ctx, type, defaults, includes = None):
|
||||||
|
src = '''
|
||||||
|
- #include <sys/types.h>
|
||||||
|
- #include <stdlib.h>
|
||||||
|
- #include <stdio.h>
|
||||||
|
- #include <stdint.h>
|
||||||
|
+ int main() {
|
||||||
|
+ int a[1 - 2 * (sizeof(%s) != %d)];
|
||||||
|
+ return a[0] = 0;
|
||||||
|
+ }
|
||||||
|
'''
|
||||||
|
- if includes:
|
||||||
|
- src += "\n".join("#include <%s>\n" % i for i in includes)
|
||||||
|
-
|
||||||
|
- ext = '.c'
|
||||||
|
- # test code taken from autoconf: this is a pretty clever hack to find that
|
||||||
|
- # a type is of a given size using only compilation. This speeds things up
|
||||||
|
- # quite a bit compared to straightforward code using TryRun
|
||||||
|
- src += r"""
|
||||||
|
-typedef %s scons_check_type;
|
||||||
|
-
|
||||||
|
-int main()
|
||||||
|
-{
|
||||||
|
- static int test_array[1 - 2 * ((long int) sizeof(scons_check_type) > %d)];
|
||||||
|
- test_array[0] = 0;
|
||||||
|
|
||||||
|
- return 0;
|
||||||
|
-}
|
||||||
|
-"""
|
||||||
|
+ if includes:
|
||||||
|
+ src = '\n'.join('#include <%s>' % i for i in includes) + '\n' + src
|
||||||
|
|
||||||
|
- # Only check if the given size is the right one
|
||||||
|
ctx.Message('Checking size of %s ... ' % type)
|
||||||
|
|
||||||
|
- # Try sensible defaults first
|
||||||
|
- try:
|
||||||
|
- szrange = _DEFAULTS_SIZEOF[type]
|
||||||
|
- except KeyError:
|
||||||
|
- szrange = []
|
||||||
|
- szrange.extend(range(minsz, maxsz))
|
||||||
|
- st = 0
|
||||||
|
-
|
||||||
|
- # Actual test
|
||||||
|
- for sz in szrange:
|
||||||
|
- st = ctx.TryCompile(src % (type, sz), ext)
|
||||||
|
- if st:
|
||||||
|
- break
|
||||||
|
-
|
||||||
|
- if st:
|
||||||
|
- ctx.Result('%d' % sz)
|
||||||
|
- return sz
|
||||||
|
- else:
|
||||||
|
- ctx.Result('Failed !')
|
||||||
|
- return 0
|
||||||
|
+ for sz in defaults + range(1, 16):
|
||||||
|
+ if ctx.TryCompile(src % (type, sz), '.c'):
|
||||||
|
+ ctx.Result(str(sz))
|
||||||
|
+ return sz
|
||||||
|
+
|
||||||
|
+ raise Exception('Failed to get the sizeof of ' + type)
|
||||||
|
|
||||||
|
conf.AddTest('CheckSizeOf', CheckSizeOf)
|
||||||
|
|
||||||
|
@@ -209,7 +146,17 @@ headers = '''arpa/inet.h fcntl.h ifaddrs.h inttypes.h mach/mach_time.h
|
||||||
|
'''
|
||||||
|
decls = '''CTL_KERN KERN_ARND KERN_RANDOM RANDOM_UUID'''
|
||||||
|
structs = 'addrinfo in6_addr sockaddr_in6 sockaddr_storage'
|
||||||
|
-sizeof = ['int', 'long', 'long long', 'off_t', 'short', 'size_t', 'void *']
|
||||||
|
+
|
||||||
|
+sizeof = [
|
||||||
|
+ ('short', [2], None),
|
||||||
|
+ ('int', [4, 2], None),
|
||||||
|
+ ('long', [8, 4], None),
|
||||||
|
+ ('long long', [8, 4], None),
|
||||||
|
+ ('void *', [8, 4], None),
|
||||||
|
+ ('size_t', [8, 4], ['sys/types.h']),
|
||||||
|
+ ('off_t', [8, 4], ['sys/types.h']),
|
||||||
|
+ ('pthread_t', [8, 4], ['pthread.h']),
|
||||||
|
+]
|
||||||
|
|
||||||
|
gethostbyname_r_3_arg_src = '''
|
||||||
|
#ifndef __cplusplus
|
||||||
|
@@ -284,13 +231,9 @@ def get_event_config_defs():
|
||||||
|
|
||||||
|
|
||||||
|
# Sizes
|
||||||
|
- for type in sizeof:
|
||||||
|
- size = conf.CheckSizeOf(type)
|
||||||
|
- if size:
|
||||||
|
- defs['SIZEOF_' + to_def(type)] = size
|
||||||
|
-
|
||||||
|
- size = conf.CheckSizeOf('pthread_t', ['pthread.h'])
|
||||||
|
- if size: defs['SIZEOF_PTHREAD_T'] = size
|
||||||
|
+ for type, defaults, includes in sizeof:
|
||||||
|
+ size = conf.CheckSizeOf(type, defaults, includes)
|
||||||
|
+ defs['SIZEOF_' + to_def(type)] = size
|
||||||
|
|
||||||
|
|
||||||
|
# Decls
|
||||||
|
@@ -380,13 +323,11 @@ def build_function(target, source, env):
|
||||||
|
|
||||||
|
f = open(target, 'w')
|
||||||
|
|
||||||
|
- f.write('#ifndef EVENT2_EVENT_CONFIG_H_INCLUDED_\n')
|
||||||
|
- f.write('#define EVENT2_EVENT_CONFIG_H_INCLUDED_\n')
|
||||||
|
+ f.write('#pragma once\n')
|
||||||
|
|
||||||
|
for name, value in sorted(defs.items()):
|
||||||
|
f.write('#define EVENT__%s %s\n' % (name, value))
|
||||||
|
|
||||||
|
- f.write('#endif /* EVENT2_EVENT_CONFIG_H_INCLUDED_ */\n')
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0.rc1.5.gae92ac8ae3
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Template file for 'cbang'
|
# Template file for 'cbang'
|
||||||
pkgname=cbang
|
pkgname=cbang
|
||||||
version=1.5.0
|
version=1.5.0
|
||||||
revision=1
|
revision=2
|
||||||
build_style=scons
|
build_style=scons
|
||||||
make_build_args="sharedlib=1 staticlib=1"
|
make_build_args="sharedlib=1 staticlib=1"
|
||||||
make_install_args="${make_build_args}"
|
make_install_args="${make_build_args}"
|
||||||
|
|
Loading…
Reference in a new issue