diff --git a/L/libnode/build_tarballs.jl b/L/libnode/build_tarballs.jl index 133904279bf..2c50edcd4da 100644 --- a/L/libnode/build_tarballs.jl +++ b/L/libnode/build_tarballs.jl @@ -3,24 +3,52 @@ using BinaryBuilder, Pkg name = "libnode" -version = v"16.17.0" +version = v"18.12.1" # Collection of sources required to complete build sources = [ - ArchiveSource("https://nodejs.org/dist/v$(version)/node-v$(version).tar.gz", "2a2e6262739741f98ab81648a50891861dbf66f12413b93f1a97b4c71570611e"), + ArchiveSource("https://nodejs.org/dist/v$(version)/node-v$(version).tar.gz", "ba8174dda00d5b90943f37c6a180a1d37c861d91e04a4cb38dc1c0c74981c186"), + ArchiveSource( + "https://github.com/sunoru/libnode/releases/download/v$(version)/libnode-v$(version)-Windows-x64.zip", + "675d4b4b335db8d1ab047ea55e09488e0b1c51008f42ee09e4ef7cbca978b2ff", + unpack_target = "x86_64-w64-mingw32" + ), + ArchiveSource( + "https://github.com/sunoru/libnode/releases/download/v$(version)/libnode-v$(version)-macOS-x64.zip", + "a19cbfceaeae3e98f982e06dc232f8a228e021941a9ead79aef9bc1ca0fc2f50", + unpack_target = "x86_64-apple-darwin14" + ), DirectorySource("bundled") ] -# Bash recipe for building across all platforms -script = raw""" -cd $WORKSPACE/srcdir +w64_script = raw""" +cd ${target}/libnode-* cd node-* +chmod +x *.cmd *.exe +mkdir -p ${bindir} +mv * ${bindir}/ +mv ${bindir}/include ${prefix} +mv ${bindir}/LICENSE . +install_license ./LICENSE +""" + +mac_script = raw""" +cd ${target}/libnode-* +chmod +x bin/* +mv * ${prefix}/ +mv ${prefix}/LICENSE . +install_license ./LICENSE +""" +linux_script = raw""" +cd node-* export CC_host=$HOSTCC export CXX_host=$HOSTCXX -atomic_patch -p1 "${WORKSPACE}/srcdir/patches/node_main.cc.patch" -atomic_patch -p1 "${WORKSPACE}/srcdir/patches/trap-handler.h.patch" +atomic_patch -p1 "${WORKSPACE}/srcdir/patches/configure.py.patch" +atomic_patch -p1 "${WORKSPACE}/srcdir/patches/node.gypi.patch" +atomic_patch -p1 "${WORKSPACE}/srcdir/patches/node_credentials.cc.patch" +atomic_patch -p1 "${WORKSPACE}/srcdir/patches/test_crypto_clienthello.cc.patch" # Build & install libnode if [[ $target == $MACHTYPE ]] then @@ -28,11 +56,9 @@ then else DEST_CPU=x86_64 if [[ $target == *aarch64* ]]; then DEST_CPU=arm64; fi - DEST_OS=linux - ./configure --prefix=${prefix} --shared --cross-compiling --dest-cpu=$DEST_CPU --dest-os=$DEST_OS + ./configure --prefix=${prefix} --shared --cross-compiling --dest-cpu=$DEST_CPU --dest-os=linux fi -export LDFLAGS=-lrt export CPPFLAGS=-D__STDC_FORMAT_MACROS make -j`nproc` make install @@ -40,6 +66,23 @@ cp ./out/Release/node ${bindir} install_license ./LICENSE """ +# Bash recipe for building across all platforms +script = """ +cd \$WORKSPACE/srcdir +if [[ \$target == *w64* ]] +then + $w64_script +elif [[ \$target == *apple* ]] +then + $mac_script +elif [[ \$target == *linux* ]] +then + $linux_script +fi +""" + + + # These are the platforms we will build for by default, unless further # platforms are passed in on the command line # Only 64-bit Linux platforms. @@ -52,10 +95,10 @@ platforms = [ Platform("x86_64", "linux"; libc="musl"), Platform("aarch64", "linux"; libc="musl"), - # Platform("x86_64", "macos"), + Platform("x86_64", "macos"), # Platform("aarch64", "macos"), - # Platform("x86_64", "windows"), + Platform("x86_64", "windows"), ] platforms = expand_cxxstring_abis(platforms) diff --git a/L/libnode/bundled/patches/configure.py.patch b/L/libnode/bundled/patches/configure.py.patch new file mode 100644 index 00000000000..43d9c1c2fb2 --- /dev/null +++ b/L/libnode/bundled/patches/configure.py.patch @@ -0,0 +1,17 @@ +diff --git a/configure.py b/configure.py +index a4e5723067..60ec604454 100755 +--- a/configure.py ++++ b/configure.py +@@ -1245,9 +1245,9 @@ def configure_node(o): + + o['variables']['want_separate_host_toolset'] = int(cross_compiling) + +- # Enable branch protection for arm64 +- if target_arch == 'arm64': +- o['cflags']+=['-msign-return-address=all'] ++ # # Enable branch protection for arm64 ++ # if target_arch == 'arm64': ++ # o['cflags']+=['-msign-return-address=all'] + + if options.node_snapshot_main is not None: + if options.shared: diff --git a/L/libnode/bundled/patches/node.gypi.patch b/L/libnode/bundled/patches/node.gypi.patch new file mode 100644 index 00000000000..29cc2a878a9 --- /dev/null +++ b/L/libnode/bundled/patches/node.gypi.patch @@ -0,0 +1,13 @@ +diff --git a/node.gypi b/node.gypi +index 0b0f05322e..25ce3e14c6 100644 +--- a/node.gypi ++++ b/node.gypi +@@ -327,7 +327,7 @@ + 'ldflags': [ '-Wl,-M,/usr/lib/ld/map.noexstk' ], + }], + [ 'OS=="linux"', { +- 'libraries!': [ ++ 'libraries': [ + '-lrt' + ], + }], diff --git a/L/libnode/bundled/patches/node_credentials.cc.patch b/L/libnode/bundled/patches/node_credentials.cc.patch new file mode 100644 index 00000000000..8a58cebe426 --- /dev/null +++ b/L/libnode/bundled/patches/node_credentials.cc.patch @@ -0,0 +1,37 @@ +diff --git a/src/node_credentials.cc b/src/node_credentials.cc +index 115c2fc877..946f39f7b4 100644 +--- a/src/node_credentials.cc ++++ b/src/node_credentials.cc +@@ -13,7 +13,13 @@ + #endif + #ifdef __linux__ + #include +-#include ++#include ++#ifdef __LP64__ ++#define Elf_auxv_t Elf64_auxv_t ++#else ++#define Elf_auxv_t Elf32_auxv_t ++#endif // __LP64__ ++extern char** environ; + #include + #endif // __linux__ + +@@ -38,8 +44,15 @@ bool linux_at_secure() { + // and returns the correct value, e.g. even in static + // initialization code in other files. + #ifdef __linux__ +- static const bool value = getauxval(AT_SECURE); +- return value; ++ char** envp = environ; ++ while (*envp++ != nullptr) {} ++ Elf_auxv_t* auxv = reinterpret_cast(envp); ++ for (; auxv->a_type != AT_NULL; auxv++) { ++ if (auxv->a_type == AT_SECURE) { ++ static const bool value = auxv->a_un.a_val; ++ return value; ++ } ++ } + #else + return false; + #endif diff --git a/L/libnode/bundled/patches/node_main.cc.patch b/L/libnode/bundled/patches/node_main.cc.patch deleted file mode 100644 index 10f9d63de33..00000000000 --- a/L/libnode/bundled/patches/node_main.cc.patch +++ /dev/null @@ -1,36 +0,0 @@ -diff --git a/src/node_main.cc b/src/node_main.cc -index 6bac107593..9f4ea22d12 100644 ---- a/src/node_main.cc -+++ b/src/node_main.cc -@@ -89,7 +89,13 @@ int wmain(int argc, wchar_t* wargv[]) { - #else - // UNIX - #ifdef __linux__ --#include -+#include -+#ifdef __LP64__ -+#define Elf_auxv_t Elf64_auxv_t -+#else -+#define Elf_auxv_t Elf32_auxv_t -+#endif // __LP64__ -+extern char** environ; - #endif // __linux__ - #if defined(__POSIX__) && defined(NODE_SHARED_MODE) - #include -@@ -118,7 +124,15 @@ int main(int argc, char* argv[]) { - #endif - - #if defined(__linux__) -- node::per_process::linux_at_secure = getauxval(AT_SECURE); -+ char** envp = environ; -+ while (*envp++ != nullptr) {} -+ Elf_auxv_t* auxv = reinterpret_cast(envp); -+ for (; auxv->a_type != AT_NULL; auxv++) { -+ if (auxv->a_type == AT_SECURE) { -+ node::per_process::linux_at_secure = auxv->a_un.a_val; -+ break; -+ } -+ } - #endif - // Disable stdio buffering, it interacts poorly with printf() - // calls elsewhere in the program (e.g., any logging from V8.) diff --git a/L/libnode/bundled/patches/test_crypto_clienthello.cc.patch b/L/libnode/bundled/patches/test_crypto_clienthello.cc.patch new file mode 100644 index 00000000000..16ee58b914e --- /dev/null +++ b/L/libnode/bundled/patches/test_crypto_clienthello.cc.patch @@ -0,0 +1,21 @@ +diff --git a/test/cctest/test_crypto_clienthello.cc b/test/cctest/test_crypto_clienthello.cc +index 60a8e294c8..e673073dc3 100644 +--- a/test/cctest/test_crypto_clienthello.cc ++++ b/test/cctest/test_crypto_clienthello.cc +@@ -16,6 +16,7 @@ + // safety is violated. + #if !defined(NO_GUARD_PAGE) + #ifdef __linux__ ++#include + #include + #include + #if defined(_SC_PAGE_SIZE) && defined(PROT_NONE) && defined(PROT_READ) && \ +@@ -54,7 +55,7 @@ class OverrunGuardedBuffer { + #ifdef USE_MPROTECT + // Place the packet right before a guard page, which, when accessed, causes + // a segmentation fault. +- alloc_base = static_cast(aligned_alloc(page, 2 * page)); ++ alloc_base = static_cast(memalign(page, 2 * page)); + EXPECT_NE(alloc_base, nullptr); + uint8_t* second_page = alloc_base + page; + EXPECT_EQ(mprotect(second_page, page, PROT_NONE), 0); diff --git a/L/libnode/bundled/patches/trap-handler.h.patch b/L/libnode/bundled/patches/trap-handler.h.patch deleted file mode 100644 index c6c437d2ceb..00000000000 --- a/L/libnode/bundled/patches/trap-handler.h.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/deps/v8/src/trap-handler/trap-handler.h b/deps/v8/src/trap-handler/trap-handler.h -index 0b3a6e0a70..50eccd6f46 100644 ---- a/deps/v8/src/trap-handler/trap-handler.h -+++ b/deps/v8/src/trap-handler/trap-handler.h -@@ -26,9 +26,9 @@ namespace trap_handler { - #elif V8_TARGET_ARCH_ARM64 && V8_HOST_ARCH_ARM64 && V8_OS_MACOSX - #define V8_TRAP_HANDLER_SUPPORTED true - // Arm64 simulator on x64 on Linux or Mac. --#elif V8_TARGET_ARCH_ARM64 && V8_HOST_ARCH_X64 && (V8_OS_LINUX || V8_OS_MACOSX) --#define V8_TRAP_HANDLER_VIA_SIMULATOR --#define V8_TRAP_HANDLER_SUPPORTED true -+// #elif V8_TARGET_ARCH_ARM64 && V8_HOST_ARCH_X64 && (V8_OS_LINUX || V8_OS_MACOSX) -+// #define V8_TRAP_HANDLER_VIA_SIMULATOR -+// #define V8_TRAP_HANDLER_SUPPORTED true - // Everything else is unsupported. - #else - #define V8_TRAP_HANDLER_SUPPORTED false