Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
martonp96 committed Apr 30, 2024
0 parents commit c288eb4
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 0 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Build libnode

on:
push:
tags:
- 'v*'

jobs:
build:
strategy:
fail-fast: false
matrix:
arch: [x64]
os: [ubuntu-latest, windows-latest]

runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Setup alpine
uses: jirutka/setup-alpine@v1
if: runner.os != 'Windows'
with:
branch: v3.16
packages: >
git bash binutils-gold curl gnupg libgcc linux-headers make python3 ccache xz libatomic
clang clang-dev clang-libs llvm13-dev lld
libc-dev musl musl-dev musl-dbg gcc g++
- name: Apply patches
shell: bash
working-directory: ./node
run: |
git apply --reject --whitespace=fix ../patches/enable_rtti.patch
git apply --reject --whitespace=fix ../patches/internal_modules.patch
git apply --reject --whitespace=fix ../patches/rename_output.patch
git apply --reject --whitespace=fix ../patches/version_suffix.patch
- name: Build project
if: runner.os != 'Windows'
working-directory: ./node
shell: alpine.sh {0}
run: |
export CC="clang"
export CXX="clang++"
export CXXFLAGS="-g -mssse3 -std=c++17"
export LDFLAGS="-m64 -lstdc++ -Wl,--build-id -fuse-ld=lld"
./configure --shared
make -j4
- name: Install NASM
uses: ilammy/setup-nasm@v1
if: runner.os == 'Windows'

- name: Build
if: runner.os == 'Windows'
shell: bash
working-directory: ./node
run: ./vcbuild.bat release x64 dll no-cctest

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: libnode-${{ runner.os }}-${{ matrix.arch }}
path: ./node/out/Release

release:
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4

- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: |
${{ github.workspace }}/libnode-Windows-x64/libnode20.dll
${{ github.workspace }}/libnode-Windows-x64/libnode20.lib
${{ github.workspace }}/libnode-Windows-x64/libnode20.pdb
${{ github.workspace }}/libnode-Linux-x64/libnode20.so
- name: Delete artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: libnode-*

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "node"]
path = node
url = https://github.com/nodejs/node.git
1 change: 1 addition & 0 deletions node
Submodule node added at b3f0c6
27 changes: 27 additions & 0 deletions patches/enable_rtti.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/common.gypi b/common.gypi
index efcd8da848..946952d720 100644
--- a/common.gypi
+++ b/common.gypi
@@ -439,7 +439,7 @@
}],
[ 'OS in "linux freebsd openbsd solaris android aix os400 cloudabi"', {
'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ],
- 'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++17' ],
+ 'cflags_cc': [ '-fno-exceptions' ],
'defines': [ '__STDC_FORMAT_MACROS' ],
'ldflags': [ '-rdynamic' ],
'target_conditions': [
diff --git a/tools/v8_gypfiles/features.gypi b/tools/v8_gypfiles/features.gypi
index c768d7a0f1..c40752b4b6 100644
--- a/tools/v8_gypfiles/features.gypi
+++ b/tools/v8_gypfiles/features.gypi
@@ -318,7 +318,8 @@

# Enable advanced BigInt algorithms, costing about 10-30 KiB binary size
# depending on platform.
- 'v8_advanced_bigint_algorithms%': 1
+ 'v8_advanced_bigint_algorithms%': 1,
+ 'use_rtti%': 1
},

'target_defaults': {
19 changes: 19 additions & 0 deletions patches/internal_modules.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/lib/internal/bootstrap/realm.js b/lib/internal/bootstrap/realm.js
index 9cb6a8add7..6090473d7d 100644
--- a/lib/internal/bootstrap/realm.js
+++ b/lib/internal/bootstrap/realm.js
@@ -209,12 +209,12 @@ const getOwn = (target, property, receiver) => {

const publicBuiltinIds = builtinIds
.filter((id) =>
- !StringPrototypeStartsWith(id, 'internal/') &&
+ !StringPrototypeStartsWith(id, 'yespls/') &&
!experimentalModuleList.has(id),
);
// Do not expose the loaders to user land even with --expose-internals.
const internalBuiltinIds = builtinIds
- .filter((id) => StringPrototypeStartsWith(id, 'internal/') && id !== selfId);
+ .filter((id) => StringPrototypeStartsWith(id, 'yespls/') && id !== selfId);

// When --expose-internals is on we'll add the internal builtin ids to these.
let canBeRequiredByUsersList = new SafeSet(publicBuiltinIds);
76 changes: 76 additions & 0 deletions patches/rename_output.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
diff --git a/node.gyp b/node.gyp
index 4aac64089c..8fa6ab3e81 100644
--- a/node.gyp
+++ b/node.gyp
@@ -25,7 +25,7 @@
'node_v8_options%': '',
'node_enable_v8_vtunejit%': 'false',
'node_core_target_name%': 'node',
- 'node_lib_target_name%': 'libnode',
+ 'node_lib_target_name%': 'libnode20',
'node_intermediate_lib_type%': 'static_library',
'node_builtin_modules_path%': '',
'linked_module_files': [

diff --git a/tools/install.py b/tools/install.py
index 17b0947aac..3e49ce2d74 100755
--- a/tools/install.py
+++ b/tools/install.py
@@ -151,31 +151,31 @@ def files(options, action):

if 'true' == options.variables.get('node_shared'):
if options.is_win:
- action(options, [os.path.join(options.build_dir, 'libnode.dll')], 'bin/libnode.dll')
- action(options, [os.path.join(options.build_dir, 'libnode.lib')], 'lib/libnode.lib')
+ action(options, [os.path.join(options.build_dir, 'libnode20.dll')], 'bin/libnode20.dll')
+ action(options, [os.path.join(options.build_dir, 'libnode20.lib')], 'lib/libnode20.lib')
elif sys.platform == 'zos':
# GYP will output to lib.target; see _InstallableTargetInstallPath
# function in tools/gyp/pylib/gyp/generator/make.py
output_prefix = os.path.join(options.build_dir, 'lib.target')

- output_lib = 'libnode.' + options.variables.get('shlib_suffix')
+ output_lib = 'libnode20.' + options.variables.get('shlib_suffix')
action(options, [os.path.join(output_prefix, output_lib)], os.path.join('lib', output_lib))

- # create libnode.x that references libnode.so (C++ addons compat)
+ # create libnode20.x that references libnode20.so (C++ addons compat)
os.system(os.path.dirname(os.path.realpath(__file__)) +
'/zos/modifysidedeck.sh ' +
abspath(options.install_path, 'lib', output_lib) + ' ' +
- abspath(options.install_path, 'lib/libnode.x') + ' libnode.so')
+ abspath(options.install_path, 'lib/libnode20.x') + ' libnode20.so')

- # install libnode.version.so
- so_name = 'libnode.' + re.sub(r'\.x$', '.so', options.variables.get('shlib_suffix'))
+ # install libnode20.version.so
+ so_name = 'libnode20.' + re.sub(r'\.x$', '.so', options.variables.get('shlib_suffix'))
action(options, [os.path.join(output_prefix, so_name)], options.variables.get('libdir') + '/' + so_name)

- # create symlink of libnode.so -> libnode.version.so (C++ addons compat)
- link_path = abspath(options.install_path, 'lib/libnode.so')
+ # create symlink of libnode20.so -> libnode20.version.so (C++ addons compat)
+ link_path = abspath(options.install_path, 'lib/libnode20.so')
try_symlink(options, so_name, link_path)
else:
- output_lib = 'libnode.' + options.variables.get('shlib_suffix')
+ output_lib = 'libnode20.' + options.variables.get('shlib_suffix')
action(options, [os.path.join(options.build_dir, output_lib)],
os.path.join(options.variables.get('libdir'), output_lib))


diff --git a/vcbuild.bat b/vcbuild.bat
index 75f0850b01..3baa17461f 100644
--- a/vcbuild.bat
+++ b/vcbuild.bat
@@ -451,8 +451,8 @@ if errorlevel 1 echo Cannot copy nodevars.bat && goto package_error
copy /Y ..\tools\msvs\install_tools\*.* %TARGET_NAME%\ > nul
if errorlevel 1 echo Cannot copy install_tools scripts && goto package_error
if defined dll (
- copy /Y libnode.dll %TARGET_NAME%\ > nul
- if errorlevel 1 echo Cannot copy libnode.dll && goto package_error
+ copy /Y libnode20.dll %TARGET_NAME%\ > nul
+ if errorlevel 1 echo Cannot copy libnode20.dll && goto package_error

mkdir %TARGET_NAME%\Release > nul
copy /Y node.def %TARGET_NAME%\Release\ > nul
13 changes: 13 additions & 0 deletions patches/version_suffix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/configure.py b/configure.py
index 00c8513d68..0794bab18e 100755
--- a/configure.py
+++ b/configure.py
@@ -1428,7 +1428,7 @@ def configure_node(o):
elif sys.platform.startswith('zos'):
shlib_suffix = '%s.x'
else:
- shlib_suffix = 'so.%s'
+ shlib_suffix = 'so'
if '%s' in shlib_suffix:
shlib_suffix %= node_module_version

0 comments on commit c288eb4

Please sign in to comment.