Subject: Re: [bug#32095] [PATCH 2/2] gnu: node: Update to 10.6.0.

From: Marius Bakke <[email-masked]>
Date: Sun, 23 Sep 2018 15:22:37 +0200

Mathieu Lirzin <[email-masked]> writes:

> Marius Bakke <[email-masked]> writes:
>
>> We already have the latest libuv on 'core-updates'.
>
> Indeed, I forgot to prune old branches and get confused.
>
>>  I wanted to push
>> this patch to master actually (with a libuv-1.23 package), but node does
>> not work with OpenSSL 1.1.1:
>> <https://github.com/nodejs/node/issues/18770>.
>
> I have read rapidly this thread.
>
> IIRC the build for node 10.xx was failing with ‘openssl’ which was the
> reason of upgrading to ‘openssl-next’ and this issue seems to imply that
> node fails to run with ‘openssl-next’?  Is that correct?
>
> Have you recently tried to compile ‘node’ with libuv-1.23 without
> upgrading the “openssl” input?  How did it work?

Building Node 10.11.0 with [email-masked] results in...

g++ '-DNODE_ARCH="x64"' '-DNODE_PLATFORM="linux"' '-DNODE_WANT_INTERNALS=1' '-DV8_DEPRECATION_WARNINGS=1' '-DNODE_OPENSSL_SYSTEM_CERT_PATH=""' '-DHAVE_INSPECTOR=1' '-D__POSIX__' '-DNODE_USE_V8_PLATFORM=1' '-DNODE_HAVE_I18N_SUPPORT=1' '-DHAVE_OPENSSL=1' -I../src -I/tmp/guix-build-node-10.11.0.drv-0/node-v10.11.0/out/Release/obj/gen -I/tmp/guix-build-node-10.11.0.drv-0/node-v10.11.0/out/Release/obj/gen/include -I/tmp/guix-build-node-10.11.0.drv-0/node-v10.11.0/out/Release/obj/gen/src -I../deps/v8/include  -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++1y -MMD -MF /tmp/guix-build-node-10.11.0.drv-0/node-v10.11.0/out/Release/.deps//tmp/guix-build-node-10.11.0.drv-0/node-v10.11.0/out/Release/obj.target/node_lib/src/node.o.d.raw   -c -o /tmp/guix-build-node-10.11.0.drv-0/node-v10.11.0/out/Release/obj.target/node_lib/src/node.o ../src/node.cc
In file included from ../src/node.cc:39:0:
../src/node_crypto.h:82:46: error: ‘EVP_MD_CTX_free’ was not declared in this scope
 using EVPMDPointer = DeleteFnPtr<EVP_MD_CTX, EVP_MD_CTX_free>;                                                                                                                                                                                      ^
../src/node_crypto.h:82:61: error: template argument 2 is invalid
 using EVPMDPointer = DeleteFnPtr<EVP_MD_CTX, EVP_MD_CTX_free>;
                                                             ^
../src/node_crypto.h:454:25: error: ‘HMAC_CTX_free’ was not declared in this scope
   DeleteFnPtr<HMAC_CTX, HMAC_CTX_free> ctx_;
                         ^
../src/node_crypto.h:454:38: error: template argument 2 is invalid
   DeleteFnPtr<HMAC_CTX, HMAC_CTX_free> ctx_;
                                      ^
../src/node_crypto.h: In constructor ‘node::crypto::Hmac::Hmac(node::Environment*, v8::Local<v8::Object>)’:
../src/node_crypto.h:449:21: error: cannot convert ‘std::nullptr_t’ to ‘int’ in initialization
         ctx_(nullptr) {
                     ^
../src/node_crypto.h: At global scope:
../src/node_crypto.h:483:3: error: ‘EVPMDPointer’ does not name a type
   EVPMDPointer mdctx_;
   ^
../src/node_crypto.h: In constructor ‘node::crypto::Hash::Hash(node::Environment*, v8::Local<v8::Object>)’:
../src/node_crypto.h:477:9: error: class ‘node::crypto::Hash’ does not have any field named ‘mdctx_’
         mdctx_(nullptr),
         ^
../src/node_crypto.h: At global scope:
../src/node_crypto.h:515:3: error: ‘EVPMDPointer’ does not name a type
   EVPMDPointer mdctx_;
   ^
make[1]: *** [node_lib.target.mk:181: /tmp/guix-build-node-10.11.0.drv-0/node-v10.11.0/out/Release/obj.target/node_lib/src/node.o] Error 1

>> So I wonder if we should downgrade to the 8.12 LTS release, which still
>> supports OpenSSL 1.0, until the OpenSSL situation is sorted.  From what
>> I can tell it might take a while.
>>
>> What do you think?
>
> I think that ideally it would be a good idea to have both the latest and
> the LTS versions distributed in Guix.  So I agree with your solution of
> downgrading to 8.12 LTS.

I managed to build Node LTS on 'core-updates' with this patch:

From 9556fc13a77d2619cfd1e861f0269bccf0a58986 Mon Sep 17 00:00:00 2001
From: Marius Bakke <[email-masked]>
Date: Sun, 23 Sep 2018 13:12:23 +0200
Subject: [PATCH] gnu: Add Node LTS.

* gnu/packages/libevent.scm (libuv-1.19): New public variable.
* gnu/packages/node.scm (node)[arguments]: Adjust 'patch-files' phase to
ignore missing files.
(node-lts): New public variable.
---
 gnu/packages/libevent.scm | 13 +++++++++++++
 gnu/packages/node.scm     | 30 +++++++++++++++++++++++++++---
 2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/libevent.scm b/gnu/packages/libevent.scm
index bc7f6c670..053824bce 100644
--- a/gnu/packages/libevent.scm
+++ b/gnu/packages/libevent.scm
@@ -152,6 +152,19 @@ resolution, asynchronous file system operations, and threading primitives.")
     ;; details.  Documentation is CC-BY 4.0 as of 1.12.0; see 'LICENSE-docs'.
     (license (list expat cc-by4.0))))
 
