From b57ce73d98f3f10507fb5acd22337bbf98d3ec07 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Wed, 15 Sep 2021 20:20:21 +0300 Subject: [PATCH 1/5] v8: 8.4.255 -> 9.7.106.18 * Fix update.sh; * Use specific gn revision; * Install icudtl.dat. --- pkgs/development/libraries/v8/default.nix | 116 +++++++++++--------- pkgs/development/libraries/v8/gcc_arm.patch | 31 ------ pkgs/development/libraries/v8/update.sh | 49 ++++++--- pkgs/top-level/all-packages.nix | 4 +- 4 files changed, 98 insertions(+), 102 deletions(-) delete mode 100644 pkgs/development/libraries/v8/gcc_arm.patch diff --git a/pkgs/development/libraries/v8/default.nix b/pkgs/development/libraries/v8/default.nix index 7c463aa01228..1d2911c1313f 100644 --- a/pkgs/development/libraries/v8/default.nix +++ b/pkgs/development/libraries/v8/default.nix @@ -1,75 +1,85 @@ { stdenv, lib, fetchgit, fetchFromGitHub -, gn, ninja, python, pythonPackages, glib, pkg-config, icu +, gn, ninja, python3, glib, pkg-config, icu , xcbuild, darwin , fetchpatch }: +# Use update.sh to update all checksums. + let + version = "9.7.106.18"; + v8Src = fetchgit { + url = "https://chromium.googlesource.com/v8/v8"; + rev = version; + sha256 = "0cb3w733w1xn6zq9dsr43nx6llcg9hrmb2dkxairarj9c0igpzyh"; + }; + git_url = "https://chromium.googlesource.com"; - # This data is from the DEPS file in the root of a V8 checkout + # This data is from the DEPS file in the root of a V8 checkout. deps = { "base/trace_event/common" = fetchgit { url = "${git_url}/chromium/src/base/trace_event/common.git"; - rev = "dab187b372fc17e51f5b9fad8201813d0aed5129"; - sha256 = "0dmpj9hj4xv3xb0fl1kb9hm4bhpbs2s5csx3z8cgjd5vwvhdzig4"; + rev = "7f36dbc19d31e2aad895c60261ca8f726442bfbb"; + sha256 = "01b2fhbxznqbakxv42ivrzg6w8l7i9yrd9nf72d6p5xx9dm993j4"; }; - build = fetchgit { + "build" = fetchgit { url = "${git_url}/chromium/src/build.git"; - rev = "26e9d485d01d6e0eb9dadd21df767a63494c8fea"; - sha256 = "1jjvsgj0cs97d26i3ba531ic1f9gqan8x7z4aya8yl8jx02l342q"; + rev = "cf325916d58a194a935c26a56fcf6b525d1e2bf4"; + sha256 = "1ix4h1cpx9bvgln8590xh7lllhsd9w1hd5k9l1gx5yxxrmywd3s4"; }; "third_party/googletest/src" = fetchgit { url = "${git_url}/external/github.com/google/googletest.git"; - rev = "e3f0319d89f4cbf32993de595d984183b1a9fc57"; - sha256 = "18xz71l2xjrqsc0q317whgw4xi1i5db24zcj7v04f5g6r1hyf1a5"; + rev = "16f637fbf4ffc3f7a01fa4eceb7906634565242f"; + sha256 = "11012k3c3mxzdwcw2iparr9lrckafpyhqzclsj26hmfbgbdi0rrh"; }; "third_party/icu" = fetchgit { url = "${git_url}/chromium/deps/icu.git"; - rev = "f2223961702f00a8833874b0560d615a2cc42738"; - sha256 = "0z5p53kbrjfkjn0i12dpk55cp8976j2zk7a4wk88423s2c5w87zl"; - }; - "third_party/jinja2" = fetchgit { - url = "${git_url}/chromium/src/third_party/jinja2.git"; - rev = "b41863e42637544c2941b574c7877d3e1f663e25"; - sha256 = "1qgilclkav67m6cl2xq2kmzkswrkrb2axc2z8mw58fnch4j1jf1r"; - }; - "third_party/markupsafe" = fetchgit { - url = "${git_url}/chromium/src/third_party/markupsafe.git"; - rev = "8f45f5cfa0009d2a70589bcda0349b8cb2b72783"; - sha256 = "168ppjmicfdh4i1l0l25s86mdbrz9fgxmiq1rx33x79mph41scfz"; + rev = "eedbaf76e49d28465d9119b10c30b82906e606ff"; + sha256 = "0mppvx7wf9zlqjsfaa1cf06brh1fjb6nmiib0lhbb9hd55mqjdjj"; }; "third_party/zlib" = fetchgit { url = "${git_url}/chromium/src/third_party/zlib.git"; - rev = "156be8c52f80cde343088b4a69a80579101b6e67"; - sha256 = "0hxbkkzmlv714fjq2jlp5dd2jc339xyh6gkjx1sz3srwv33mlk92"; + rev = "6da1d53b97c89b07e47714d88cab61f1ce003c68"; + sha256 = "0v7ylmbwfwv6w6wp29qdf77kjjnfr2xzin08n0v1yvbhs01h5ppy"; + }; + "third_party/jinja2" = fetchgit { + url = "${git_url}/chromium/src/third_party/jinja2.git"; + rev = "ee69aa00ee8536f61db6a451f3858745cf587de6"; + sha256 = "1fsnd5h0gisfp8bdsfd81kk5v4mkqf8z368c7qlm1qcwc4ri4x7a"; + }; + "third_party/markupsafe" = fetchgit { + url = "${git_url}/chromium/src/third_party/markupsafe.git"; + rev = "1b882ef6372b58bfd55a3285f37ed801be9137cd"; + sha256 = "1jnjidbh03lhfaawimkjxbprmsgz4snr0jl06630dyd41zkdw5kr"; }; }; + # See `gn_version` in DEPS. + gnSrc = fetchgit { + url = "https://gn.googlesource.com/gn"; + rev = "8926696a4186279489cc2b8d768533e61bba73d7"; + sha256 = "1084lnyb0a1khbgjvak05fcx6jy973wqvsf77n0alxjys18sg2yk"; + }; + + myGn = gn.overrideAttrs (oldAttrs: { + version = "for-v8"; + src = gnSrc; + }); + in stdenv.mkDerivation rec { pname = "v8"; - version = "8.4.255"; + inherit version; doCheck = true; patches = [ - # Remove unrecognized clang debug flags - (fetchpatch { - url = "https://raw.githubusercontent.com/saiarcot895/chromium-ubuntu-build/663dbfc492fd2f8ba28d9af40fb3b1327e6aa56e/debian/patches/revert-Xclang-instcombine-lower-dbg-declare.patch"; - sha256 = "07qp4bjgbwbdrzqslvl2bgbzr3v97b9isbp0539x3lc8cy3h02g1"; - }) ./darwin.patch - ./gcc_arm.patch # Fix building zlib with gcc on aarch64, from https://gist.github.com/Adenilson/d973b6fd96c7709d33ddf08cf1dcb149 ]; - src = fetchFromGitHub { - owner = "v8"; - repo = "v8"; - rev = version; - sha256 = "07ymw4kqbz7kv311gpk5bs5q90wj73n2q7jkyfhqk4hvhs1q5bw7"; - }; + src = v8Src; postUnpack = '' ${lib.concatStringsSep "\n" ( @@ -80,16 +90,20 @@ stdenv.mkDerivation rec { chmod u+w -R . ''; - postPatch = lib.optionalString stdenv.isAarch64 '' - substituteInPlace build/toolchain/linux/BUILD.gn \ - --replace 'toolprefix = "aarch64-linux-gnu-"' 'toolprefix = ""' - '' + lib.optionalString stdenv.isDarwin '' - substituteInPlace build/config/compiler/compiler.gni \ - --replace 'strip_absolute_paths_from_debug_symbols = true' \ - 'strip_absolute_paths_from_debug_symbols = false' - substituteInPlace build/config/compiler/BUILD.gn \ - --replace 'current_toolchain == host_toolchain || !use_xcode_clang' \ - 'false' + postPatch = '' + ${lib.optionalString stdenv.isAarch64 '' + substituteInPlace build/toolchain/linux/BUILD.gn \ + --replace 'toolprefix = "aarch64-linux-gnu-"' 'toolprefix = ""' + ''} + ${lib.optionalString stdenv.isDarwin '' + substituteInPlace build/config/compiler/compiler.gni \ + --replace 'strip_absolute_paths_from_debug_symbols = true' \ + 'strip_absolute_paths_from_debug_symbols = false' + substituteInPlace build/config/compiler/BUILD.gn \ + --replace 'current_toolchain == host_toolchain || !use_xcode_clang' \ + 'false' + ''} + touch build/config/gclient_args.gni ''; gnFlags = [ @@ -106,7 +120,6 @@ stdenv.mkDerivation rec { "treat_warnings_as_errors=false" "v8_enable_i18n_support=true" "use_gold=false" - "init_stack_vars=false" # ''custom_toolchain="//build/toolchain/linux/unbundle:default"'' ''host_toolchain="//build/toolchain/linux/unbundle:default"'' ''v8_snapshot_toolchain="//build/toolchain/linux/unbundle:default"'' @@ -116,14 +129,14 @@ stdenv.mkDerivation rec { FORCE_MAC_SDK_MIN = stdenv.targetPlatform.sdkVer or "10.12"; nativeBuildInputs = [ - gn + myGn ninja pkg-config - python + python3 ] ++ lib.optionals stdenv.isDarwin [ xcbuild darwin.DarwinTools - pythonPackages.setuptools + python3.pkgs.setuptools ]; buildInputs = [ glib icu ]; @@ -133,7 +146,8 @@ stdenv.mkDerivation rec { installPhase = '' install -D d8 $out/bin/d8 - install -D obj/libv8_monolith.a $out/lib/libv8.a + install -D -m644 obj/libv8_monolith.a $out/lib/libv8.a + install -D -m644 icudtl.dat $out/share/v8/icudtl.dat cp -r ../../include $out mkdir -p $out/lib/pkgconfig diff --git a/pkgs/development/libraries/v8/gcc_arm.patch b/pkgs/development/libraries/v8/gcc_arm.patch deleted file mode 100644 index 09579561fd8d..000000000000 --- a/pkgs/development/libraries/v8/gcc_arm.patch +++ /dev/null @@ -1,31 +0,0 @@ -diff --git a/third_party/zlib/contrib/optimizations/insert_string.h b/third_party/zlib/contrib/optimizations/insert_string.h -index 1826601..d123305 100644 ---- a/third_party/zlib/contrib/optimizations/insert_string.h -+++ b/third_party/zlib/contrib/optimizations/insert_string.h -@@ -26,15 +26,23 @@ - #define _cpu_crc32_u32 _mm_crc32_u32 - - #elif defined(CRC32_ARMV8_CRC32) -- #if defined(__clang__) -+ #if defined(__GNUC__) || defined(__clang__) - #undef TARGET_CPU_WITH_CRC -- #define __crc32cw __builtin_arm_crc32cw -+ #if defined(__clang__) -+ #define __crc32cw __builtin_arm_crc32cw -+ #elif defined(__GNUC__) -+ #define __crc32cw __builtin_aarch64_crc32cw -+ #endif - #endif - - #define _cpu_crc32_u32 __crc32cw - - #if defined(__aarch64__) -- #define TARGET_CPU_WITH_CRC __attribute__((target("crc"))) -+ #if defined(__clang__) -+ #define TARGET_CPU_WITH_CRC __attribute__((target("crc"))) -+ #elif defined(__GNUC__) -+ #define TARGET_CPU_WITH_CRC __attribute__((target("+crc"))) -+ #endif - #else // !defined(__aarch64__) - #define TARGET_CPU_WITH_CRC __attribute__((target("armv8-a,crc"))) - #endif // defined(__aarch64__) diff --git a/pkgs/development/libraries/v8/update.sh b/pkgs/development/libraries/v8/update.sh index f046bb8e6885..c3fbab6faf19 100755 --- a/pkgs/development/libraries/v8/update.sh +++ b/pkgs/development/libraries/v8/update.sh @@ -1,29 +1,45 @@ #!/usr/bin/env nix-shell -#! nix-shell -i bash -p curl -p nix-prefetch-git +#! nix-shell -i bash -p curl -p nix-prefetch-git -p jq VERSION_OVERVIEW=https://omahaproxy.appspot.com/all?os=linux -TARGET_CHANNEL=beta -FILE_PATH=6_x.nix +TARGET_CHANNEL=stable set -eo pipefail -v8_version=$(curl -s "$VERSION_OVERVIEW" | awk -F "," "\$2 ~ /${TARGET_CHANNEL}/ { print \$11 }") +if [ -n "$1" ]; then + v8_version="$1" + shift +else + v8_version=$(curl -s "$VERSION_OVERVIEW" | awk -F "," "\$2 ~ /${TARGET_CHANNEL}/ { print \$11 }") +fi + +if [ -n "$1" ]; then + file_path="$1" +else + file_path=default.nix +fi echo "Using V8 version --> $v8_version" -sed -e "s#\\(version = \\)\"[0-9\.]*\"#\1\"$v8_version\"#" -i ${FILE_PATH} -sha256=$(nix-prefetch-git --no-deepClone https://github.com/v8/v8.git "refs/tags/${v8_version}" \ - | sed -ne '/sha256/ { s#.*: "\(.*\)".*#\1#; p }') -sed -e "/repo = \"v8\"/ { n;n; s#\".*\"#\"${sha256}\"# }" -i ${FILE_PATH} +prefetched=$(nix-prefetch-git --no-deepClone https://chromium.googlesource.com/v8/v8 "refs/tags/${v8_version}") -deps="$(mktemp)" +path=$(echo "$prefetched" | jq -r .path) +sha256=$(echo "$prefetched" | jq -r .sha256) +sed -e "s#\\(version = \\)\"[0-9\.]*\"#\1\"$v8_version\"#" -i ${file_path} +sed -e "/v8Src = fetchgit/ { n; n; n; s/\".*\"/\"${sha256}\"/ }" -i ${file_path} -curl -s -o "$deps" "https://raw.githubusercontent.com/v8/v8/${v8_version}/DEPS" -echo $deps +deps="$path/DEPS" -sed -ne '/= fetchgit {/ { s/.*"\(.*\)".*/\1/; p }' < ${FILE_PATH} | while read dep; do +echo "$deps" + +echo "Processing gn" +gn_rev=$(sed -ne "s/.*'gn_version': 'git_revision:\([^']*\).*/\1/p" < "$deps") +gn_sha256=$(nix-prefetch-git --no-deepClone https://gn.googlesource.com/gn "$gn_rev" 2>/dev/null | jq -r .sha256) +sed -e "/gnSrc = fetchgit/ { n; n; s/\".*\"/\"${gn_rev}\"/; n; s/\".*\"/\"${gn_sha256}\"/ }" -i ${file_path} + +sed -ne '/" = fetchgit {/ { s/.*"\(.*\)".*/\1/; p }' < ${file_path} | while read dep; do echo "Processing dependency --> $dep" escaped_dep=$(echo "$dep" | sed -e 's#/#\\/#g') - dep_rev=$(sed -ne "/\"v8\/${escaped_dep}\":/ { n; s#.*+ \"##; s#\".*##; p }" "$deps") + dep_rev=$(sed -ne "/'${escaped_dep}':/ { n; s#.*+ '##; s#'.*##; p }" "$deps") if [ "$dep_rev" = "" ]; then echo "Failed to resolve dependency $dep, not listed in DEPS file" @@ -31,8 +47,8 @@ sed -ne '/= fetchgit {/ { s/.*"\(.*\)".*/\1/; p }' < ${FILE_PATH} | while read d exit 2 fi - repo_url=$(sed -ne "/\"${escaped_dep}\" = fetchgit/ { n; s/.*\"\(.*\)\".*/\1/; s#\${git_url}#https://chromium.googlesource.com#; p }" ${FILE_PATH}) - sha256=$(nix-prefetch-git --no-deepClone "$repo_url" "$dep_rev" 2>/dev/null | sed -ne '/sha256/ { s#.*: "\(.*\)".*#\1#; p }') + repo_url=$(sed -ne "/\"${escaped_dep}\" = fetchgit/ { n; s/.*\"\(.*\)\".*/\1/; s#\${git_url}#https://chromium.googlesource.com#; p }" ${file_path}) + sha256=$(nix-prefetch-git --no-deepClone "$repo_url" "$dep_rev" 2>/dev/null | jq -r .sha256) if [ "$sha256" = "" ]; then echo "Failed to get sha256 via nix-prefetch-git $repo_url $dep_rev" @@ -40,8 +56,7 @@ sed -ne '/= fetchgit {/ { s/.*"\(.*\)".*/\1/; p }' < ${FILE_PATH} | while read d exit 2 fi - sed -e "/\"${escaped_dep}\" = fetchgit/ { n; n; s/\".*\"/\"${dep_rev}\"/; n; s/\".*\"/\"${sha256}\"/ }" -i ${FILE_PATH} + sed -e "/\"${escaped_dep}\" = fetchgit/ { n; n; s/\".*\"/\"${dep_rev}\"/; n; s/\".*\"/\"${sha256}\"/ }" -i ${file_path} done -rm -f "$deps" echo done. diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 730df49ba6b9..e459341c5b88 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -20194,9 +20194,7 @@ with pkgs; stdenv = gcc6Stdenv; }); - v8 = callPackage ../development/libraries/v8 { - inherit (python2Packages) python; - }; + v8 = callPackage ../development/libraries/v8 { }; vaapiIntel = callPackage ../development/libraries/vaapi-intel { }; From 4c9323384591a24eefe5fc67c38e17f8dbe932b5 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Sat, 8 Jan 2022 15:29:50 +0300 Subject: [PATCH 2/5] v8_5_x: remove Not used in the tree anymore. --- pkgs/development/libraries/v8/5_x.nix | 199 ------------------ .../libraries/v8/libv8-5.4.232.patch | 97 --------- pkgs/top-level/all-packages.nix | 8 - 3 files changed, 304 deletions(-) delete mode 100644 pkgs/development/libraries/v8/5_x.nix delete mode 100644 pkgs/development/libraries/v8/libv8-5.4.232.patch diff --git a/pkgs/development/libraries/v8/5_x.nix b/pkgs/development/libraries/v8/5_x.nix deleted file mode 100644 index 441a5559b527..000000000000 --- a/pkgs/development/libraries/v8/5_x.nix +++ /dev/null @@ -1,199 +0,0 @@ -{ stdenv, lib, fetchgit, fetchFromGitHub, gyp, readline, python, which, icu -, patchelf, coreutils, xcbuild -, doCheck ? false -, static ? false -}: - -assert readline != null; - -let - arch = if stdenv.isx86_64 then "x64" - else if stdenv.isi686 then "ia32" - else if stdenv.isAarch64 then "arm64" - else if stdenv.isAarch32 then "arm" - else throw "Unknown architecture for v8"; - git_url = "https://chromium.googlesource.com"; - clangFlag = if stdenv.isDarwin then "1" else "0"; - sharedFlag = if static then "static_library" else "shared_library"; - - deps = { - build = fetchgit { - url = "${git_url}/chromium/src/build.git"; - rev = "2c67d4d74b6b3673228fab191918500a582ef3b0"; - sha256 = "0jc7hci5yh792pw0ahjfxrk5xzllnlrv9llmwlgcgn2x8x6bn34q"; - }; - "tools/gyp" = fetchgit { - url = "${git_url}/external/gyp.git"; - rev = "e7079f0e0e14108ab0dba58728ff219637458563"; - sha256 = "0yd1ds13z0r9d2sb67f9i1gjn1zgzwyfv96qqqp6pn5pcfbialg6"; - }; - "third_party/icu" = fetchgit { - url = "${git_url}/chromium/deps/icu.git"; - rev = "b5ecbb29a26532f72ef482569b223d5a51fd50bf"; - sha256 = "0ld47wdnk8grcba221z67l3pnphv9zwifk4y44f5b946w3iwmpns"; - }; - buildtools = fetchgit { - url = "${git_url}/chromium/buildtools.git"; - rev = "60f7f9a8b421ebf9a46041dfa2ff11c0fe59c582"; - sha256 = "0i10bw7yhslklqwcx5krs3k05sicb73cpwd0mkaz96yxsvmkvjq0"; - }; - "base/trace_event/common" = fetchgit { - url = "${git_url}/chromium/src/base/trace_event/common.git"; - rev = "315bf1e2d45be7d53346c31cfcc37424a32c30c8"; - sha256 = "1pp2ygvp20j6g4868hrmiw0j704kdvsi9d9wx2gbk7w79rc36695"; - }; - "platform/inspector_protocol" = fetchgit { - url = "${git_url}/chromium/src/third_party/WebKit/Source/platform/inspector_protocol.git"; - rev = "f49542089820a34a9a6e33264e09b73779407512"; - sha256 = "1lwpass3p4rpp2kjmxxxpkqyv4lznxhf4i0yy7mmrd7jkpc7kn8k"; - }; - "tools/mb" = fetchgit { - url = "${git_url}/chromium/src/tools/mb.git"; - rev = "0c4dc43c454f26936ddf3074ab8e9a41e3dc03a3"; - sha256 = "0f96qphbmwn1pprv0a6xf68p01s1jzx2sz6pmadqbrs1dgh1xwnk"; - }; - "tools/swarming_client" = fetchgit { - url = "${git_url}/external/swarming.client.git"; - rev = "7f63a272f7d9785ce41b6d10bb3106c49a968e57"; - sha256 = "1pmb8bq4qifjf2dzz8c4jdwhlvwgrl9ycjaalcyh1sbh4lx3yvv2"; - }; - "testing/gtest" = fetchgit { - url = "${git_url}/external/github.com/google/googletest.git"; - rev = "6f8a66431cb592dad629028a50b3dd418a408c87"; - sha256 = "0bdba2lr6pg15bla9600zg0r0vm4lnrx0wqz84p376wfdxra24vw"; - }; - "testing/gmock" = fetchgit { - url = "${git_url}/external/googlemock.git"; - rev = "0421b6f358139f02e102c9c332ce19a33faf75be"; - sha256 = "1xiky4v98maxs8fg1avcd56y0alv3hw8qyrlpd899zgzbq2k10pp"; - }; - "test/benchmarks/data" = fetchgit { - url = "${git_url}/v8/deps/third_party/benchmarks.git"; - rev = "05d7188267b4560491ff9155c5ee13e207ecd65f"; - sha256 = "0ad2ay14bn67d61ks4dmzadfnhkj9bw28r4yjdjjyzck7qbnzchl"; - }; - "test/mozilla/data" = fetchgit { - url = "${git_url}/v8/deps/third_party/mozilla-tests.git"; - rev = "f6c578a10ea707b1a8ab0b88943fe5115ce2b9be"; - sha256 = "0rfdan76yfawqxbwwb35aa57b723j3z9fx5a2w16nls02yk2kqyn"; - }; - "test/simdjs/data" = fetchgit { - url = "${git_url}/external/github.com/tc39/ecmascript_simd.git"; - rev = "baf493985cb9ea7cdbd0d68704860a8156de9556"; - sha256 = "178r0k40a58c1187gfzqz2i6as34l8cliy1g1x870wyy0qcvlq2q"; - }; - "test/test262/data" = fetchgit { - url = "${git_url}/external/github.com/tc39/test262.git"; - rev = "88bc7fe7586f161201c5f14f55c9c489f82b1b67"; - sha256 = "0gc7fmaqrgwb6rl02jnrm3synpwzzg0dfqy3zm386r1qcisl93xs"; - }; - "test/test262/harness" = fetchgit { - url = "${git_url}/external/github.com/test262-utils/test262-harness-py.git"; - rev = "cbd968f54f7a95c6556d53ba852292a4c49d11d8"; - sha256 = "094c3600a4wh1m3fvvlivn290kik1pzzvwabq77lk8bh4jkkv7ki"; - }; - "tools/clang" = fetchgit { - url = "${git_url}/chromium/src/tools/clang.git"; - rev = "496622ab4aaa5be7e5a9b80617013cb02f45dc87"; - sha256 = "1gkhk2bzpxwzkirzcqfixxpprbr8mn6rk00krm25daarm3smydmf"; - }; - }; - -in - -stdenv.mkDerivation rec { - pname = "v8"; - version = "5.4.232"; - - inherit doCheck; - - src = fetchFromGitHub { - owner = "v8"; - repo = "v8"; - rev = version; - sha256 = "1nqxbkz75m8xrjih0sj3f3iqvif4192vxdaxzy8r787rihjwg9nx"; - }; - - postUnpack = '' - ${lib.concatStringsSep "\n" ( - lib.mapAttrsToList (n: v: '' - mkdir -p $sourceRoot/${n} - cp -r ${v}/* $sourceRoot/${n} - '') deps)} - ''; - - # Patch based off of: - # https://github.com/cowboyd/libv8/tree/v5.1.281.67.0/patches - patches = lib.optional (!doCheck) ./libv8-5.4.232.patch; - - postPatch = '' - sed -i 's,#!/usr/bin/env python,#!${python}/bin/python,' gypfiles/gyp_v8 - sed -i 's,/bin/echo,${coreutils}/bin/echo,' gypfiles/standalone.gypi - sed -i '/CR_CLANG_REVISION/ d' gypfiles/standalone.gypi - sed -i 's/-Wno-format-pedantic//g' gypfiles/standalone.gypi - ''; - - configurePhase = '' - PYTHONPATH="tools/generate_shim_headers:$PYTHONPATH" \ - PYTHONPATH="$(toPythonPath ${gyp}):$PYTHONPATH" \ - gypfiles/gyp_v8 \ - -f make \ - --generator-output="out" \ - -Dflock_index=0 \ - -Dclang=${clangFlag} \ - -Dv8_enable_i18n_support=1 \ - -Duse_system_icu=1 \ - -Dcomponent=${sharedFlag} \ - -Dconsole=readline \ - -Dv8_target_arch=${arch} \ - -Dv8_use_external_startup_data=0 - ''; - - nativeBuildInputs = [ which ]; - buildInputs = [ readline python icu ] - ++ lib.optional stdenv.isDarwin xcbuild - ++ lib.optional stdenv.isLinux patchelf; - - NIX_CFLAGS_COMPILE = "-Wno-error=strict-overflow -Wno-error=unused-function -Wno-error=attributes" - + lib.optionalString stdenv.cc.isClang " -Wno-error=unused-lambda-capture"; - - buildFlags = [ - "LINK=c++" - "-C out" - "builddir=$(CURDIR)/Release" - "BUILDTYPE=Release" - ]; - - enableParallelBuilding = true; - - dontUpdateAutotoolsGnuConfigScripts = if stdenv.isAarch64 then true else null; - - # the `libv8_libplatform` target is _only_ built as a static library, - # and is expected to be statically linked in when needed. - # see the following link for further commentary: - # https://github.com/cowboyd/therubyracer/issues/391 - installPhase = '' - install -vD out/Release/d8 "$out/bin/d8" - install -vD out/Release/mksnapshot "$out/bin/mksnapshot" - ${if static then "" - else if stdenv.isDarwin then '' - install -vD out/Release/libv8.dylib "$out/lib/libv8.dylib" - install_name_tool -change /usr/local/lib/libv8.dylib $out/lib/libv8.dylib -change /usr/lib/libgcc_s.1.dylib ${stdenv.cc.cc.lib}/lib/libgcc_s.1.dylib $out/bin/d8 - install_name_tool -id $out/lib/libv8.dylib -change /usr/lib/libgcc_s.1.dylib ${stdenv.cc.cc.lib}/lib/libgcc_s.1.dylib $out/lib/libv8.dylib - '' else '' - install -vD out/Release/lib.target/libv8.so "$out/lib/libv8.so" - ''} - mkdir -p "$out/include" - cp -vr include/*.h "$out/include" - cp -vr include/libplatform "$out/include" - mkdir -p "$out/lib" - cp -v out/Release/*.a "$out/lib" - ''; - - meta = with lib; { - description = "Google's open source JavaScript engine"; - maintainers = with maintainers; [ cstrahan proglodyte ]; - platforms = platforms.linux ++ platforms.darwin; - license = licenses.bsd3; - }; -} diff --git a/pkgs/development/libraries/v8/libv8-5.4.232.patch b/pkgs/development/libraries/v8/libv8-5.4.232.patch deleted file mode 100644 index 16c227cfe38d..000000000000 --- a/pkgs/development/libraries/v8/libv8-5.4.232.patch +++ /dev/null @@ -1,97 +0,0 @@ -From c9f42d1314c6026efcfcc01824f4e2fdfd05ebcf Mon Sep 17 00:00:00 2001 -From: Ben Sklaroff -Date: Sat, 23 Jul 2016 18:16:55 -0400 -Subject: [PATCH] libv8-5.4.232 - ---- - Makefile | 5 +---- - gypfiles/all.gyp | 32 -------------------------------- - gypfiles/standalone.gypi | 5 ++++- - 3 files changed, 5 insertions(+), 37 deletions(-) - -diff --git a/Makefile b/Makefile -index 5ea5c58..d1b2d73 100644 ---- a/Makefile -+++ b/Makefile -@@ -261,11 +261,8 @@ GYPFILES = third_party/icu/icu.gypi third_party/icu/icu.gyp \ - gypfiles/shim_headers.gypi gypfiles/features.gypi \ - gypfiles/standalone.gypi \ - gypfiles/toolchain.gypi gypfiles/all.gyp gypfiles/mac/asan.gyp \ -- test/cctest/cctest.gyp test/fuzzer/fuzzer.gyp \ -- test/unittests/unittests.gyp src/v8.gyp \ -- tools/parser-shell.gyp testing/gmock.gyp testing/gtest.gyp \ - buildtools/third_party/libc++abi/libc++abi.gyp \ -- buildtools/third_party/libc++/libc++.gyp samples/samples.gyp \ -+ buildtools/third_party/libc++/libc++.gyp \ - src/third_party/vtune/v8vtune.gyp src/d8.gyp - - # If vtunejit=on, the v8vtune.gyp will be appended. -diff --git a/gypfiles/all.gyp b/gypfiles/all.gyp -index ff1bea4..96820a0 100644 ---- a/gypfiles/all.gyp -+++ b/gypfiles/all.gyp -@@ -16,38 +16,6 @@ - '../tools/parser-shell.gyp:parser-shell', - ], - }], -- # These items don't compile for Android on Mac. -- ['host_os!="mac" or OS!="android"', { -- 'dependencies': [ -- '../samples/samples.gyp:*', -- '../test/cctest/cctest.gyp:*', -- '../test/fuzzer/fuzzer.gyp:*', -- '../test/unittests/unittests.gyp:*', -- ], -- }], -- ['test_isolation_mode != "noop"', { -- 'dependencies': [ -- '../test/bot_default.gyp:*', -- '../test/benchmarks/benchmarks.gyp:*', -- '../test/default.gyp:*', -- '../test/ignition.gyp:*', -- '../test/intl/intl.gyp:*', -- '../test/message/message.gyp:*', -- '../test/mjsunit/mjsunit.gyp:*', -- '../test/mozilla/mozilla.gyp:*', -- '../test/optimize_for_size.gyp:*', -- '../test/perf.gyp:*', -- '../test/preparser/preparser.gyp:*', -- '../test/simdjs/simdjs.gyp:*', -- '../test/test262/test262.gyp:*', -- '../test/webkit/webkit.gyp:*', -- '../tools/check-static-initializers.gyp:*', -- '../tools/gcmole/run_gcmole.gyp:*', -- '../tools/jsfunfuzz/jsfunfuzz.gyp:*', -- '../tools/run-deopt-fuzzer.gyp:*', -- '../tools/run-valgrind.gyp:*', -- ], -- }], - ] - } - ] -diff --git a/gypfiles/standalone.gypi b/gypfiles/standalone.gypi -index 89f06a0..a43976d 100644 ---- a/gypfiles/standalone.gypi -+++ b/gypfiles/standalone.gypi -@@ -506,6 +506,9 @@ - }], # fastbuild!=0 - ], - 'target_conditions': [ -+ ['_type=="static_library"', { -+ 'standalone_static_library': 1, -+ }], - ['v8_code == 0', { - 'defines!': [ - 'DEBUG', -@@ -770,7 +773,7 @@ - [ 'visibility=="hidden" and v8_enable_backtrace==0', { - 'cflags': [ '-fvisibility=hidden' ], - }], -- [ 'component=="shared_library"', { -+ [ 'component=="shared_library" or component=="static_library" and (v8_target_arch=="x64" or v8_target_arch=="arm64" or v8_target_arch=="arm")', { - 'cflags': [ '-fPIC', ], - }], - [ 'clang==0 and coverage==1', { --- -2.9.0 - diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e459341c5b88..8114e0b1f11a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -20186,14 +20186,6 @@ with pkgs; gnutls = gnutls; }); - v8_5_x = callPackage ../development/libraries/v8/5_x.nix ({ - inherit (python2Packages) python gyp; - icu = icu58; # v8-5.4.232 fails against icu4c-59.1 - } // lib.optionalAttrs stdenv.isLinux { - # doesn't build with gcc7 - stdenv = gcc6Stdenv; - }); - v8 = callPackage ../development/libraries/v8 { }; vaapiIntel = callPackage ../development/libraries/vaapi-intel { }; From 7b161cef226d3eba674918d58bae77046d2fd91a Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Sat, 8 Jan 2022 15:35:04 +0300 Subject: [PATCH 3/5] v8_8_x: init at 8.8.278.14 --- pkgs/development/libraries/v8/8_x.nix | 169 ++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 171 insertions(+) create mode 100644 pkgs/development/libraries/v8/8_x.nix diff --git a/pkgs/development/libraries/v8/8_x.nix b/pkgs/development/libraries/v8/8_x.nix new file mode 100644 index 000000000000..5d95a0716eff --- /dev/null +++ b/pkgs/development/libraries/v8/8_x.nix @@ -0,0 +1,169 @@ +{ stdenv, lib, fetchgit, fetchFromGitHub +, gn, ninja, python3, glib, pkg-config, icu +, xcbuild, darwin +, fetchpatch +}: + +# Use update.sh to update all checksums. + +let + version = "8.8.278.14"; + v8Src = fetchgit { + url = "https://chromium.googlesource.com/v8/v8"; + rev = version; + sha256 = "0w6zldyas9w6p394876ssn3pnr5rjzjy1a5dcsmdkfj51m4rlg8m"; + }; + + git_url = "https://chromium.googlesource.com"; + + # This data is from the DEPS file in the root of a V8 checkout. + deps = { + "base/trace_event/common" = fetchgit { + url = "${git_url}/chromium/src/base/trace_event/common.git"; + rev = "eb94f1c7aa96207f469008f29989a43feb2718f8"; + sha256 = "14gym38ncc9cysknv3jrql7jvcpjxf2d1dh4m8jgqb967jyzy5cj"; + }; + "build" = fetchgit { + url = "${git_url}/chromium/src/build.git"; + rev = "2101eff1ac4bfd25f2dfa71ad632a600a38c1ed9"; + sha256 = "0i3xcwzi4pkv4xpgjkbmcpj5h6mji80zqskkx0jx3sx0ji63fylz"; + }; + "third_party/googletest/src" = fetchgit { + url = "${git_url}/external/github.com/google/googletest.git"; + rev = "4fe018038f87675c083d0cfb6a6b57c274fb1753"; + sha256 = "1ilm9dmnm2v4y6l1wyfsajsbqv56j29ldfbpd0ykg4q90gpxz201"; + }; + "third_party/icu" = fetchgit { + url = "${git_url}/chromium/deps/icu.git"; + rev = "c2a4cae149aae7fd30c4cbe3cf1b30df03b386f1"; + sha256 = "0lgzxf7hmfsgqazs74v5li9ifg8r0jx5m3gxh1mnw33vpwp7qqf4"; + }; + "third_party/zlib" = fetchgit { + url = "${git_url}/chromium/src/third_party/zlib.git"; + rev = "e84c9a3fd75fdc39055b7ae27d6ec508e50bd39e"; + sha256 = "03z30djnb3srhd0nvlxvx58sjqm2bvxk7j3vp4fk6h7a0sa2bdpi"; + }; + "third_party/jinja2" = fetchgit { + url = "${git_url}/chromium/src/third_party/jinja2.git"; + rev = "a82a4944a7f2496639f34a89c9923be5908b80aa"; + sha256 = "02mkjwkrzhrg16zx97z792l0faz7gc8vga8w10r5y94p98jymnyz"; + }; + "third_party/markupsafe" = fetchgit { + url = "${git_url}/chromium/src/third_party/markupsafe.git"; + rev = "0944e71f4b2cb9a871bcbe353f95e889b64a611a"; + sha256 = "052ij8i7nkqchbvzv6ykj929hvfxjbzq7az2l01r0l2gfazhvdb9"; + }; + }; + + # See `gn_version` in DEPS. + gnSrc = fetchgit { + url = "https://gn.googlesource.com/gn"; + rev = "53d92014bf94c3893886470a1c7c1289f8818db0"; + sha256 = "1xcm07qjk6m2czi150fiqqxql067i832adck6zxrishm70c9jbr9"; + }; + + myGn = gn.overrideAttrs (oldAttrs: { + version = "for-v8"; + src = gnSrc; + }); + +in + +stdenv.mkDerivation rec { + pname = "v8"; + inherit version; + + doCheck = true; + + patches = [ + ./darwin.patch + ]; + + src = v8Src; + + postUnpack = '' + ${lib.concatStringsSep "\n" ( + lib.mapAttrsToList (n: v: '' + mkdir -p $sourceRoot/${n} + cp -r ${v}/* $sourceRoot/${n} + '') deps)} + chmod u+w -R . + ''; + + postPatch = '' + ${lib.optionalString stdenv.isAarch64 '' + substituteInPlace build/toolchain/linux/BUILD.gn \ + --replace 'toolprefix = "aarch64-linux-gnu-"' 'toolprefix = ""' + ''} + ${lib.optionalString stdenv.isDarwin '' + substituteInPlace build/config/compiler/compiler.gni \ + --replace 'strip_absolute_paths_from_debug_symbols = true' \ + 'strip_absolute_paths_from_debug_symbols = false' + substituteInPlace build/config/compiler/BUILD.gn \ + --replace 'current_toolchain == host_toolchain || !use_xcode_clang' \ + 'false' + ''} + echo 'checkout_google_benchmark = false' > build/config/gclient_args.gni + ''; + + gnFlags = [ + "use_custom_libcxx=false" + "is_clang=${lib.boolToString stdenv.cc.isClang}" + "use_sysroot=false" + # "use_system_icu=true" + "clang_use_chrome_plugins=false" + "is_component_build=false" + "v8_use_external_startup_data=false" + "v8_monolithic=true" + "is_debug=true" + "is_official_build=false" + "treat_warnings_as_errors=false" + "v8_enable_i18n_support=true" + "use_gold=false" + # ''custom_toolchain="//build/toolchain/linux/unbundle:default"'' + ''host_toolchain="//build/toolchain/linux/unbundle:default"'' + ''v8_snapshot_toolchain="//build/toolchain/linux/unbundle:default"'' + ] ++ lib.optional stdenv.cc.isClang ''clang_base_path="${stdenv.cc}"''; + + NIX_CFLAGS_COMPILE = "-O2"; + FORCE_MAC_SDK_MIN = stdenv.targetPlatform.sdkVer or "10.12"; + + nativeBuildInputs = [ + myGn + ninja + pkg-config + python3 + ] ++ lib.optionals stdenv.isDarwin [ + xcbuild + darwin.DarwinTools + python3.pkgs.setuptools + ]; + buildInputs = [ glib icu ]; + + ninjaFlags = [ ":d8" "v8_monolith" ]; + + enableParallelBuilding = true; + + installPhase = '' + install -D d8 $out/bin/d8 + install -D -m644 obj/libv8_monolith.a $out/lib/libv8.a + install -D -m644 icudtl.dat $out/share/v8/icudtl.dat + cp -r ../../include $out + + mkdir -p $out/lib/pkgconfig + cat > $out/lib/pkgconfig/v8.pc << EOF + Name: v8 + Description: V8 JavaScript Engine + Version: ${version} + Libs: -L$out/lib -lv8 -pthread + Cflags: -I$out/include + EOF + ''; + + meta = with lib; { + description = "Google's open source JavaScript engine"; + maintainers = with maintainers; [ cstrahan proglodyte matthewbauer ]; + platforms = platforms.unix; + license = licenses.bsd3; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8114e0b1f11a..e49d9577474d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -20188,6 +20188,8 @@ with pkgs; v8 = callPackage ../development/libraries/v8 { }; + v8_8_x = callPackage ../development/libraries/v8/8_x.nix { }; + vaapiIntel = callPackage ../development/libraries/vaapi-intel { }; vaapi-intel-hybrid = callPackage ../development/libraries/vaapi-intel-hybrid { }; From a4c6e9e084347417024fa1d175c9951de3c80166 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Sat, 8 Jan 2022 15:37:44 +0300 Subject: [PATCH 4/5] postgresqlPackages.plv8: 2.3.15 -> 3.0.0 Use v8 8.8.x. --- pkgs/servers/sql/postgresql/ext/plv8.nix | 14 ++++++++++---- pkgs/servers/sql/postgresql/packages.nix | 4 +++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pkgs/servers/sql/postgresql/ext/plv8.nix b/pkgs/servers/sql/postgresql/ext/plv8.nix index 6f5411340e45..3fc6460adadb 100644 --- a/pkgs/servers/sql/postgresql/ext/plv8.nix +++ b/pkgs/servers/sql/postgresql/ext/plv8.nix @@ -29,6 +29,8 @@ stdenv.mkDerivation rec { ]; preConfigure = '' + # We build V8 as a monolith, so this is unnecessary. + substituteInPlace Makefile.shared --replace "-lv8_libplatform" "" patchShebangs ./generate_upgrade.sh substituteInPlace generate_upgrade.sh \ --replace " 2.3.10)" " 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.15)" @@ -42,10 +44,14 @@ stdenv.mkDerivation rec { rmdir "$out/nix/store"/* "$out/nix/store" "$out/nix" ''; - # Without this, PostgreSQL will crash at runtime. - # The flags are only included in Makefile, not Makefile.shared. - # https://github.com/plv8/plv8/pull/469 - NIX_CFLAGS_COMPILE = "-DJSONB_DIRECT_CONVERSION -DV8_COMPRESS_POINTERS=1 -DV8_31BIT_SMIS_ON_64BIT_ARCH=1"; + NIX_CFLAGS_COMPILE = [ + # V8 depends on C++14. + "-std=c++14" + # Without this, PostgreSQL will crash at runtime. + # The flags are only included in Makefile, not Makefile.shared. + # https://github.com/plv8/plv8/pull/469 + "-DJSONB_DIRECT_CONVERSION" "-DV8_COMPRESS_POINTERS=1" "-DV8_31BIT_SMIS_ON_64BIT_ARCH=1" + ]; meta = with lib; { description = "V8 Engine Javascript Procedural Language add-on for PostgreSQL"; diff --git a/pkgs/servers/sql/postgresql/packages.nix b/pkgs/servers/sql/postgresql/packages.nix index e751ae621f32..f3df8a99ca22 100644 --- a/pkgs/servers/sql/postgresql/packages.nix +++ b/pkgs/servers/sql/postgresql/packages.nix @@ -26,7 +26,9 @@ self: super: { plr = super.callPackage ./ext/plr.nix { }; - plv8 = super.callPackage ./ext/plv8.nix { }; + plv8 = super.callPackage ./ext/plv8.nix { + v8 = self.v8_8_x; + }; pgjwt = super.callPackage ./ext/pgjwt.nix { }; From 2405472dd6c24a17fc8a63124ecb3b872f162160 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Sun, 9 Jan 2022 10:31:59 +0300 Subject: [PATCH 5/5] postgresqlPackages.plv8: add smoke test This ensures that PLV8 doesn't crash. --- pkgs/servers/sql/postgresql/ext/plv8.nix | 30 +++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/pkgs/servers/sql/postgresql/ext/plv8.nix b/pkgs/servers/sql/postgresql/ext/plv8.nix index 3fc6460adadb..eaf9c389e926 100644 --- a/pkgs/servers/sql/postgresql/ext/plv8.nix +++ b/pkgs/servers/sql/postgresql/ext/plv8.nix @@ -1,6 +1,8 @@ -{ lib, stdenv, fetchFromGitHub, v8, perl, postgresql }: +{ lib, stdenv, fetchFromGitHub, v8, perl, postgresql +# For test +, runCommand, coreutils, gnugrep }: -stdenv.mkDerivation rec { +let self = stdenv.mkDerivation rec { pname = "plv8"; version = "3.0.0"; @@ -53,6 +55,28 @@ stdenv.mkDerivation rec { "-DJSONB_DIRECT_CONVERSION" "-DV8_COMPRESS_POINTERS=1" "-DV8_31BIT_SMIS_ON_64BIT_ARCH=1" ]; + passthru.tests.smoke = runCommand "${pname}-test" {} '' + export PATH=${lib.makeBinPath [ (postgresql.withPackages (_: [self])) coreutils gnugrep ]} + db="$PWD/testdb" + initdb "$db" + postgres -k "$db" -D "$db" & + pid="$!" + + for i in $(seq 1 100); do + if psql -h "$db" -d postgres -c "" 2>/dev/null; then + break + elif ! kill -0 "$pid"; then + exit 1 + else + sleep 0.1 + fi + done + + psql -h "$db" -d postgres -c 'CREATE EXTENSION plv8; DO $$ plv8.elog(NOTICE, plv8.version); $$ LANGUAGE plv8;' 2> "$out" + grep -q "${version}" "$out" + kill -0 "$pid" + ''; + meta = with lib; { description = "V8 Engine Javascript Procedural Language add-on for PostgreSQL"; homepage = "https://plv8.github.io/"; @@ -60,4 +84,4 @@ stdenv.mkDerivation rec { platforms = [ "x86_64-linux" ]; license = licenses.postgresql; }; -} +}; in self