Skip to content

fix(main/turbopack): condense and revise#29207

Draft
robertkirkman wants to merge 1 commit intotermux:masterfrom
robertkirkman:turbopack-changes
Draft

fix(main/turbopack): condense and revise#29207
robertkirkman wants to merge 1 commit intotermux:masterfrom
robertkirkman:turbopack-changes

Conversation

@robertkirkman
Copy link
Copy Markdown
Member

@robertkirkman robertkirkman commented Apr 4, 2026

  • Bulk-patch "android" wherever it can condense the patches using find on $TERMUX_PKG_SRCDIR and rustls-platform-verifier

  • Organize add_android_build.patch into the bulk-patches plus three smaller .patch files that group related changes together, disable-wasm-fallback-for-android.patch, modify-allocator-for-android.patch and modify-file-locking-for-android.patch

  • Use CARGO_TARGET_NAME instead of redefining a new variable with the same contents, RUST_TARGET

  • Apply --yes to npx pnpm install for noninteractive building outside of GitHub Actions

  • Remove unnecessary ls -l command

  • Remove unnecessary ${STRIP} commands; termux_step_strip_elf_symbols() does that automatically

  • Reorganize termux_step_pre_configure() to contain all external dependency fetching and environment variable setting, and termux_step_make() to contain only the build command

  • Implement the fallback binary using a symbolic link to the regular binary, saving space in the package.

  • Apply x86_64-linux-android triplet to napi array in packages/next-swc/package.json

- Bulk-patch `"android"` wherever it can condense the patches using `find` on `$TERMUX_PKG_SRCDIR` and `rustls-platform-verifier`

- Organize `add_android_build.patch` into the bulk-patches plus three smaller `.patch` files that group related changes together, `disable-wasm-fallback-for-android.patch`, `modify-allocator-for-android.patch` and `modify-file-locking-for-android.patch`

- Use `CARGO_TARGET_NAME` instead of redefining a new variable with the same contents, `RUST_TARGET`

- Apply `--yes` to `npx pnpm install` for noninteractive building outside of GitHub Actions

- Remove unnecessary `ls -l` command

- Remove unnecessary `${STRIP}` commands; `termux_step_strip_elf_symbols()` does that automatically

- Reorganize `termux_step_pre_configure()` to contain all external dependency fetching and environment variable setting, and `termux_step_make()` to contain only the build command

- Implement the fallback binary using a symbolic link to the regular binary, saving space in the package.

- Apply `x86_64-linux-android` triplet to `napi` array in `packages/next-swc/package.json`
@robertkirkman
Copy link
Copy Markdown
Member Author

@xingguangcuican6666 @Kuldeep-Dilliwar I wanted to ask,

  • Do these changes all look ok to you?
  • Could you test the GitHub Actions artifacts from this PR and make sure that everything is still working the same after this? It is for me, but I'm not 100% sure.

