Closed hubutui closed 2 years ago
We could enable this to allow linking with libnode.so
. It works, I can confirm this, but I'm not 100% sure I like it. When I researched it, it looks like --shared
is around in nodejs for quite some time. Yet nodejs mentions This mode is not officially supported for regular applications
and I'm wondering why no other distro has this flag enabled and how long Arch will build nodejs with this flag, therefore I'm not really sure what to make of this.
On the contrary Arch users would gain the benefit of having a distro package they could simply install and it would free me of the burden of providing updated PKGBUILDs for V8.
From c98a2da2166c3b54b3e6d1712d03909eb089d5ad Mon Sep 17 00:00:00 2001
From: Jan Marvin Garbuszus <jan.garbuszus@ruhr-uni-bochum.de>
Date: Wed, 2 Nov 2022 20:08:01 +0100
Subject: [PATCH] allow linking to libnode
if nodejs is build with '--shared' we can use libnode.so
---
configure | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/configure b/configure
index eddfe61..621698d 100755
--- a/configure
+++ b/configure
@@ -32,6 +32,11 @@ if [ "$UARCH" = "x86_64" ] || [ "$UARCH" = "arm64" ] || [ "$UARCH" = "aarch64" ]
DOWNLOAD_STATIC_LIBV8=1
fi
fi
+# Link to libnode if nodejs is build with --shared. Assume that this shares V8
+if [ -f "/usr/lib/libnode.so" ]; then
+PKG_LIBS="-lnode"
+PKG_CFLAGS="-I/usr/include/node"
+fi
fi
# Use CXX17 when available, required as of libv8 version 10.2
--
libgit2 1.5.0
@JanMarvin ArchLinux has enabled --shared
when building nodejs
, see also the PKGBUILD they use to build the pkg.
@hubutui It's not trivial on our end to guess the proper flags to link to NodeJS. Ideally, Arch would also provide a (virtual) libv8 package which sets up the proper symlinks from v8 in nodejs-shared. See for example other distros:
In Fedora, the nodejs
source package provides a v8-devel
subpackage that installs symlinks, e.g search for libv8.so
in: https://src.fedoraproject.org/rpms/nodejs/blob/rawhide/f/nodejs.spec#_656-662
In Debian the libnode-dev
package already contains symlinks e.g libv8.so -> libnode.so
: https://salsa.debian.org/js-team/nodejs/-/blob/master/debian/libnode-dev.links.in. The libv8-dev
package is simply alias for libnode-dev
: https://salsa.debian.org/js-team/nodejs/-/blob/master/debian/control#L60
I have also added an option to customize those, so you can do in R:
Sys.setenv(V8_PKG_LIBS="-lnode")
Sys.setenv(V8_PKG_CFLAGS="-I/usr/include/node")
install.packages("V8", repos = "https://jeroen.r-universe.dev")
But it would be much better if node installs symlinks as suggested above https://github.com/jeroen/V8/issues/149#issuecomment-1302020081
I have created a very basic AUR PKGBUILD that provides a shared v8 using the nodejs package: nodejs-v8. But I am not really using Arch as my daily driver anymore, therefore I am not really going to push this any further. It is just a quick way for others to use the nodejs v8.
Could we update these lines: https://github.com/jeroen/V8/blob/196359bb38a4eaccbbbfafa820c8d5b6c5213cf3/configure#L11-L12 to:
So we could build it with nodejs on ArchLinux.
nodejs
from ArchLinux recently rebuild with--shared
, and provides/usr/lib/libnode.so
.