From fd5592d05d5db9aef8017ac29e178c13dce435ee Mon Sep 17 00:00:00 2001 From: "Stuart D. Gathman" Date: Thu, 31 May 2018 11:04:56 -0400 Subject: [PATCH 1/5] Add cnacl s390x support BZ#1584480 --- cjdns.s390x.patch | 182 ++++++++++++++++++++++++++++++++++++++++++++++ cjdns.spec | 10 ++- 2 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 cjdns.s390x.patch diff --git a/cjdns.s390x.patch b/cjdns.s390x.patch new file mode 100644 index 0000000..ef9b11f --- /dev/null +++ b/cjdns.s390x.patch @@ -0,0 +1,182 @@ +--- cjdns-cjdns-v20.2/node_build/dependencies/cnacl/cpucycles/osfreq.c.s390x 2018-05-31 12:03:56.321045469 +0200 ++++ cjdns-cjdns-v20.2/node_build/dependencies/cnacl/cpucycles/osfreq.c 2018-05-31 12:04:07.901045469 +0200 +@@ -33,6 +33,18 @@ static double osfreq(void) + f = fopen("/proc/cpuinfo","r"); + if (f) { + for (;;) { ++ s = fscanf(f,"cpu MHz dynamic : %lf",&result); ++ if (s > 0) break; ++ if (s == 0) s = fscanf(f,"%*[^\n]\n"); ++ if (s < 0) { result = 0; break; } ++ } ++ fclose(f); ++ if (result) return 1000000.0 * result; ++ } ++ ++ f = fopen("/proc/cpuinfo","r"); ++ if (f) { ++ for (;;) { + s = fscanf(f,"clock : %lf",&result); + if (s > 0) break; + if (s == 0) s = fscanf(f,"%*[^\n]\n"); +--- cjdns-cjdns-v20.2/node_build/dependencies/cnacl/do.s390x 2018-04-18 09:35:41.000000000 +0200 ++++ cjdns-cjdns-v20.2/node_build/dependencies/cnacl/do 2018-05-31 11:56:41.881045469 +0200 +@@ -418,7 +418,7 @@ echo "=== `date` === starting curvecp" + + okabi \ + | awk ' +- { if ($1=="amd64" || $1=="ia64" || $1=="ppc64" || $1=="sparcv9" || $1=="mips64") print 1,$1 ++ { if ($1=="amd64" || $1=="ia64" || $1=="ppc64" || $1=="sparcv9" || $1=="mips64" || $1=="s390x") print 1,$1 + else if ($1 == "mips32") print 2,$1 + else print 3,$1 + } +--- cjdns-cjdns-v20.2/node_build/dependencies/cnacl/node_build/plans/s390x_plan.json.s390x 2018-05-31 11:56:41.881045469 +0200 ++++ cjdns-cjdns-v20.2/node_build/dependencies/cnacl/node_build/plans/s390x_plan.json 2018-05-31 11:56:41.881045469 +0200 +@@ -0,0 +1,124 @@ ++{ ++ "PLAN_IMPLEMENTATIONS": [ ++ [ ++ "crypto_sign", ++ "ed25519", ++ "ref10" ++ ], ++ [ ++ "crypto_stream", ++ "aes128ctr", ++ "portable" ++ ], ++ [ ++ "crypto_auth", ++ "hmacsha256", ++ "ref" ++ ], ++ [ ++ "crypto_core", ++ "hsalsa20", ++ "ref" ++ ], ++ [ ++ "crypto_scalarmult", ++ "curve25519", ++ "ref" ++ ], ++ [ ++ "crypto_core", ++ "salsa20", ++ "ref" ++ ], ++ [ ++ "crypto_verify", ++ "16", ++ "ref" ++ ], ++ [ ++ "crypto_onetimeauth", ++ "poly1305", ++ "donna" ++ ], ++ [ ++ "crypto_core", ++ "salsa208", ++ "ref" ++ ], ++ [ ++ "crypto_hashblocks", ++ "sha512", ++ "inplace" ++ ], ++ [ ++ "crypto_stream", ++ "salsa2012", ++ "ref" ++ ], ++ [ ++ "crypto_stream", ++ "xsalsa20", ++ "ref" ++ ], ++ [ ++ "crypto_secretbox", ++ "xsalsa20poly1305", ++ "ref" ++ ], ++ [ ++ "crypto_core", ++ "salsa2012", ++ "ref" ++ ], ++ [ ++ "crypto_verify", ++ "32", ++ "ref" ++ ], ++ [ ++ "crypto_stream", ++ "salsa208", ++ "ref" ++ ], ++ [ ++ "crypto_hash", ++ "sha256", ++ "ref" ++ ], ++ [ ++ "crypto_hashblocks", ++ "sha256", ++ "ref" ++ ], ++ [ ++ "crypto_hash", ++ "sha512", ++ "ref" ++ ], ++ [ ++ "crypto_box", ++ "curve25519xsalsa20poly1305", ++ "ref" ++ ], ++ [ ++ "crypto_auth", ++ "hmacsha512256", ++ "ref" ++ ], ++ [ ++ "crypto_stream", ++ "salsa20", ++ "ref" ++ ] ++ ], ++ "PLAN_TYPES": [ ++ "typedef short crypto_int16;", ++ "typedef unsigned int crypto_uint32;", ++ "typedef unsigned short crypto_uint16;", ++ "typedef long long crypto_int64;", ++ "typedef int crypto_int32;", ++ "typedef unsigned char crypto_uint8;", ++ "typedef signed char crypto_int8;", ++ "typedef unsigned long long crypto_uint64;" ++ ] ++} +--- cjdns-cjdns-v20.2/node_build/dependencies/cnacl/okcompilers/abiname.c.s390x 2018-04-18 09:35:41.000000000 +0200 ++++ cjdns-cjdns-v20.2/node_build/dependencies/cnacl/okcompilers/abiname.c 2018-05-31 11:56:41.881045469 +0200 +@@ -14,6 +14,8 @@ const char *abi(void) + return "ppc64"; + #elif defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) || defined(_ARCH_PPC) + return "ppc32"; ++#elif defined(__s390x__) ++ return "s390x" + #elif defined(__sparcv9__) || defined(__sparcv9) + return "sparcv9"; + #elif defined(__sparc_v8__) +--- cjdns-cjdns-v20.2/node_build/dependencies/cnacl/okcompilers/abiname_xcompile.c.s390x 2018-04-18 09:35:41.000000000 +0200 ++++ cjdns-cjdns-v20.2/node_build/dependencies/cnacl/okcompilers/abiname_xcompile.c 2018-05-31 11:56:41.881045469 +0200 +@@ -20,6 +20,8 @@ + #error ABI_IS_ppc64__ + #elif defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) || defined(_ARCH_PPC) + #error ABI_IS_ppc32__ ++#elif defined(__s390x__) ++ #error ABI_IS_s390x__ + #elif defined(__sparcv9__) || defined(__sparcv9) + #error ABI_IS_sparcv9__ + #elif defined(__sparc_v8__) + diff --git a/cjdns.spec b/cjdns.spec index c16ae03..b59487b 100644 --- a/cjdns.spec +++ b/cjdns.spec @@ -50,7 +50,7 @@ Name: cjdns # major version is cjdns protocol version: Version: 20.2 -Release: 1%{?dist} +Release: 2%{?dist} Summary: The privacy-friendly network without borders Group: System Environment/Base # cjdns is all GPLv3 except libuv which is MIT and BSD and ISC @@ -108,6 +108,8 @@ Patch12: cjdns.sign.patch #Patch15: cjdns.benc.patch # Specify python2 for systems that default to python3 Patch16: cjdns.python3.patch +# s390x support for embedded cnacl library from Dan HorĂ¡k +Patch17: cjdns.s390x.patch BuildRequires: nodejs, nodejs-ronn, python2 @@ -133,7 +135,7 @@ Provides: bundled(nacl) = 20110221 %endif # build system requires nodejs, unfortunately ExclusiveArch: %{nodejs_arches} -%if 0%{use_embedded} +%if 0 && 0%{use_embedded} # The nodejs build system for embedded cnacl has no "plan" for s390x. # It might work to copy another big endian plan like ppc64. ExcludeArch: s390x @@ -236,6 +238,7 @@ fi #patch14 -b .entropy #patch15 -b .benc %patch16 -b .python3 +%patch17 -p1 -b .s390x cp %{SOURCE1} README_Fedora.md @@ -542,6 +545,9 @@ fi %{_bindir}/graphStats %changelog +* Thu May 31 2018 Stuart Gathman - 20.2-2 +- Add cnacl s390x support BZ#1584480 + * Tue May 22 2018 Stuart Gathman - 20.2-1 - New upstream release BZ#1464671 From 4fcbbff9e28a06c88d8b72c34c659c343998ca5e Mon Sep 17 00:00:00 2001 From: "Stuart D. Gathman" Date: Thu, 28 Jun 2018 13:01:36 -0400 Subject: [PATCH 2/5] Update bundled libuv version to 0.11.19 --- cjdns.spec | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cjdns.spec b/cjdns.spec index b59487b..ac2548d 100644 --- a/cjdns.spec +++ b/cjdns.spec @@ -50,7 +50,7 @@ Name: cjdns # major version is cjdns protocol version: Version: 20.2 -Release: 2%{?dist} +Release: 3%{?dist} Summary: The privacy-friendly network without borders Group: System Environment/Base # cjdns is all GPLv3 except libuv which is MIT and BSD and ISC @@ -129,17 +129,12 @@ Requires(preun): systemd Requires(postun): systemd %endif Requires(pre): shadow-utils -Provides: bundled(libuv) = 0.11.4 +Provides: bundled(libuv) = 0.11.19 %if 0%{use_embedded} Provides: bundled(nacl) = 20110221 %endif # build system requires nodejs, unfortunately ExclusiveArch: %{nodejs_arches} -%if 0 && 0%{use_embedded} -# The nodejs build system for embedded cnacl has no "plan" for s390x. -# It might work to copy another big endian plan like ppc64. -ExcludeArch: s390x -%endif %description Cjdns implements an encrypted IPv6 network using public-key cryptography for @@ -545,6 +540,9 @@ fi %{_bindir}/graphStats %changelog +* Fri Jun 22 2018 Stuart Gathman - 20.2-3 +- cjdns-20.2 bundles libuv-0.11.19 + * Thu May 31 2018 Stuart Gathman - 20.2-2 - Add cnacl s390x support BZ#1584480 From ff6110692a9f9224fdc00d4b2cdb8ff3df0da3c7 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 12 Jul 2018 21:48:27 +0000 Subject: [PATCH 3/5] - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- cjdns.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cjdns.spec b/cjdns.spec index b59487b..bedd2bb 100644 --- a/cjdns.spec +++ b/cjdns.spec @@ -50,7 +50,7 @@ Name: cjdns # major version is cjdns protocol version: Version: 20.2 -Release: 2%{?dist} +Release: 3%{?dist} Summary: The privacy-friendly network without borders Group: System Environment/Base # cjdns is all GPLv3 except libuv which is MIT and BSD and ISC @@ -545,6 +545,9 @@ fi %{_bindir}/graphStats %changelog +* Thu Jul 12 2018 Fedora Release Engineering - 20.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + * Thu May 31 2018 Stuart Gathman - 20.2-2 - Add cnacl s390x support BZ#1584480 From 9da2f5d98614bc560e66208453552515fc81b971 Mon Sep 17 00:00:00 2001 From: "Stuart D. Gathman" Date: Wed, 18 Jul 2018 18:26:00 -0400 Subject: [PATCH 4/5] Remove CPU specific optimizations for generic build. --- cjdns.dyn.patch | 16 ++++++++++------ cjdns.spec | 45 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/cjdns.dyn.patch b/cjdns.dyn.patch index 9dc22e0..666bd32 100644 --- a/cjdns.dyn.patch +++ b/cjdns.dyn.patch @@ -1,7 +1,7 @@ diff -up ./node_build/make.js.dyn ./node_build/make.js ---- ./node_build/make.js.dyn 2016-10-11 17:39:44.000000000 -0400 -+++ ./node_build/make.js 2016-10-14 22:08:23.018241766 -0400 -@@ -252,44 +252,9 @@ Builder.configure({ +--- ./node_build/make.js.dyn 2018-04-18 03:35:41.000000000 -0400 ++++ ./node_build/make.js 2018-06-28 13:50:51.922657841 -0400 +@@ -256,48 +256,9 @@ Builder.configure({ }).nThen(function (waitFor) { @@ -26,13 +26,17 @@ diff -up ./node_build/make.js.dyn ./node_build/make.js - - args.unshift(builder.config.optimizeLevel, '-fomit-frame-pointer'); - +- if (!/^\-O0$/.test(builder.config.optimizeLevel)) { +- args.unshift('-D_FORTIFY_SOURCE=2'); +- } +- - if (CFLAGS) { - [].push.apply(args, CFLAGS.split(' ')); - } - - if (!builder.config.crossCompiling) { -- if (NO_MARCH_FLAG.indexOf(process.arch) < -1) { -- builder.config.cflags.push('-march=native'); +- if (NO_MARCH_FLAG.indexOf(process.arch) == -1) { +- args.unshift('-march=native'); - } - } - @@ -49,7 +53,7 @@ diff -up ./node_build/make.js.dyn ./node_build/make.js }).nThen(function (waitFor) { -@@ -430,7 +395,7 @@ Builder.configure({ +@@ -442,7 +403,7 @@ Builder.configure({ builder.buildExecutable('crypto/random/randombytes.c'); builder.lintFiles(function (fileName, file, callback) { diff --git a/cjdns.spec b/cjdns.spec index 1858592..7b43a72 100644 --- a/cjdns.spec +++ b/cjdns.spec @@ -2,25 +2,40 @@ # Fedora review: http://bugzilla.redhat.com/1268716 # Option to enable SUBNODE mode (WIP) +# Fedora generally runs on systems that easily support a full node %bcond_with subnode # Option to use the optimized libnacl embedded with cjdns +# Required since v20 due to use of private cnacl APIs %bcond_without embedded +# Option to enable CPU specific optimization +# Default to generic for distro builds +%bcond_without generic +# Option to use libsodium instead of nacl (broken since v20) +%bcond_with libsodium +# Option to disable SECCOMP: confusing backward logic +# Needed to run on openvz and other container systems +%bcond_without seccomp -%if %{with subnode} || %{with embedded} + +%if %{with embedded} %global use_embedded 1 %else %global use_embedded 0 %endif -# Use libsodium instead of nacl -%global use_libsodium 1 -# Option to disable SECCOMP: confusing backward logic -%bcond_without seccomp -%if 0%{use_libsodium} +%if %{with generic} +%global generic_build 1 +%else +%global generic_build 0 +%endif + +%if %{with libsodium} +%global use_libsodium 1 %global nacl_name libsodium %global nacl_version 1.0.14 %global nacl_lib %{_libdir}/libsodium.so %else +%global use_libsodium 0 %global nacl_name nacl %global nacl_version 20110221 %global nacl_lib %{_libdir}/libnacl.so @@ -50,7 +65,7 @@ Name: cjdns # major version is cjdns protocol version: Version: 20.2 -Release: 3%{?dist} +Release: 4%{?dist} Summary: The privacy-friendly network without borders Group: System Environment/Base # cjdns is all GPLv3 except libuv which is MIT and BSD and ISC @@ -116,7 +131,7 @@ BuildRequires: nodejs, nodejs-ronn, python2 # Automated package review hates explicit BR on make, but it *is* needed BuildRequires: make -%if !%{use_embedded} +%if !0%{use_embedded} # x86_64 and ARM libnacl are not compiled with -fPIC before Fedora release 11. BuildRequires: %{nacl_name}-devel >= %{nacl_version} %endif @@ -202,7 +217,9 @@ Python graphing tools for cjdns. cp %{SOURCE2} contrib/systemd -%if !%{use_embedded} +%if 0%{use_embedded} +# disable CPU opt +%else !use_embedded # use system nacl library if provided. if test -x %{nacl_lib}; then %if 0%{use_libsodium} @@ -233,7 +250,9 @@ fi #patch14 -b .entropy #patch15 -b .benc %patch16 -b .python3 +%if 0%{use_embedded} %patch17 -p1 -b .s390x +%endif cp %{SOURCE1} README_Fedora.md @@ -269,6 +288,14 @@ EOF chmod a+x cjdns-up.sh +%if %{generic_build} +sed -i -e 's/-march=native/-mtune=generic/' node_build/make.js +rm node_build/dependencies/cnacl/node_build/plans/*_AVX_plan.json +# Leaving SSE2 code in since x86 is secondary arch and pretty much everyone +# is going to have SSE2, except things like XO-1 which needs custom build. +#rm node_build/dependencies/cnacl/node_build/plans/x86_SSE2_plan.json +%endif + # FIXME: grep Version_CURRENT_PROTOCOL util/version/Version.h and # check that it matches major %%{version} From 7b61aa8ff0f85f96ecc17c25a5f1f418dd476016 Mon Sep 17 00:00:00 2001 From: "Stuart D. Gathman" Date: Wed, 18 Jul 2018 18:32:34 -0400 Subject: [PATCH 5/5] f29 requires explicit gcc Build dependency. --- cjdns.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cjdns.spec b/cjdns.spec index 7b43a72..4d1b86a 100644 --- a/cjdns.spec +++ b/cjdns.spec @@ -129,7 +129,7 @@ Patch17: cjdns.s390x.patch BuildRequires: nodejs, nodejs-ronn, python2 # Automated package review hates explicit BR on make, but it *is* needed -BuildRequires: make +BuildRequires: make gcc %if !0%{use_embedded} # x86_64 and ARM libnacl are not compiled with -fPIC before Fedora release 11.