termux-packages icon indicating copy to clipboard operation
termux-packages copied to clipboard

enable,bump(main/deno): 2.1.2

Open 0komo opened this issue 1 year ago β€’ 24 comments

WIP

  • [x] Bump deno
    • [ ] ~~Fix i686 and arm for "index out of bounds" error on src_binding.rs~~ See https://github.com/denoland/deno/issues/2295#issuecomment-2329248010
    • [ ] Successfully built deno
  • [x] ~~Bump librusty-v8~~ Moved to #22404
    • [x] ~~Successfully build librusty-v8~~

0komo avatar Nov 24 '24 15:11 0komo

Ninja tries to link libclang_rt which is not possible to link, and there's no way to disable it nor replace it with libgcc.

Waiting for denoland/rusty_v8#1662.

0komo avatar Nov 25 '24 11:11 0komo

The linkage should comes from chromium or v8, not really related to rusty_v8. I'll have a look this night or tomorrow.

licy183 avatar Nov 25 '24 11:11 licy183

The linkage should comes from chromium or v8, not really related to rusty_v8. I'll have a look this night or tomorrow.

I can take a look at it later. Seems it comes from V8's BUILD.gn.

0komo avatar Nov 25 '24 11:11 0komo

TODO: Patch src/binding.cc regarding static assertation error (probably bad architecture assumption)

0komo avatar Nov 25 '24 21:11 0komo

PKG_CONFIG_PATH maybe required to make Cargo recognize Termux's libraries.

0komo avatar Nov 27 '24 21:11 0komo

Better to split librusty-v8 into a seperate PR and merge it before building deno. It takes too much time to build librusty-v8.

licy183 avatar Nov 28 '24 00:11 licy183

Better to split librusty-v8 into a seperate PR and merge it before building deno. It takes too much time to build librusty-v8.

I'll do that in the next commit

0komo avatar Nov 28 '24 08:11 0komo

  • i686 and arm build failed because of "index out of bounds" error inside src_binding.rs.

0komo avatar Nov 28 '24 15:11 0komo

All builds failed because of librusty-v8, seems like it needs a further more patches to get it working.

0komo avatar Nov 29 '24 13:11 0komo

aarch64 build might failed because of snapshot being compiled for x86_64.

0komo avatar Nov 30 '24 12:11 0komo

Cargo built x86_64 deno on aarch64 build, thus ld: error: /data/data/com.termux/files/usr/lib/libsqlite3.so is incompatible with elf64-x86-64 error shows up Need to patch this one

0komo avatar Nov 30 '24 14:11 0komo

Thanks for this, I have successfully build and install it πŸ₯°β™₯️

Screenshot_2025-06-02-11-22-56-89_84d3000e3f4017145260f7618db1d683

Jobians avatar Jun 02 '25 10:06 Jobians

I'd like to merge this PR and then bump deno to the latest stable version. After this PR is merged, I'll transfer github.com/licy183/deno-snapshot to termux.

CC: @thunder-coding As the maintainer of nodejs

licy183 avatar Jun 04 '25 02:06 licy183

@licy183 can you try to fix this issue https://github.com/denoland/deno/issues/19759#issuecomment-2914426954

It happens in your buid

Jobians avatar Jun 04 '25 07:06 Jobians

@licy183 can you try to fix this issue denoland/deno#19759 (comment)

It happens in your buid

Addressed in 11bf2b553e324e8f5988bcd32118120e129dff45

licy183 avatar Jun 04 '25 12:06 licy183

@licy183 can you try to fix this issue denoland/deno#19759 (comment) It happens in your buid

Addressed in 11bf2b5

Deno Android Compatibility Test Results βœ…

I've verified the new build works perfectly on Android (Termux) using a comprehensive test. Here are the results:

Test File Used