+ let env_var = std::env::var("TURBO_SSL_CERT_FILE");
+
+ // --- BRANCH A: TERMUX MODE (Fix the Crash) ---
+ if termux_path.exists() {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that my version does not require this patch in this way.

However, I have not been able to conclusively confirm that, because I do not know how to reproduce the exact error that this patch fixes.

@Kuldeep-Dilliwar do you know how to reproduce the exact error that this patch about /data/data/com.termux/files/usr/etc/tls/cert.pem fixes, so I can test my version to confirm that it is not affected by the error anymore even without having this patch?

@xingguangcuican6666
Copy link
Copy Markdown
Contributor

@xingguangcuican6666 @Kuldeep-Dilliwar I wanted to ask,

  • Do these changes all look ok to you?
  • Could you test the GitHub Actions artifacts from this PR and make sure that everything is still working the same after this? It is for me, but I'm not 100% sure.

It seems that there is no problem. I will conduct a functionality test later.

@xingguangcuican6666
Copy link
Copy Markdown
Contributor

After my testing, it seems that there is indeed no problem, but I found that /data/data/com.termux/files/usr/etc/profile.d/turbopack.sh does not source automatically and needs to be sourced manually.

@robertkirkman
Copy link
Copy Markdown
Member Author

After my testing, it seems that there is indeed no problem, but I found that /data/data/com.termux/files/usr/etc/profile.d/turbopack.sh does not source automatically and needs to be sourced manually.

This is known about; I explained that it is necessary to use exit and then open Termux again after installing turbopack here:

Maybe I should add a line to the postinst script print message that explains that is necessary.

However, that is also necessary for other things in Termux and also often on Desktop Linux as well, such as for example C# programs like jellyfin-server, and those don't have postinst messages explaining this - they just assume the users will know that. I'm not sure what option is best.

@Kuldeep-Dilliwar
Copy link
Copy Markdown
Contributor

@xingguangcuican6666 @Kuldeep-Dilliwar I wanted to ask,

  • Do these changes all look ok to you?
  • Could you test the GitHub Actions artifacts from this PR and make sure that everything is still working the same after this? It is for me, but I'm not 100% sure.

IMG_20260405_082724.jpg

This is the issues that i added those harcoded cert file location from Termux, in this image I have used artifect from build, and the reason about adding the env was that, because in one feature of nextjs you can use your corporate companies SSL cert which is provided by your company, so i thought I could make a env which people or user can point to and that will be added to know cert list.

@xingguangcuican6666
Copy link
Copy Markdown
Contributor

This is known about; I explained that it is necessary to use exit and then open Termux again after installing turbopack here:

Maybe I should add a line to the postinst script print message that explains that is necessary.

However, that is also necessary for other things in Termux and also often on Desktop Linux as well, such as for example C# programs like jellyfin-server, and those don't have postinst messages explaining this - they just assume the users will know that. I'm not sure what option is best.

Yes, I know this, but I mean that after restarting Termux, it still seems to require me to manually source it.
IMG_20260405_111414

@robertkirkman
Copy link
Copy Markdown
Member Author

Yes, I know this, but I mean that after restarting Termux, it still seems to require me to manually source it.

It is because you are using fish instead of bash or zsh. I noticed that when fish is set as the Termux shell with chsh -s fish, it does not get the NEXT_TEST_* variables, but if chsh -s bash or chsh -s zsh is used instead, it works.

If we consider bash and zsh as the best-polished shells in Termux currently (ignoring issues like #25970, #25984, #28433, #28433, and #25264), and consider fish as an outlier, this would imply a problem specific to fish that should be considered separately.

@robertkirkman robertkirkman marked this pull request as draft April 5, 2026 05:15
@robertkirkman
Copy link
Copy Markdown
Member Author

robertkirkman commented Apr 5, 2026

This is the issues that i added those harcoded cert file location from Termux, in this image I have used artifect from build, and the reason about adding the env was that, because in one feature of nextjs you can use your corporate companies SSL cert which is provided by your company, so i thought I could make a env which people or user can point to and that will be added to know cert list.

ok actually yes I can reproduce those errors, but I did not know if those were what is fixed by that patch, yes that points out that this PR currently doesn't handle that correctly. I need to change this PR until it works fully. Thank you for confirming those errors get fixed by the patch, now I can check that to see when my version is working.

local ENV_PREFIX=$(echo "$RUST_TARGET" | tr '[:lower:]-' '[:upper:]_')
if [ "$TERMUX_ARCH" == "aarch64" ]; then
export RUSTFLAGS="$RUSTFLAGS -Zshare-generics=y -Csymbol-mangling-version=v0"
local ENV_PREFIX=$(echo "$CARGO_TARGET_NAME" | tr '[:lower:]-' '[:upper:]_')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

declare/local has a -u flag for this.

Suggested change
local ENV_PREFIX=$(echo "$CARGO_TARGET_NAME" | tr '[:lower:]-' '[:upper:]_')
local -u env_host="${CARGO_TARGET_NAME//-/_}"
https://man.archlinux.org/man/bash.1#u~3

This is also used in the fish build, it probably makes sense to use the same variable name as well..

local -u env_host="${CARGO_TARGET_NAME//-/_}"

else
export "CARGO_TARGET_${ENV_PREFIX}_LINKER"="$CC"
export "CC_${RUST_TARGET//-/_}"="$CC"
export "CC_${CARGO_TARGET_NAME//-/_}"="$CC"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export "CC_${CARGO_TARGET_NAME//-/_}"="$CC"
export "CC_${env_host}"="$CC"

termux_step_make() {
cd packages/next-swc
npx pnpm run build-native-release --target "$RUST_TARGET"
npx pnpm run build-native-release --target "$CARGO_TARGET_NAME"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
npx pnpm run build-native-release --target "$CARGO_TARGET_NAME"
npx pnpm run build-native-release --target "${env_host}"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line does not need to be changed because it uses $CARGO_TARGET_NAME unmodified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants