Skip to content

Commit

Permalink
nodejs: Do not use native host nodejs binaries
Browse files Browse the repository at this point in the history
the wordlength of the binaries which are used for generating inputs
during build should match the target, currently, if world lengths are
not same for build host and target then wrong code is being generated,
so we have two options, use qemu usermode to run the target binaries as
it is during build, which works but takes longer to build and qemu
segfaults on some architectures e.g. mips, second option is to require
multilib toolchain on host and then use matching wordlength for host
binaries. It also means nodejs-native dependency can be dropped which is
kind of nice

Signed-off-by: Khem Raj <[email protected]>
  • Loading branch information
kraj committed Apr 18, 2021
1 parent 68e9363 commit ece80ab
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 87 deletions.
2 changes: 1 addition & 1 deletion meta-oe/README
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ URI: git://github.com/openembedded/openembedded-core.git
branch: master
revision: HEAD

luajit recipe requires host compiler to be able to generate 32bit code when target is 32bit
luajit and nodejs recipes require host compiler to be able to generate 32bit code when target is 32bit
e.g. arm, so ensure that $CC -m32 is functional on build host, if building this recipe, needed
packages to fullfit this might have different names on different host distributions
e.g. on archlinux based distributions install prerequisites like below
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
From fbf9c3dedc4114065a6db8718daed3dbc98a743c Mon Sep 17 00:00:00 2001
From: Khem Raj <[email protected]>
Date: Sat, 17 Apr 2021 09:39:27 -0700
Subject: [PATCH] Delete additional libs for host binaries

While building host tools during cross build, these libs are not needed
and would need additional deps if desired to be linked in

Upstream-Status: Inappropriate [Cross-compile specific]
Signed-off-by: Khem Raj <[email protected]>
---
tools/icu/icu-generic.gyp | 4 ++++
tools/v8_gypfiles/v8.gyp | 7 +++++++
2 files changed, 11 insertions(+)

--- a/tools/icu/icu-generic.gyp
+++ b/tools/icu/icu-generic.gyp
@@ -522,6 +522,7 @@
'target_name': 'genrb',
'type': 'executable',
'toolsets': [ 'host' ],
+ 'libraries!':[ '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares', '-lbrotlienc', '-lbrotlidec' ],
'dependencies': [ 'icutools' ],
'sources': [
'<@(icu_src_genrb)'
@@ -538,6 +539,7 @@
'target_name': 'iculslocs',
'toolsets': [ 'host' ],
'type': 'executable',
+ 'libraries!':[ '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares', '-lbrotlienc', '-lbrotlidec' ],
'dependencies': [ 'icutools' ],
'sources': [
'iculslocs.cc',
@@ -550,6 +552,7 @@
'target_name': 'icupkg',
'toolsets': [ 'host' ],
'type': 'executable',
+ 'libraries!':[ '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares', '-lbrotlienc', '-lbrotlidec' ],
'dependencies': [ 'icutools' ],
'sources': [
'<@(icu_src_icupkg)',
@@ -561,6 +564,7 @@
'target_name': 'genccode',
'toolsets': [ 'host' ],
'type': 'executable',
+ 'libraries!':[ '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares', '-lbrotlienc', '-lbrotlidec' ],
'dependencies': [ 'icutools' ],
'sources': [
'<@(icu_src_genccode)',
--- a/tools/v8_gypfiles/v8.gyp
+++ b/tools/v8_gypfiles/v8.gyp
@@ -1310,6 +1310,7 @@
{
'target_name': 'bytecode_builtins_list_generator',
'type': 'executable',
+ 'libraries!':[ '-licui18n', '-licuuc', '-licudata', '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares', '-lbrotlienc', '-lbrotlidec' ],
'conditions': [
['want_separate_host_toolset', {
'toolsets': ['host'],
@@ -1333,6 +1334,8 @@
{
'target_name': 'mksnapshot',
'type': 'executable',
+ 'libraries!':[ '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares', '-lbrotlienc', '-lbrotlidec' ],
+ 'library_dirs':[ '../../../../staging_dir/hostpkg/share/icu/current/lib' ],
'dependencies': [
'v8_base_without_compiler',
'v8_compiler_for_mksnapshot',
@@ -1354,6 +1357,7 @@
{
'target_name': 'torque',
'type': 'executable',
+ 'libraries!':[ '-licui18n', '-licuuc', '-licudata', '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares', '-lbrotlienc', '-lbrotlidec' ],
'dependencies': [
'torque_base',
# "build/win:default_exe_manifest",
@@ -1392,6 +1396,7 @@
{
'target_name': 'torque-language-server',
'type': 'executable',
+ 'libraries!':[ '-licui18n', '-licuuc', '-licudata', '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares', '-lbrotlienc', '-lbrotlidec' ],
'conditions': [
['want_separate_host_toolset', {
'toolsets': ['host'],
@@ -1419,6 +1424,8 @@
{
'target_name': 'gen-regexp-special-case',
'type': 'executable',
+ 'libraries!':[ '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares', '-lbrotlienc', '-lbrotlidec' ],
+ 'library_dirs':[ '../../../../staging_dir/hostpkg/share/icu/current/lib' ],
'dependencies': [
'v8_libbase',
# "build/win:default_exe_manifest",

This file was deleted.

24 changes: 9 additions & 15 deletions meta-oe/recipes-devtools/nodejs/nodejs_14.16.1.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ LICENSE = "MIT & BSD & Artistic-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=85bf260d8b6de1588f57abc5dc66587c"

DEPENDS = "openssl"
DEPENDS_append_class-target = " nodejs-native"

inherit pkgconfig python3native
inherit pkgconfig python3native siteinfo

COMPATIBLE_MACHINE_armv4 = "(!.*armv4).*"
COMPATIBLE_MACHINE_armv5 = "(!.*armv5).*"
Expand All @@ -22,9 +21,7 @@ SRC_URI = "http://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz \
file://big-endian.patch \
file://mips-warnings.patch \
file://v8-call-new-ListFormatter-createInstance.patch \
"
SRC_URI_append_class-target = " \
file://0002-Using-native-binaries.patch \
file://0001-Delete-additional-libs-for-host-binaries.patch \
"
SRC_URI[sha256sum] = "e44adbbed6756c2c1a01258383e9f00df30c147b36e438f6369b5ef1069abac3"

Expand Down Expand Up @@ -61,20 +58,17 @@ PACKAGECONFIG[nghttp2] = "--shared-nghttp2,,nghttp2"
PACKAGECONFIG[shared] = "--shared"
PACKAGECONFIG[zlib] = "--shared-zlib,,zlib"

# We don't want to cross-compile during target compile,
# and we need to use the right flags during host compile,
# too.
EXTRA_OEMAKE = "\
CC.host='${CC}' \
CFLAGS.host='${CPPFLAGS} ${CFLAGS}' \
CXX.host='${CXX}' \
CXXFLAGS.host='${CPPFLAGS} ${CXXFLAGS}' \
LDFLAGS.host='${LDFLAGS}' \
AR.host='${AR}' \
\
builddir_name=./ \
"

FORCE32BIT = "${@['-m32',''][d.getVar('SITEINFO_BITS') != '32']}"
EXTRA_OEMAKE_append_class-target = "\
CC.host='${BUILD_CC} ${FORCE32BIT}' \
CXX.host='${BUILD_CXX} ${FORCE32BIT}' \
AR.host='${BUILD_AR}' \
"

python do_unpack() {
import shutil

Expand Down

0 comments on commit ece80ab

Please sign in to comment.