-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deno build on riscv64 #18702
Comments
The errors from TypeScript LSP is perhaps caused by some path manipulation operations in In function function hexEncode(s) {
// helper function for debugging
let result = "";
for(let i=0; i < s.length; i++) {
let hex = s.charCodeAt(i).toString(16);
result += ("000" + hex).slice(-4);
}
return result;
}
function pathForLibFile(libFileName) {
const core = globalThis.Deno.core;
core.print(`entering pathForLibFile(${libFileName}): \n`);
const components = libFileName.split(".");
let path = components[1];
core.print(`!!!!! path = ${path}, components = ${components}\n`, true);
let i = 2;
while (components[i] && components[i] !== "d") {
let expr = (i === 2 ? "/" : "-") + components[i];
core.print(`!!!!! path += ${hexEncode(expr)}\n`, true);
path += expr;
i++;
}
const resolveFrom = combinePaths(currentDirectory, `__lib_node_modules_lookup_${libFileName}__.ts`);
core.print(`pathForLibFile(${libFileName}): \n defaultLibraryPath = ${defaultLibraryPath}\n resolveFrom = ${resolveFrom}\n path = ${path}\n`, true);
const localOverrideModuleResult = resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: 2 /* Node10 */ }, host, moduleResolutionCache);
if (localOverrideModuleResult == null ? void 0 : localOverrideModuleResult.resolvedModule) {
return localOverrideModuleResult.resolvedModule.resolvedFileName;
}
return combinePaths(defaultLibraryPath, libFileName);
} The while loop is producing wrong results on riscv64:
The log doesn't look nice. There are some extra characters:
It looks like a V8 bug. By explicitly using char codes I can workaround this bug: // while (components[i] && components[i] !== "d") {
while (components[i] && components[i].charCodeAt(0) !== 100) {
// let expr = (i === 2 ? "/" : "-") + components[i];
let expr;
if (i === 2)
expr = String.fromCharCode(47) + components[i];
else
expr = String.fromCharCode(45) + components[i]; But there are other places that have bugs about path manipulation operations. So only fixing this one place can't let that error go away. Any suggestions and helps will be well appreciated! |
Hello, I want to update the status of Deno on riscv64. On 1.33.1 denoland/rusty_v8#1209 is merged and released. The local _extra_gn_args=(
'custom_toolchain="//build/toolchain/linux/unbundle:default"'
'host_toolchain="//build/toolchain/linux/unbundle:default"'
)
export CC=clang CXX=clang++ AR=ar NM=nm
export CFLAGS="${CFLAGS//-fstack-clash-protection/}" CXXFLAGS="${CXXFLAGS//-fstack-clash-protection/}"
export V8_FROM_SOURCE=1
export CLANG_BASE_PATH=/usr
export GN=/usr/bin/gn NINJA=/usr/bin/ninja
export EXTRA_GN_ARGS="${_extra_gn_args[@]}"
export NO_PRINT_GN_ARGS=1 As a side note, V8's pointer compression on riscv64 is fixed in https://chromium-review.googlesource.com/c/v8/v8/+/4559353. If the aforementioned restriction is added back, Deno is likely to still work properly. |
Rust triple for riscv64 is riscv64gc. Although there are no official builds for architectures other than x86_64 and aarch64, Arch Linux RISC-V has managed to package Deno on riscv64: https://github.com/felixonmars/archriscv-packages/blob/master/deno/riscv64.patch Ref: #18702
What is the status of deno on riscv64 now that deno v2 is out? Any effort in progress? |
Pretty much usable AFAIK, at least on recent versions <2. 1.46.0 needs to disable pointer compression like before. Progress are tracked in Arch Linux RISC-V's deno patch against Arch Linux PKGBUILD (if this file does not exist then the original PKGBUILD will build fine.) As for Deno 2.0, I haven't looked at it yet, but as long as it doesn't have groundbreaking changes in (rusty-)V8, it should build and work with no to little effort of porting. |
Hello, I'm trying On some scripts I get echo 'import mqtt from "npm:mqtt"' | deno run - Through |
Hi @shodan8192 My guess is that your kernel/SBI on Lichee Pi Nano treats RVV 0.7 in C906 cores as RVV 1.0. Could you try upgrading OpenSBI and see if it works? |
My system report |
This is not statically compiled code, it's generated by V8. In terms of your question -- yes, it runs fine on Unmatched, and SG2042 (which has its RVV 0.7 hidden so application won't recognize it as RVV anymore) |
Now that's clear. I didn't knew that V8 make use of vector instructions if they're available, thats why I though they were generated by compiler. So I'll try to disable RVV 0.7 and make things work. Thanks @hack3ric ! |
Sorry for spam, but I can't get it to work on Lichee Pi Nano with 5.10 kernel. I've removed #include <sys/auxv.h>
#include <stdio.h>
#include <asm/hwcap.h>
void main() {
unsigned long hw_cap = getauxval(AT_HWCAP);
printf("I %s\n", hw_cap & COMPAT_HWCAP_ISA_I ? "detected" : "not found");
printf("M %s\n", hw_cap & COMPAT_HWCAP_ISA_M ? "detected" : "not found");
printf("A %s\n", hw_cap & COMPAT_HWCAP_ISA_A ? "detected" : "not found");
printf("F %s\n", hw_cap & COMPAT_HWCAP_ISA_F ? "detected" : "not found");
printf("D %s\n", hw_cap & COMPAT_HWCAP_ISA_D ? "detected" : "not found");
printf("C %s\n", hw_cap & COMPAT_HWCAP_ISA_C ? "detected" : "not found");
printf("V %s\n", hw_cap & COMPAT_HWCAP_ISA_V ? "detected" : "not found");
} shows :
/proc/cpuinfo :
Running my example with V8 JIT disabled :
also crashes with SIGILL, so it seems it's not in V8 generated code. What else I can try to see what happening ? |
It could be another problem with C906. fence.tso was originally not included in G, and C906 doesn't implement it in hardware. Newer OpenSBI for LicheeRV Nano (and other boards that uses C906 cores) should emulate it. Could you try upgrading that? p.s. Sorry for not replying the email, since you also asked here later I'll answer here. |
I'm using OpenSBI already patched for |
I still cannot reproduce this on LicheeRV Nano running Arch Linux RISC-V (kernel 6.11.3-arch1-1), so I'm out of ideas... |
Kernel 6.11 have Where I can find image of Arch Linux you using ? |
I'm using one of our team's build machine. There's no image right now, but I assume you can flash Debian first, replace the chroot, and then modify extlinux.conf or something so it boots to Arch-managed kernel. Deno on Arch RISC-V is built against newer version of glibc (2.40 actually), and it may not work under your Debian image. As you mentioned in the email the detection method used in V8 is compile-time.
You could try to compile and install a newer version of glibc (>=2.40) on Debian though. But yeah, use other distros' packages is considered a bad idea :( |
In my Debian image there's the same version of glibc I've excluded V8 as crash cause by disabling JIT, and by src code analysing - in my case V8 doesn't try use of Actually
I'll investigate it further. |
OK, so I found the problem. In my example crash occur, when npm tgz package is downloaded and is about to decompress. Deno is using
zlib-ng C library as the backend, which currently has this issue : zlib-ng/zlib-ng#1705 due to RVV detection method.
On my system, if I spoof kernel version to |
I've successfully built Deno (1.32.3, 1.32.4 in progress) in qemu-user and run on HiFive Unmatched on Arch Linux riscv64.
Some tweaks I did:
clang
,lld
,gn
andninja
to manually build V8.NO_PRINT_GN_ARGS=1
. GN somehow segfaults when printing arguments, but it is trivial for now and doesn't affect generating build files.v8_enable_shared_ro_heap
. This is intentially disabled, but we need to wait for pointer compression to meet rusty_v8's requirement and disable it.ring
with felixonmars/ring to provide C fallback for platforms without assembly crypto implementation.Environment variables exported:
Build script for Arch Linux can be found in felixonmars/archriscv-packages#2510. Patch Arch Linux's official PKGBUILD and build it:
Caveats
Note that current build runs TypeScript scripts normally, but in REPL errors will appear (while not affecting basic auto completion functionality):
This is triggered only by TypeScript LSP's
getDiagnostics
request. Other LSP requests with specifiers containing$deno$repl.ts
seem to not fail. I'm yet to find out why.The text was updated successfully, but these errors were encountered: