Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,7 @@ $(TARBALL): release-only doc-only
mkdir -p $(TARNAME)/doc/api
cp doc/node.1 $(TARNAME)/doc/node.1
cp -r out/doc/api/* $(TARNAME)/doc/api/
sed 's/fileset = fileset.intersection (fileset.gitTracked root)/fileset =/' tools/nix/v8.nix > $(TARNAME)/tools/nix/v8.nix
$(RM) -r $(TARNAME)/.editorconfig
$(RM) -r $(TARNAME)/.git*
$(RM) -r $(TARNAME)/.mailmap
Expand Down
112 changes: 65 additions & 47 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,18 @@
withSQLite ? true,
withSSL ? true,
withTemporal ? false,
sharedLibDeps ?
let
d = import ./tools/nix/sharedLibDeps.nix {
inherit
pkgs
withLief
withQuic
withSQLite
withSSL
withTemporal
;
};
in
# To avoid conflicts with V8's bundled simdutf lib, it's easier to remove it when using a precompiled V8.
if (useSeparateDerivationForV8 != false) then builtins.removeAttrs d [ "simdutf" ] else d,
sharedLibDeps ? (
import ./tools/nix/sharedLibDeps.nix {
inherit
pkgs
withLief
withQuic
withSQLite
withSSL
withTemporal
;
}
),

# dev tools (not needed to build Node.js, useful to maintain it)
ncu-path ? null, # Provide this if you want to use a local version of NCU
Expand All @@ -45,9 +42,20 @@ let
useSharedAda = builtins.hasAttr "ada" sharedLibDeps;
useSharedOpenSSL = builtins.hasAttr "openssl" sharedLibDeps;

needsRustCompiler = withTemporal && !builtins.hasAttr "temporal_capi" sharedLibDeps;
useSharedTemporal = builtins.hasAttr "temporal_capi" sharedLibDeps;
needsRustCompiler = withTemporal && !useSharedTemporal;

buildInputs = builtins.attrValues sharedLibDeps ++ pkgs.lib.optional useSharedICU icu;
nativeBuildInputs =
pkgs.nodejs-slim_latest.nativeBuildInputs
++ pkgs.lib.optionals needsRustCompiler [
pkgs.cargo
pkgs.rustc
];
buildInputs =
pkgs.lib.optional useSharedICU icu
++ pkgs.lib.optional (withTemporal && useSharedTemporal) sharedLibDeps.temporal_capi;

# Put here only the configure flags that affect the V8 build
configureFlags = [
(
if icu == null then
Expand All @@ -57,47 +65,31 @@ let
)
]
++ extraConfigFlags
++ pkgs.lib.optional (!withAmaro) "--without-amaro"
++ pkgs.lib.optional (!withLief) "--without-lief"
++ pkgs.lib.optional withQuic "--experimental-quic"
++ pkgs.lib.optional (!withSQLite) "--without-sqlite"
++ pkgs.lib.optional (!withSSL) "--without-ssl"
++ pkgs.lib.optional withTemporal "--v8-enable-temporal-support"
++ pkgs.lib.optional (ninja != null) "--ninja"
++ pkgs.lib.optional loadJSBuiltinsDynamically "--node-builtin-modules-path=${builtins.toString ./.}"
++ pkgs.lib.concatMap (name: [
"--shared-${name}"
"--shared-${name}-libpath=${pkgs.lib.getLib sharedLibDeps.${name}}/lib"
"--shared-${name}-include=${pkgs.lib.getInclude sharedLibDeps.${name}}/include"
]) (builtins.attrNames sharedLibDeps);
++ pkgs.lib.optional (withTemporal && useSharedTemporal) "--shared-temporal_capi";
in
pkgs.mkShell {
inherit (pkgs.nodejs-slim_latest) nativeBuildInputs;
inherit nativeBuildInputs;

buildInputs =
buildInputs
builtins.attrValues sharedLibDeps
++ buildInputs
++ pkgs.lib.optional (useSeparateDerivationForV8 != false) (
if useSeparateDerivationForV8 == true then
import ./tools/nix/v8.nix {
inherit
pkgs
configureFlags
buildInputs
needsRustCompiler
;
let
sharedLibsToMock = pkgs.callPackage ./tools/nix/non-v8-deps-mock.nix { };
in
pkgs.callPackage ./tools/nix/v8.nix {
inherit nativeBuildInputs icu;

configureFlags = configureFlags ++ sharedLibsToMock.configureFlags ++ [ "--ninja" ];
buildInputs = buildInputs ++ [ sharedLibsToMock ];
}
else
useSeparateDerivationForV8
);

packages =
pkgs.lib.optional (ccache != null) ccache
++ devTools
++ benchmarkTools
++ pkgs.lib.optionals needsRustCompiler [
pkgs.cargo
pkgs.rustc
];
packages = devTools ++ benchmarkTools ++ pkgs.lib.optional (ccache != null) ccache;

shellHook = pkgs.lib.optionalString (ccache != null) ''
export CC="${pkgs.lib.getExe ccache} $CC"
Expand All @@ -107,7 +99,33 @@ pkgs.mkShell {
BUILD_WITH = if (ninja != null) then "ninja" else "make";
NINJA = pkgs.lib.optionalString (ninja != null) "${pkgs.lib.getExe ninja}";
CONFIG_FLAGS = builtins.toString (
configureFlags ++ pkgs.lib.optional (useSeparateDerivationForV8 != false) "--without-bundled-v8"
configureFlags
++ pkgs.lib.optional (ninja != null) "--ninja"
++ pkgs.lib.optional (!withAmaro) "--without-amaro"
++ pkgs.lib.optional (!withLief) "--without-lief"
++ pkgs.lib.optional withQuic "--experimental-quic"
++ pkgs.lib.optional (!withSQLite) "--without-sqlite"
++ pkgs.lib.optional (!withSSL) "--without-ssl"
++ pkgs.lib.optional loadJSBuiltinsDynamically "--node-builtin-modules-path=${builtins.toString ./.}"
++ pkgs.lib.optional (useSeparateDerivationForV8 != false) "--without-bundled-v8"
++
pkgs.lib.concatMap
(name: [
"--shared-${name}"
"--shared-${name}-libpath=${pkgs.lib.getLib sharedLibDeps.${name}}/lib"
"--shared-${name}-include=${pkgs.lib.getInclude sharedLibDeps.${name}}/include"
])
(
builtins.attrNames (
if (useSeparateDerivationForV8 != false) then
builtins.removeAttrs sharedLibDeps [
"simdutf"
"temporal_capi"
]
else
sharedLibDeps
)
)
);
NOSQLITE = pkgs.lib.optionalString (!withSQLite) "1";
}
76 changes: 76 additions & 0 deletions tools/nix/non-v8-deps-mock.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
symlinkJoin,
writeTextFile,
validatePkgConfig,
testers,
lib,
}:

let
sharedLibsToMock = {
zlib = [ "zlib" ];
http-parser = [ "libllhttp" ];
libuv = [ "libuv" ];
ada = [ "ada" ];
simdjson = [ "simdjson" ];
brotli = [
"libbrotlidec"
"libbrotlienc"
];
cares = [ "libcares" ];
gtest = [ "gtest" ];
hdr-histogram = [ "hdr_histogram" ];
merve = [ "merve" ];
nbytes = [ "nbytes" ];
nghttp2 = [ "libnghttp2" ];
nghttp3 = [ "libnghttp3" ];
ngtcp2 = [ "libngtcp2" ];
uvwasi = [ "uvwasi" ];
zstd = [ "libzstd" ];
};
in
symlinkJoin (finalAttrs: {
pname = "non-v8-deps-mock";
version = "0.0.0-mock";

nativeBuildInputs = [ validatePkgConfig ];

paths = lib.concatMap (
sharedLibName:
(builtins.map (
pkgName:
writeTextFile {
name = "mock-${pkgName}.pc";
destination = "/lib/pkgconfig/${pkgName}.pc";
text = ''
Name: ${pkgName}
Description: Mock package for ${sharedLibName}
Version: ${finalAttrs.version}
Libs:
Cflags:
'';
}
) sharedLibsToMock.${sharedLibName})
) (builtins.attrNames sharedLibsToMock);
passthru = {
configureFlags = [
"--without-lief"
"--without-sqlite"
"--without-ssl"
]
++ (lib.concatMap (sharedLibName: [
"--shared-${sharedLibName}"
"--shared-${sharedLibName}-libname="
]) (builtins.attrNames sharedLibsToMock));

tests.pkg-config = testers.hasPkgConfigModules {
package = finalAttrs.finalPackage;
};
};

meta = {
description = "Mock of Node.js dependencies that are not needed for building V8";
license = lib.licenses.mit;
pkgConfigModules = lib.concatMap (x: x) (builtins.attrValues sharedLibsToMock);
};
})
63 changes: 63 additions & 0 deletions tools/nix/temporal-no-vendored-icu.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
diff --git a/deps/v8/src/objects/js-temporal-zoneinfo64.cc b/deps/v8/src/objects/js-temporal-zoneinfo64.cc
index 99dd3a84c1e..b6b399c10dc 100644
--- a/deps/v8/src/objects/js-temporal-zoneinfo64.cc
+++ b/deps/v8/src/objects/js-temporal-zoneinfo64.cc
@@ -11,12 +11,44 @@
#include "temporal_rs/TimeZone.hpp"

#ifdef V8_INTL_SUPPORT
-#include "udatamem.h"
+#include "unicode/udata.h"
+typedef struct {
+ uint16_t headerSize;
+ uint8_t magic1;
+ uint8_t magic2;
+} MappedData;
+typedef struct {
+ MappedData dataHeader;
+ UDataInfo info;
+} DataHeader;
+typedef struct {
+ void* Lookup;
+ void* NumEntries;
+} commonDataFuncs;
+struct UDataMemory {
+ const commonDataFuncs *vFuncs; /* Function Pointers for accessing TOC */
+
+ const DataHeader *pHeader; /* Header of the memory being described by this */
+ /* UDataMemory object. */
+ const void *toc; /* For common memory, table of contents for */
+ /* the pieces within. */
+ UBool heapAllocated; /* True if this UDataMemory Object is on the */
+ /* heap and thus needs to be deleted when closed. */
+
+ void *mapAddr; /* For mapped or allocated memory, the start addr. */
+ /* Only non-null if a close operation should unmap */
+ /* the associated data. */
+ void *map; /* Handle, or other data, OS dependent. */
+ /* Only non-null if a close operation should unmap */
+ /* the associated data, and additional info */
+ /* beyond the mapAddr is needed to do that. */
+ int32_t length; /* Length of the data in bytes; -1 if unknown. */
+};
#else
// Defined in builtins-temporal-zoneinfo64-data.cc, generated by
// include-file-as-bytes.py
-extern "C" uint32_t zoneinfo64_static_data[];
-extern "C" size_t zoneinfo64_static_data_len;
+static uint32_t zoneinfo64_static_data[] = {};
+static size_t zoneinfo64_static_data_len = 0;
#endif

namespace v8::internal {
@@ -33,7 +65,7 @@ ZoneInfo64Provider::ZoneInfo64Provider() {
// NOT udata_getLength: this ignores the header,
// and we're parsing resb files with the header
auto length = memory->length;
- const void* data = udata_getRawMemory(memory);
+ const void* data = udata_getMemory(memory);
DCHECK_WITH_MSG(length % 4 == 0, "ICU4C should align udata to uint32_t");
if (length % 4 != 0) {
// This really shouldn't happen: ICU4C aligns these files
--
2.51.0
Loading
Loading