async function main() {
  console.log("=== Starting Deno Android Compatibility Test ===");
  
  // 1. Core functionality
  console.log("\nβœ… Core Test");
  console.log("Deno version:", Deno.version.deno);
  console.log("Fetch test:", await fetch("https://example.com").then(r => r.status));

  // 2. Process spawning (historically problematic on Android)
  console.log("\nπŸ”„ Process Spawn Test");
  try {
    const cmd = new Deno.Command("echo", {
      args: ["Process spawn successful!"],
      stdout: "piped"
    });
    const { stdout } = await cmd.output();
    console.log(new TextDecoder().decode(stdout).trim());
  } catch (e) {
    console.log("❌ Process spawn failed:", e.message);
  }

  // 3. Filesystem operations
  console.log("\nπŸ“ Filesystem Test");
  try {
    const testFile = "deno_test_file.txt";
    await Deno.writeTextFile(testFile, "Filesystem works!");
    console.log("File content:", await Deno.readTextFile(testFile));
    await Deno.remove(testFile);
  } catch (e) {
    console.log("❌ Filesystem failed:", e.message);
  }

  // 4. Native bindings check
  console.log("\nπŸ”Œ Native Binding Test");
  try {
    const tempDir = await Deno.makeTempDir();
    console.log("Temp dir created:", tempDir);
    await Deno.remove(tempDir, { recursive: true });
  } catch (e) {
    console.log("❌ Native bindings failed:", e.message);
  }

  console.log("\n=== Test Complete ===");
}

main();

Successful Output

=== Starting Deno Android Compatibility Test ===

βœ… Core Test
Deno version: 2.1.2
Fetch test: 200

πŸ”„ Process Spawn Test
Process spawn successful!

πŸ“ Filesystem Test
File content: Filesystem works!

πŸ”Œ Native Binding Test
Temp dir created: /data/data/com.termux/files/usr/tmp/c276bb488d231afc

=== Test Complete ===

Screenshot Proof:
Terminal showing successful test

Key Features Confirmed Working:

  • βœ… Process spawning (Deno.Command)
  • βœ… Filesystem operations
  • βœ… Network access
  • βœ… Native bindings
  • βœ… Permission system

This resolves the previous Android compatibility issues we observed.

Jobians avatar Jun 04 '25 13:06 Jobians

Great work !! Maybe these patches can be send to deno upstream ?

secext2022 avatar Jun 05 '25 13:06 secext2022

Great work !! Maybe these patches can be send to deno upstream ?

That's unnecesarry to do, and it would be hard to maintain it's stability for platform that the maintainers doesn't even use.

0komo avatar Jun 05 '25 23:06 0komo

@0komo

$ lldb deno
(lldb) target create "deno"
Current executable set to '/data/data/com.termux/files/usr/bin/deno' (aarch64).
(lldb) run --allow-all --unstable-worker-options main.ts
Process 21068 launched: '/data/data/com.termux/files/usr/bin/deno' (aarch64)
Listening on http://0.0.0.0:3300/
Process 21068 stopped
* thread #13, name = 'tokio-runtime-w', stop reason = signal SIGTRAP
    frame #0: 0x00000055594d51a8 deno`___lldb_unnamed_symbol69746 + 1432
deno`___lldb_unnamed_symbol69746:
->  0x55594d51a8 <+1432>: brk    #0x1
    0x55594d51ac <+1436>: add    x0, x19, #0x10
    0x55594d51b0 <+1440>: b      0x55594d51a0   ; <+1424>
    0x55594d51b4 <+1444>: mov    x20, x0
(lldb) bt
* thread #13, name = 'tokio-runtime-w', stop reason = signal SIGTRAP
  * frame #0: 0x00000055594d51a8 deno`___lldb_unnamed_symbol69746 + 1432
    frame #1: 0x00000055594d4e24 deno`___lldb_unnamed_symbol69746 + 532
    frame #2: 0x00000055594d3b84 deno`___lldb_unnamed_symbol69721 + 276
    frame #3: 0x00000055594d3a5c deno`___lldb_unnamed_symbol69720 + 32
    frame #4: 0x00000055594d8ed8 deno`___lldb_unnamed_symbol69904 + 76
    frame #5: 0x00000055594a69a0 deno`___lldb_unnamed_symbol68510 + 428
    frame #6: 0x00000055594add4c deno`___lldb_unnamed_symbol68572 + 232
    frame #7: 0x000000555803f9f0 deno`___lldb_unnamed_symbol4756 + 2188
    frame #8: 0x000000555808a2c8 deno`___lldb_unnamed_symbol5385 + 5352
    frame #9: 0x0000005558088940 deno`___lldb_unnamed_symbol5382 + 344
    frame #10: 0x0000005558dee87c deno`___lldb_unnamed_symbol42248 + 332
    frame #11: 0x0000005558df7f04 deno`___lldb_unnamed_symbol42384 + 164
    frame #12: 0x00000055594e5f7c deno`___lldb_unnamed_symbol70195 + 440
    frame #13: 0x00000055594e5c8c deno`___lldb_unnamed_symbol70194 + 144
    frame #14: 0x000000555941ba74 deno`___lldb_unnamed_symbol65550 + 36
    frame #15: 0x0000007fec1342a8 libc.so`__pthread_start(void*) + 200
    frame #16: 0x0000007fec125624 libc.so`__start_thread + 68
(lldb)
```

Jobians avatar Jun 10 '25 14:06 Jobians

Please provide the files of your project.

licy183 avatar Jun 10 '25 16:06 licy183

I think the problem is from the package, please investigate

const workerCode = `
import { InlineKeyboard } from 'jsr:@gramio/core';
`;

const blob = new Blob([workerCode], { type: "application/javascript" });
const worker = new Worker(URL.createObjectURL(blob), { type: "module" });

console.log("Main script: worker started");

Jobians avatar Jun 10 '25 16:06 Jobians

Not a bug of Termux's deno. It is also reproducible on deno-v2.1.2-x86_64-unknown-linux-gnu. It may be fixed in the latest version of deno, but I want to bump deno to the latest version after this PR is merged.

licy183 avatar Jun 10 '25 19:06 licy183

@licy183 Thanks for the info! Is there a way I can get the latest Deno version now? Version 2.1.2 has many bugs that have been fixed in the latest release.

Jobians avatar Jun 12 '25 21:06 Jobians

@Jobians You can fork this PR branch, change the TERMUX_PKG_VERSION to latest, and run the build CI. But expect things to not work out properly.

0komo avatar Jun 13 '25 03:06 0komo

Deno is now bumped to the latest LTS version.

licy183 avatar Jun 17 '25 18:06 licy183

Hi! Thanks for the update πŸ™

Unfortunately, this version still has the same issue:

error: Uncaught (in promise) AssertionError: unreachable
  throw new AssertionError("unreachable");
        ^
    at unreachable (https://deno.land/[email protected]/testing/asserts.ts:865:9)
    at https://deno.land/[email protected]/node/internal_binding/uv.ts:320:7

Would it be possible for you to share the relevant patches or changes so I can try building Deno v2.3.6 with them locally?

Thanks again for your work!

Jobians avatar Jun 18 '25 14:06 Jobians

Would it be possible for you to share the relevant patches or changes so I can try building Deno v2.3.6 with them locally?

The relevant patches are on this branch. You can either check them out via the GitHub CLI:

gh pr checkout 22379

Or grab the .patch file of this PR and apply it to your fork of termux/termux-packages on a branch of your choice.

git clone https://github.com/termux/termux-packages
# Or clone your own fork if you have one

cd termux-packages

wget https://github.com/termux/termux-packages/pull/22379.patch

git apply 22379.patch

(This does lose some granularity by compressing the commits on this branch into a single patch that is applied on top of your working state.)

TomJo2000 avatar Jun 18 '25 14:06 TomJo2000

Thanks again, Tom!

I’ve actually already tried applying that patch, but unfortunately it doesn’t fully work with Deno v2.3.6.

It seems there are some internal code changes in the Deno VM in this version that break compatibility β€” so additional adjustments beyond the current patch are likely needed.

Let me know if there’s an updated patch or workaround. I’m happy to help test it!

Jobians avatar Jun 18 '25 15:06 Jobians

Please provide the steps that trigger this error. I can't reproduce it using the ts file above in https://github.com/termux/termux-packages/pull/22379#issuecomment-2959981767.

licy183 avatar Jun 18 '25 15:06 licy183

Seems like it came from this.

https://github.com/denoland/deno/blob/v2.2.13/ext/node/polyfills/internal_binding/uv.ts#L490-L520

Can anyone verify the output of Deno.build.os?

0komo avatar Jun 18 '25 16:06 0komo