summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEfraim Flashner <efraim@flashner.co.il>2025-03-10 22:50:32 +0200
committerEfraim Flashner <efraim@flashner.co.il>2025-03-13 14:34:59 +0200
commit64cc1353bb6816360710b9f6eea0e0453dd3db18 (patch)
tree8759608ce8db510cf554c50dfca47ebf0dbbb9aa
parent2650a32e7aba3eedb277b6ad2aec64edd6e5c0de (diff)
fixup node-12 riscv64 support
Change-Id: I1ff6a30a614ade6e82d44e3f2fe20530c93fc7c5
-rw-r--r--gnu/packages/node.scm2
-rw-r--r--gnu/packages/patches/node-12-riscv64-support.patch133
2 files changed, 124 insertions, 11 deletions
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 5eb2323f6ef..edaaa74993b 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -404,6 +404,8 @@ devices.")
404 ;; Run only the CI tests. The default test target requires additional 404 ;; Run only the CI tests. The default test target requires additional
405 ;; add-ons from NPM that are not distributed with the source. 405 ;; add-ons from NPM that are not distributed with the source.
406 #:test-target "test-ci-js" 406 #:test-target "test-ci-js"
407 ;; For now
408 #:tests? ,(not (target-riscv64?))
407 ;; Some of the tests can timeout under heavy load. 409 ;; Some of the tests can timeout under heavy load.
408 #:parallel-tests? ,(target-x86?) 410 #:parallel-tests? ,(target-x86?)
409 #:modules 411 #:modules
diff --git a/gnu/packages/patches/node-12-riscv64-support.patch b/gnu/packages/patches/node-12-riscv64-support.patch
index 1450c228ae7..18002f74485 100644
--- a/gnu/packages/patches/node-12-riscv64-support.patch
+++ b/gnu/packages/patches/node-12-riscv64-support.patch
@@ -1,5 +1,5 @@
1diff --git a/Makefile b/Makefile 1diff --git a/Makefile b/Makefile
2index b8986e9a3c1..4768b4d1fff 100644 2index b8986e9a3c1..abdacdbcc9a 100644
3--- a/Makefile 3--- a/Makefile
4+++ b/Makefile 4+++ b/Makefile
5@@ -843,6 +843,9 @@ else 5@@ -843,6 +843,9 @@ else
@@ -20,6 +20,24 @@ index b8986e9a3c1..4768b4d1fff 100644
20 ifeq ($(DESTCPU),x64) 20 ifeq ($(DESTCPU),x64)
21 ARCH=x64 21 ARCH=x64
22 else 22 else
23@@ -883,6 +887,9 @@ else
24 ifeq ($(DESTCPU),s390x)
25 ARCH=s390x
26 else
27+ifeq ($(DESTCPU),riscv64)
28+ARCH=riscv64
29+else
30 ARCH=x86
31 endif
32 endif
33@@ -891,6 +898,7 @@ endif
34 endif
35 endif
36 endif
37+endif
38
39 # node and v8 use different arch names (e.g. node 'x86' vs v8 'ia32').
40 # pass the proper v8 arch name to $V8_ARCH based on user-specified $DESTCPU.
23diff --git a/configure.py b/configure.py 41diff --git a/configure.py b/configure.py
24index e6485a7b383..a557a22de28 100755 42index e6485a7b383..a557a22de28 100755
25--- a/configure.py 43--- a/configure.py
@@ -341,7 +359,7 @@ index c50cdd7a98e..d35c2a1fbb1 100644
341 #error Unsupported host architecture. 359 #error Unsupported host architecture.
342 #endif 360 #endif
343diff --git a/deps/v8/src/builtins/builtins-sharedarraybuffer-gen.cc b/deps/v8/src/builtins/builtins-sharedarraybuffer-gen.cc 361diff --git a/deps/v8/src/builtins/builtins-sharedarraybuffer-gen.cc b/deps/v8/src/builtins/builtins-sharedarraybuffer-gen.cc
344index 8ae89187ecb..de9948e38fe 100644 362index 8ae89187ecb..aa74f6d4aac 100644
345--- a/deps/v8/src/builtins/builtins-sharedarraybuffer-gen.cc 363--- a/deps/v8/src/builtins/builtins-sharedarraybuffer-gen.cc
346+++ b/deps/v8/src/builtins/builtins-sharedarraybuffer-gen.cc 364+++ b/deps/v8/src/builtins/builtins-sharedarraybuffer-gen.cc
347@@ -322,7 +322,7 @@ TF_BUILTIN(AtomicsExchange, SharedArrayBufferBuiltinsAssembler) { 365@@ -322,7 +322,7 @@ TF_BUILTIN(AtomicsExchange, SharedArrayBufferBuiltinsAssembler) {
@@ -353,6 +371,15 @@ index 8ae89187ecb..de9948e38fe 100644
353 Return(CallRuntime(Runtime::kAtomicsExchange, context, array, index_integer, 371 Return(CallRuntime(Runtime::kAtomicsExchange, context, array, index_integer,
354 value)); 372 value));
355 #else 373 #else
374@@ -405,7 +405,7 @@ TF_BUILTIN(AtomicsExchange, SharedArrayBufferBuiltinsAssembler) {
375 // This shouldn't happen, we've already validated the type.
376 BIND(&other);
377 Unreachable();
378-#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
379+#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_RISCV64
380 }
381
382 TF_BUILTIN(AtomicsCompareExchange, SharedArrayBufferBuiltinsAssembler) {
356@@ -425,7 +425,8 @@ TF_BUILTIN(AtomicsCompareExchange, SharedArrayBufferBuiltinsAssembler) { 383@@ -425,7 +425,8 @@ TF_BUILTIN(AtomicsCompareExchange, SharedArrayBufferBuiltinsAssembler) {
357 ValidateAtomicIndex(array, index_word32, context); 384 ValidateAtomicIndex(array, index_word32, context);
358 385
@@ -363,7 +390,15 @@ index 8ae89187ecb..de9948e38fe 100644
363 Return(CallRuntime(Runtime::kAtomicsCompareExchange, context, array, 390 Return(CallRuntime(Runtime::kAtomicsCompareExchange, context, array,
364 index_integer, old_value, new_value)); 391 index_integer, old_value, new_value));
365 #else 392 #else
366@@ -555,7 +556,8 @@ void SharedArrayBufferBuiltinsAssembler::AtomicBinopBuiltinCommon( 393@@ -523,6 +524,7 @@ TF_BUILTIN(AtomicsCompareExchange, SharedArrayBufferBuiltinsAssembler) {
394 Unreachable();
395 #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64
396 // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X
397+ // || V8_TARGET_ARCH_RISCV64
398 }
399
400 #define BINOP_BUILTIN(op) \
401@@ -555,7 +557,8 @@ void SharedArrayBufferBuiltinsAssembler::AtomicBinopBuiltinCommon(
367 ValidateAtomicIndex(array, index_word32, context); 402 ValidateAtomicIndex(array, index_word32, context);
368 403
369 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \ 404 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \
@@ -373,6 +408,14 @@ index 8ae89187ecb..de9948e38fe 100644
373 Return(CallRuntime(runtime_function, context, array, index_integer, value)); 408 Return(CallRuntime(runtime_function, context, array, index_integer, value));
374 #else 409 #else
375 TNode<UintPtrT> index_word = ChangeUint32ToWord(index_word32); 410 TNode<UintPtrT> index_word = ChangeUint32ToWord(index_word32);
411@@ -642,6 +645,7 @@ void SharedArrayBufferBuiltinsAssembler::AtomicBinopBuiltinCommon(
412 Unreachable();
413 #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64
414 // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X
415+ // || V8_TARGET_ARCH_RISCV64
416 }
417
418 } // namespace internal
376diff --git a/deps/v8/src/builtins/riscv64/builtins-riscv64.cc b/deps/v8/src/builtins/riscv64/builtins-riscv64.cc 419diff --git a/deps/v8/src/builtins/riscv64/builtins-riscv64.cc b/deps/v8/src/builtins/riscv64/builtins-riscv64.cc
377new file mode 100644 420new file mode 100644
378index 00000000000..685f575598f 421index 00000000000..685f575598f
@@ -4453,10 +4496,10 @@ index 00000000000..b99262cb367
4453+#endif // V8_CODEGEN_RISCV64_ASSEMBLER_RISCV64_INL_H_ 4496+#endif // V8_CODEGEN_RISCV64_ASSEMBLER_RISCV64_INL_H_
4454diff --git a/deps/v8/src/codegen/riscv64/assembler-riscv64.cc b/deps/v8/src/codegen/riscv64/assembler-riscv64.cc 4497diff --git a/deps/v8/src/codegen/riscv64/assembler-riscv64.cc b/deps/v8/src/codegen/riscv64/assembler-riscv64.cc
4455new file mode 100644 4498new file mode 100644
4456index 00000000000..e070e72f45e 4499index 00000000000..c66081657b0
4457--- /dev/null 4500--- /dev/null
4458+++ b/deps/v8/src/codegen/riscv64/assembler-riscv64.cc 4501+++ b/deps/v8/src/codegen/riscv64/assembler-riscv64.cc
4459@@ -0,0 +1,3020 @@ 4502@@ -0,0 +1,3024 @@
4460+// Copyright (c) 1994-2006 Sun Microsystems Inc. 4503+// Copyright (c) 1994-2006 Sun Microsystems Inc.
4461+// All Rights Reserved. 4504+// All Rights Reserved.
4462+// 4505+//
@@ -4491,14 +4534,16 @@ index 00000000000..e070e72f45e
4491+// modified significantly by Google Inc. 4534+// modified significantly by Google Inc.
4492+// Copyright 2021 the V8 project authors. All rights reserved. 4535+// Copyright 2021 the V8 project authors. All rights reserved.
4493+ 4536+
4494+#if V8_TARGET_ARCH_RISCV64
4495+
4496+#include "src/codegen/riscv64/assembler-riscv64.h" 4537+#include "src/codegen/riscv64/assembler-riscv64.h"
4497+ 4538+
4539+#if V8_TARGET_ARCH_RISCV64
4540+
4498+#include "src/base/cpu.h" 4541+#include "src/base/cpu.h"
4499+#include "src/codegen/riscv64/assembler-riscv64-inl.h" 4542+#include "src/codegen/riscv64/assembler-riscv64-inl.h"
4543+#include "src/codegen/register-configuration.h"
4500+#include "src/codegen/safepoint-table.h" 4544+#include "src/codegen/safepoint-table.h"
4501+#include "src/codegen/string-constants.h" 4545+#include "src/codegen/string-constants.h"
4546+#include "src/execution/frame-constants.h"
4502+#include "src/deoptimizer/deoptimizer.h" 4547+#include "src/deoptimizer/deoptimizer.h"
4503+#include "src/diagnostics/disasm.h" 4548+#include "src/diagnostics/disasm.h"
4504+#include "src/diagnostics/disassembler.h" 4549+#include "src/diagnostics/disassembler.h"
@@ -4584,6 +4629,8 @@ index 00000000000..e070e72f45e
4584+// Implementation of RelocInfo. 4629+// Implementation of RelocInfo.
4585+ 4630+
4586+const int RelocInfo::kApplyMask = 4631+const int RelocInfo::kApplyMask =
4632+ RelocInfo::ModeMask(RelocInfo::CODE_TARGET) |
4633+ RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY) |
4587+ RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) | 4634+ RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) |
4588+ RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); 4635+ RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED);
4589+ 4636+
@@ -7479,10 +7526,10 @@ index 00000000000..e070e72f45e
7479+#endif // V8_TARGET_ARCH_RISCV64 7526+#endif // V8_TARGET_ARCH_RISCV64
7480diff --git a/deps/v8/src/codegen/riscv64/assembler-riscv64.h b/deps/v8/src/codegen/riscv64/assembler-riscv64.h 7527diff --git a/deps/v8/src/codegen/riscv64/assembler-riscv64.h b/deps/v8/src/codegen/riscv64/assembler-riscv64.h
7481new file mode 100644 7528new file mode 100644
7482index 00000000000..1dcf4e0aae1 7529index 00000000000..98d84918bc4
7483--- /dev/null 7530--- /dev/null
7484+++ b/deps/v8/src/codegen/riscv64/assembler-riscv64.h 7531+++ b/deps/v8/src/codegen/riscv64/assembler-riscv64.h
7485@@ -0,0 +1,1243 @@ 7532@@ -0,0 +1,1267 @@
7486+// Copyright (c) 1994-2006 Sun Microsystems Inc. 7533+// Copyright (c) 1994-2006 Sun Microsystems Inc.
7487+// All Rights Reserved. 7534+// All Rights Reserved.
7488+// 7535+//
@@ -7545,6 +7592,30 @@ index 00000000000..1dcf4e0aae1
7545+class SafepointTableBuilder; 7592+class SafepointTableBuilder;
7546+ 7593+
7547+// ----------------------------------------------------------------------------- 7594+// -----------------------------------------------------------------------------
7595+// Immediates.
7596+class Immediate {
7597+ public:
7598+ template <typename T>
7599+ inline explicit Immediate(
7600+ Handle<T> handle, RelocInfo::Mode mode = RelocInfo::FULL_EMBEDDED_OBJECT);
7601+
7602+ // This is allowed to be an implicit constructor because Immediate is
7603+ // a wrapper class that doesn't normally perform any type conversion.
7604+ template <typename T>
7605+ inline Immediate(T value); // NOLINT(runtime/explicit)
7606+
7607+ template <typename T>
7608+ inline Immediate(T value, RelocInfo::Mode rmode);
7609+
7610+ int64_t value() const { return value_; }
7611+ RelocInfo::Mode rmode() const { return rmode_; }
7612+
7613+ private:
7614+ int64_t value_;
7615+ RelocInfo::Mode rmode_;
7616+};
7617+
7618+// -----------------------------------------------------------------------------
7548+// Machine instruction Operands. 7619+// Machine instruction Operands.
7549+constexpr int kSmiShift = kSmiTagSize + kSmiShiftSize; 7620+constexpr int kSmiShift = kSmiTagSize + kSmiShiftSize;
7550+constexpr uint64_t kSmiShiftMask = (1UL << kSmiShift) - 1; 7621+constexpr uint64_t kSmiShiftMask = (1UL << kSmiShift) - 1;
@@ -10149,10 +10220,10 @@ index 00000000000..aad09378f99
10149+#endif // V8_TARGET_ARCH_RISCV64 10220+#endif // V8_TARGET_ARCH_RISCV64
10150diff --git a/deps/v8/src/codegen/riscv64/interface-descriptors-riscv64.cc b/deps/v8/src/codegen/riscv64/interface-descriptors-riscv64.cc 10221diff --git a/deps/v8/src/codegen/riscv64/interface-descriptors-riscv64.cc b/deps/v8/src/codegen/riscv64/interface-descriptors-riscv64.cc
10151new file mode 100644 10222new file mode 100644
10152index 00000000000..26730aceca7 10223index 00000000000..b2717d9fa87
10153--- /dev/null 10224--- /dev/null
10154+++ b/deps/v8/src/codegen/riscv64/interface-descriptors-riscv64.cc 10225+++ b/deps/v8/src/codegen/riscv64/interface-descriptors-riscv64.cc
10155@@ -0,0 +1,301 @@ 10226@@ -0,0 +1,323 @@
10156+// Copyright 2021 the V8 project authors. All rights reserved. 10227+// Copyright 2021 the V8 project authors. All rights reserved.
10157+// Use of this source code is governed by a BSD-style license that can be 10228+// Use of this source code is governed by a BSD-style license that can be
10158+// found in the LICENSE file. 10229+// found in the LICENSE file.
@@ -10217,6 +10288,11 @@ index 00000000000..26730aceca7
10217+ data->InitializePlatformSpecific(kParameterCount, default_stub_registers); 10288+ data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
10218+} 10289+}
10219+ 10290+
10291+const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
10292+ return a1;
10293+}
10294+const Register FastNewFunctionContextDescriptor::SlotsRegister() { return a0; }
10295+
10220+void DynamicCheckMapsDescriptor::InitializePlatformSpecific( 10296+void DynamicCheckMapsDescriptor::InitializePlatformSpecific(
10221+ CallInterfaceDescriptorData* data) { 10297+ CallInterfaceDescriptorData* data) {
10222+ Register default_stub_registers[] = {kReturnRegister0, a1, a2, a3, cp}; 10298+ Register default_stub_registers[] = {kReturnRegister0, a1, a2, a3, cp};
@@ -10374,6 +10450,12 @@ index 00000000000..26730aceca7
10374+ data->InitializePlatformSpecific(arraysize(registers), registers); 10450+ data->InitializePlatformSpecific(arraysize(registers), registers);
10375+} 10451+}
10376+ 10452+
10453+void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
10454+ CallInterfaceDescriptorData* data) {
10455+ // register state
10456+ data->InitializePlatformSpecific(0, nullptr);
10457+}
10458+
10377+void CompareDescriptor::InitializePlatformSpecific( 10459+void CompareDescriptor::InitializePlatformSpecific(
10378+ CallInterfaceDescriptorData* data) { 10460+ CallInterfaceDescriptorData* data) {
10379+ Register registers[] = {a1, a0}; 10461+ Register registers[] = {a1, a0};
@@ -10386,6 +10468,17 @@ index 00000000000..26730aceca7
10386+ data->InitializePlatformSpecific(arraysize(registers), registers); 10468+ data->InitializePlatformSpecific(arraysize(registers), registers);
10387+} 10469+}
10388+ 10470+
10471+void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
10472+ CallInterfaceDescriptorData* data) {
10473+ Register registers[] = {
10474+ a1, // JSFunction
10475+ a3, // the new target
10476+ a0, // actual number of arguments
10477+ a2, // expected number of arguments
10478+ };
10479+ data->InitializePlatformSpecific(arraysize(registers), registers);
10480+}
10481+
10389+void ApiCallbackDescriptor::InitializePlatformSpecific( 10482+void ApiCallbackDescriptor::InitializePlatformSpecific(
10390+ CallInterfaceDescriptorData* data) { 10483+ CallInterfaceDescriptorData* data) {
10391+ Register registers[] = { 10484+ Register registers[] = {
@@ -35898,3 +35991,21 @@ index e4778326a90..1fd0f464ef2 100644
35898 VARIABLES[var] = var 35991 VARIABLES[var] = var
35899 35992
35900 # Allow using variants as keywords. 35993 # Allow using variants as keywords.
35994diff --git a/tools/v8_gypfiles/toolchain.gypi b/tools/v8_gypfiles/toolchain.gypi
35995index 0876b16b46a..df96d605d41 100644
35996--- a/tools/v8_gypfiles/toolchain.gypi
35997+++ b/tools/v8_gypfiles/toolchain.gypi
35998@@ -271,6 +271,13 @@
35999 'V8_TARGET_ARCH_ARM64',
36000 ],
36001 }],
36002+ ['v8_target_arch=="riscv64"', {
36003+ 'defines': [
36004+ 'V8_TARGET_ARCH_RISCV64',
36005+ '__riscv_xlen=64',
36006+ 'CAN_USE_FPU_INSTRUCTIONS'
36007+ ],
36008+ }],
36009 ['v8_target_arch=="s390x"', {
36010 'defines': [
36011 'V8_TARGET_ARCH_S390',