Github messages for voidlinux
 help / color / Atom feed
* [PR PATCH] cbang: cherry-pick cross-compile patch from upstream.
@ 2020-06-02  0:58 sgn
  0 siblings, 0 replies; only message in thread
From: sgn @ 2020-06-02  0:58 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 409 bytes --]

There is a new pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages cbang-fix-sizeof-long
https://github.com/void-linux/void-packages/pull/22508

cbang: cherry-pick cross-compile patch from upstream.
The old patch has a bug with sizeof(long) on 32-bit platform.



A patch file from https://github.com/void-linux/void-packages/pull/22508.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-cbang-fix-sizeof-long-22508.patch --]
[-- Type: text/x-diff, Size: 16498 bytes --]

From 5179ad766f006771c3d540b0dcf6f54dde14adba 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: Tue, 2 Jun 2020 07:52:12 +0700
Subject: [PATCH] cbang: cherry-pick cross-compile patch from upstream.

The old patch has a bug with sizeof(long) on 32-bit platform.
---
 ...config-openssl-correct-version-check.patch |  52 ------
 .../patches/0002-OpenSSL-version-check.patch  |  40 +++++
 ...heck-OPENSSL_VERSION-in-compile-time.patch |  47 -----
 ...heck-OPENSSL_VERSION-in-compile-time.patch |  37 ++++
 ...event-use-compile-time-sizeof-check.patch} |  19 +-
 ...06-Fixes-and-clean-up-of-sizeof-test.patch | 169 ++++++++++++++++++
 srcpkgs/cbang/template                        |   2 +-
 7 files changed, 254 insertions(+), 112 deletions(-)
 delete mode 100644 srcpkgs/cbang/patches/0001-config-openssl-correct-version-check.patch
 create mode 100644 srcpkgs/cbang/patches/0002-OpenSSL-version-check.patch
 delete mode 100644 srcpkgs/cbang/patches/0002-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch
 create mode 100644 srcpkgs/cbang/patches/0004-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch
 rename srcpkgs/cbang/patches/{0003-libevent-use-compile-time-sizeof-check.patch => 0005-libevent-use-compile-time-sizeof-check.patch} (87%)
 create mode 100644 srcpkgs/cbang/patches/0006-Fixes-and-clean-up-of-sizeof-test.patch

diff --git a/srcpkgs/cbang/patches/0001-config-openssl-correct-version-check.patch b/srcpkgs/cbang/patches/0001-config-openssl-correct-version-check.patch
deleted file mode 100644
index a89fccb494e..00000000000
--- a/srcpkgs/cbang/patches/0001-config-openssl-correct-version-check.patch
+++ /dev/null
@@ -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
-
diff --git a/srcpkgs/cbang/patches/0002-OpenSSL-version-check.patch b/srcpkgs/cbang/patches/0002-OpenSSL-version-check.patch
new file mode 100644
index 00000000000..144753e5db7
--- /dev/null
+++ b/srcpkgs/cbang/patches/0002-OpenSSL-version-check.patch
@@ -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
+
diff --git a/srcpkgs/cbang/patches/0002-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch b/srcpkgs/cbang/patches/0002-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch
deleted file mode 100644
index df857d8ab2f..00000000000
--- a/srcpkgs/cbang/patches/0002-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch
+++ /dev/null
@@ -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
-
diff --git a/srcpkgs/cbang/patches/0004-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch b/srcpkgs/cbang/patches/0004-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch
new file mode 100644
index 00000000000..a6ae9127a93
--- /dev/null
+++ b/srcpkgs/cbang/patches/0004-config-openssl-check-OPENSSL_VERSION-in-compile-time.patch
@@ -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
+
diff --git a/srcpkgs/cbang/patches/0003-libevent-use-compile-time-sizeof-check.patch b/srcpkgs/cbang/patches/0005-libevent-use-compile-time-sizeof-check.patch
similarity index 87%
rename from srcpkgs/cbang/patches/0003-libevent-use-compile-time-sizeof-check.patch
rename to srcpkgs/cbang/patches/0005-libevent-use-compile-time-sizeof-check.patch
index 32254f0bbf5..68094f326ef 100644
--- a/srcpkgs/cbang/patches/0003-libevent-use-compile-time-sizeof-check.patch
+++ b/srcpkgs/cbang/patches/0005-libevent-use-compile-time-sizeof-check.patch
@@ -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?=
  <congdanhqx@gmail.com>
 Date: Sun, 17 May 2020 22:44:25 +0700
-Subject: [PATCH 3/5] libevent: use compile time sizeof check
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
+Subject: [PATCH 5/7] libevent: use compile time sizeof check
 
 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 +++++++++++++++++++++++++++++++++++++----
  1 file changed, 73 insertions(+), 8 deletions(-)
 
-diff --git src/libevent/SConscript src/libevent/SConscript
-index 89e770c1..2e8373f9 100644
---- src/libevent/SConscript
-+++ src/libevent/SConscript
+diff --git a/src/libevent/SConscript b/src/libevent/SConscript
+index 1197b8d3..ab1f72ad 100644
+--- a/src/libevent/SConscript
++++ b/src/libevent/SConscript
 @@ -18,22 +18,87 @@ conf.AddTest('CheckSYS_TIMERFD_H', CheckSYS_TIMERFD_H)
  
  
@@ -115,5 +110,5 @@ index 89e770c1..2e8373f9 100644
  conf.AddTest('CheckSizeOf', CheckSizeOf)
  
 -- 
-2.26.2.672.g232c24e857
+2.27.0.rc1.5.gae92ac8ae3
 
diff --git a/srcpkgs/cbang/patches/0006-Fixes-and-clean-up-of-sizeof-test.patch b/srcpkgs/cbang/patches/0006-Fixes-and-clean-up-of-sizeof-test.patch
new file mode 100644
index 00000000000..9ca934e1139
--- /dev/null
+++ b/srcpkgs/cbang/patches/0006-Fixes-and-clean-up-of-sizeof-test.patch
@@ -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
+
diff --git a/srcpkgs/cbang/template b/srcpkgs/cbang/template
index 4446b5acf08..5616cbfce2b 100644
--- a/srcpkgs/cbang/template
+++ b/srcpkgs/cbang/template
@@ -1,7 +1,7 @@
 # Template file for 'cbang'
 pkgname=cbang
 version=1.5.0
-revision=1
+revision=2
 build_style=scons
 make_build_args="sharedlib=1 staticlib=1"
 make_install_args="${make_build_args}"

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02  0:58 [PR PATCH] cbang: cherry-pick cross-compile patch from upstream sgn

Github messages for voidlinux

Archives are clonable: git clone --mirror http://inbox.vuxu.org/voidlinux-github

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.github.voidlinux


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git