+;; Node 8.x require this version.
+(define-public libuv-1.19
+  (package
+    (inherit libuv)
+    (version "1.19.2")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://dist.libuv.org/dist/v" version
+                                  "/libuv-v" version ".tar.gz"))
+              (sha256
+               (base32
+                "1msk9ac1z69whww88ibrwjqkd1apdla6l77cm2fwy5kigq0z5g3w"))))))
+
 (define-public perl-anyevent
   (package
     (name "perl-anyevent")
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index d1de7a536..50b1c2b34 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -39,7 +39,8 @@
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
   #:use-module (gnu packages tls)
-  #:use-module (gnu packages web))
+  #:use-module (gnu packages web)
+  #:use-module (srfi srfi-1))
 
 (define-public node
   (package
@@ -86,6 +87,14 @@
        (modify-phases %standard-phases
          (add-before 'configure 'patch-files
            (lambda* (#:key inputs #:allow-other-keys)
+
+             ;; This phase is inherited by Node LTS, which does not have all
+             ;; the files listed here.  Use this helper for convenience.
+             (define (delete-if-exists file)
+               (if (file-exists? file)
+                   (delete-file file)
+                   #t))
+
              ;; Fix hardcoded /bin/sh references.
              (substitute* '("lib/child_process.js"
                             "lib/internal/v8_prof_polyfill.js"
@@ -103,7 +112,7 @@
 
              ;; FIXME: These tests depend on being able to install eslint.
              ;; See https://github.com/nodejs/node/issues/17098.
-             (for-each delete-file
+             (for-each delete-if-exists
                        '("test/parallel/test-eslint-alphabetize-errors.js"
                          "test/parallel/test-eslint-buffer-constructor.js"
                          "test/parallel/test-eslint-documented-errors.js"
@@ -111,7 +120,7 @@
 
              ;; FIXME: These tests fail in the build container, but they don't
              ;; seem to be indicative of real problems in practice.
-             (for-each delete-file
+             (for-each delete-if-exists
                        '("test/async-hooks/test-ttywrap.readstream.js"
                          "test/parallel/test-util-inspect.js"
                          "test/parallel/test-v8-serdes.js"
@@ -180,3 +189,18 @@ devices.")
     (home-page "https://nodejs.org/")
     (license expat)
     (properties '((timeout . 3600))))) ; 1 h
+
+(define-public node-lts
+  (package
+    (inherit node)
+    (version "8.12.0")
+    (source (origin
+              (inherit (package-source node))
+              (uri (string-append "https://nodejs.org/dist/v" version
+                                  "/node-v" version ".tar.xz"))
+              (sha256
+               (base32
+                "16j1rrxkhmvpcw689ndw1raql1gz4jqn7n82z55zn63c05cgz7as"))))
+    (inputs
+     `(("libuv" ,libuv-1.19)
+       ,@(alist-delete "libuv" (package-inputs node))))))
-- 
2.19.0

Unfortunately it fails on 'master' because a test requires OpenSSL
1.0.2p.  I can arrange to disable the test there.  WDYT?