About this project
This project provides a modified build of [Bun](https://bun.sh) that runs natively on Android/Termux (aarch64) using Bionic libc. No proot, no glibc-runner, no LD_PRELOAD, no termux-exec — all fixes are compiled directly into the binary via `#[cfg(target_os = "android")]` Rust branches.
### What it solves
Upstream Bun 1.4's Android build hits three remaining issues on Termux:
- `bun install` crashes with SIGSYS because Android's zygote seccomp profile traps `fchmodat2` and `openat2` instead of returning `ENOSYS`, preventing upstream runtime fallbacks from running.
- `bunx <pkg>` fails with ENOENT because npm shims carry `#!/usr/bin/env node` shebangs and Android has no `/usr/bin`.
- `bun:ffi cc()` reports TinyCC disabled because upstream gates the feature off on Android.
This fork applies seven source-level patches against Bun v1.4.0 to fix each issue.
### Features
- **Full FFI support**: `dlopen`, `cc()`, and `JSCallback` all work.
- **TinyCC enabled on Android**: SELinux-safe JIT memory via `memfd_create` + ARM64 long-call veneers for out-of-range BL calls.
- **Seccomp-trap bypass**: `lchmod` uses `fchmodat(AT_SYMLINK_NOFOLLOW)` instead of trapped `fchmodat2`; resolver walks use plain `openat` instead of trapped `openat2`.
- **Shebang remap**: Scripts with missing interpreters remap paths like `/usr/bin` to `$PREFIX/bin`.
- **`bunx` works**: Launcher sets `argv[0]` correctly for script spawning.
### Compatibility
| Item | Status |
|---|---|
| Architecture | `aarch64` (arm64) |
| Android | 10+ (API 29+, SELinux untrusted_app_27+) |
| Bun version | 1.4.0 |
| `bun install` | Works (seccomp bypass) |
| `bun run` / `bunx` | Works |
| `bun build --compile` | Works (fixed upstream) |
| `bun:ffi` `dlopen` / `cc()` / `JSCallback` | Work |
| opentui TUI | Works |
### Install
```bash
curl -fsSL https://raw.githubusercontent.com/bd-loser/bun-termux/main/scripts/install.sh | bash
```
Installs `bun` and `bunx` into `$PREFIX/bin`.
### Build from source
Requires Rust, NDK r27c, clang 18, CMake, Ninja, and Bun for bootstrapping. See [docs/BUILD.md](docs/BUILD.md) for full instructions.
### Licensing
MIT for the fork patches; TinyCC components under LGPL-2.1; upstream Bun under MIT.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.