Skip to content

Conversation

@etcusrvar
Copy link
Contributor

@etcusrvar etcusrvar commented Nov 29, 2024

Description

Add helix- https://helix-editor.com

Remarks

This needed some tweaking, because the upstream releases are not cross compiled but created on native systems (for x64 and aarch64).
By default helix is first built for the host arch and not for the target. And an error in cc crate does not detect the correct target arch (this is fixed by include and patching the cc crate source).
Another impediment is the build of the tree-sitter grammar modules. Those are not built by rust but by native c compiler (under the control of cargo build system). This is fixed by explicit cross tool definitions.

helix is not a small tool (due to the language processing modules) so it is not an option to add it to synocli-file but to create its own package.

Checklist

  • Build rule all-supported completed successfully
  • New installation of package completed successfully
  • Package upgrade completed successfully (Manually install the package again)
  • Package functionality was tested
  • Any needed documentation is updated/created

Type of change

  • New Package

draft PR status

This currently builds, installs, and works correctly on avoton-7.1.
all-supported doesn't yet build without errors.

@hgy59
Copy link
Contributor

hgy59 commented Nov 29, 2024

Thanks for contributing.

helix is candiate to be added to synocli-file package.
For the actual development it is ok to have it as dedicated spk.
Later (before merging), we should move spk/helix to diyspk/helix and include helix in spk/synocli-file.

But there is a cross compilation error when building the tree-sitter crate.
Without this fixed, helix would be available for x64 only.

I already found this issue when I tried to build helix 1 1/2 year ago, ....

@hgy59
Copy link
Contributor

hgy59 commented Nov 29, 2024

This is the build error for aarch64-7.1

The wrong CFLAG -m64 is typically for x64, but must not be used for other archs.
I have not a clue where this comes from...

The following warnings were emitted during compilation:

warning: [email protected]: aarch64-unknown-linux-gnu-gcc: error: unrecognized command line option ‘-m64’

error: failed to run custom build command for `tree-sitter v0.22.6`

Caused by:
  process didn't exit successfully: `/spksrc/cross/helix/work-aarch64-7.1/helix-24.07/target/opt/build/tree-sitter-e2838712e9319bfa/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=CARGO_FEATURE_WASM
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/alloc.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/wasm_store.c
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/wasm
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/get_changed_ranges.c
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/language.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/tree.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/lib.c
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/tree_cursor.c
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/get_changed_ranges.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/tree_cursor.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/lexer.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/host.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/parser.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/stack.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/language.c
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/subtree.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/point.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/unicode.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/alloc.c
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/clock.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/atomic.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/reduce_action.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/length.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/reusable_node.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/wasm_store.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/error_costs.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/stack.c
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/unicode
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/array.h
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/query.c
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/node.c
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/tree.c
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/subtree.c
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/lexer.c
  cargo:rerun-if-changed=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/parser.c
  OUT_DIR = Some(/spksrc/cross/helix/work-aarch64-7.1/helix-24.07/target/opt/build/tree-sitter-f4b304b61a55b470/out)
  TARGET = Some(x86_64-unknown-linux-gnu)
  OPT_LEVEL = Some(0)
  HOST = Some(x86_64-unknown-linux-gnu)
  cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
  CC_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
  CC_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = Some(/spksrc/toolchain/syno-aarch64-7.1/work/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gcc)
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(false)
  CARGO_CFG_TARGET_FEATURE = Some(fxsr,sse,sse2)
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  CFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  CFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = Some(-I/spksrc/toolchain/syno-aarch64-7.1/work/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot/usr/include -I/spksrc/cross/helix/work-aarch64-7.1/install/usr/local/helix/include )
  OUT_DIR = Some(/spksrc/cross/helix/work-aarch64-7.1/helix-24.07/target/opt/build/tree-sitter-f4b304b61a55b470/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some(fxsr,sse,sse2)
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  CFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  CFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = Some(-I/spksrc/toolchain/syno-aarch64-7.1/work/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot/usr/include -I/spksrc/cross/helix/work-aarch64-7.1/install/usr/local/helix/include )
  OUT_DIR = Some(/spksrc/cross/helix/work-aarch64-7.1/helix-24.07/target/opt/build/tree-sitter-f4b304b61a55b470/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some(fxsr,sse,sse2)
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  CFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  CFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = Some(-I/spksrc/toolchain/syno-aarch64-7.1/work/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot/usr/include -I/spksrc/cross/helix/work-aarch64-7.1/install/usr/local/helix/include )
  OUT_DIR = Some(/spksrc/cross/helix/work-aarch64-7.1/helix-24.07/target/opt/build/tree-sitter-f4b304b61a55b470/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some(fxsr,sse,sse2)
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  CFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  CFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = Some(-I/spksrc/toolchain/syno-aarch64-7.1/work/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot/usr/include -I/spksrc/cross/helix/work-aarch64-7.1/install/usr/local/helix/include )
  OUT_DIR = Some(/spksrc/cross/helix/work-aarch64-7.1/helix-24.07/target/opt/build/tree-sitter-f4b304b61a55b470/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some(fxsr,sse,sse2)
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  CFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  CFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = Some(-I/spksrc/toolchain/syno-aarch64-7.1/work/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot/usr/include -I/spksrc/cross/helix/work-aarch64-7.1/install/usr/local/helix/include )
  cargo:warning=aarch64-unknown-linux-gnu-gcc: error: unrecognized command line option ‘-m64’

  --- stderr


  error occurred: Command "/spksrc/toolchain/syno-aarch64-7.1/work/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src" "-I" "/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/wasm" "-I" "/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/include" "-I/spksrc/toolchain/syno-aarch64-7.1/work/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot/usr/include" "-I/spksrc/cross/helix/work-aarch64-7.1/install/usr/local/helix/include" "-o" "/spksrc/cross/helix/work-aarch64-7.1/helix-24.07/target/opt/build/tree-sitter-f4b304b61a55b470/out/e2a9901b8fe01e95-lib.o" "-c" "/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/src/lib.c" with args aarch64-unknown-linux-gnu-gcc did not execute successfully (status code exit status: 1).

@etcusrvar
Copy link
Contributor Author

I added CARGO_BUILD_ARGS += -vv to cross/helix/Makefile, and it gave a bit more info--

process didn't exit successfully: `
CARGO=/spksrc/distrib/rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo
CARGO_CFG_PANIC=unwind
CARGO_CFG_TARGET_ABI=''
CARGO_CFG_TARGET_ARCH=x86_64
CARGO_CFG_TARGET_ENDIAN=little
CARGO_CFG_TARGET_ENV=gnu
CARGO_CFG_TARGET_FAMILY=unix
CARGO_CFG_TARGET_FEATURE=fxsr,sse,sse2
CARGO_CFG_TARGET_HAS_ATOMIC=16,32,64,8,ptr
CARGO_CFG_TARGET_OS=linux
CARGO_CFG_TARGET_POINTER_WIDTH=64
CARGO_CFG_TARGET_VENDOR=unknown
CARGO_CFG_UNIX=''
CARGO_ENCODED_RUSTFLAGS=''
CARGO_MANIFEST_DIR=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6
CARGO_MANIFEST_LINKS=tree-sitter
CARGO_MANIFEST_PATH=/spksrc/distrib/cargo/registry/src/index.crates.io-6f17d22bba15001f/tree-sitter-0.22.6/Cargo.toml
CARGO_PKG_LICENSE=MIT
CARGO_PKG_LICENSE_FILE=''
CARGO_PKG_NAME=tree-sitter
CARGO_PKG_README=binding_rust/README.md
CARGO_PKG_REPOSITORY='https://github.com/tree-sitter/tree-sitter'
CARGO_PKG_RUST_VERSION=1.65
CARGO_PKG_VERSION=0.22.6
CARGO_PKG_VERSION_MAJOR=0
CARGO_PKG_VERSION_MINOR=22
CARGO_PKG_VERSION_PATCH=6
CARGO_PKG_VERSION_PRE=''
DEBUG=false
HOST=x86_64-unknown-linux-gnu
LD_LIBRARY_PATH='/spksrc/cross/helix/work-aarch64-7.1/helix-24.07/target/opt/deps:/spksrc/cross/helix/work-aarch64-7.1/helix-24.07/target/opt:/spksrc/distrib/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib:/spksrc/distrib/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib'
NUM_JOBS=4
OPT_LEVEL=0
OUT_DIR=/spksrc/cross/helix/work-aarch64-7.1/helix-24.07/target/opt/build/tree-sitter-4fe5024e6456f75e/out
PROFILE=release
RUSTC=/spksrc/distrib/rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc
RUSTDOC=/spksrc/distrib/rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustdoc
TARGET=x86_64-unknown-linux-gnu
/spksrc/cross/helix/work-aarch64-7.1/helix-24.07/target/opt/build/tree-sitter-359b4f37ca1845b5/build-script-build
` (exit status: 1)

I tried changing things like CARGO_CFG_TARGET_ARCH and TARGET in the Makefile, but even when explicitly setting them to appropriate aarch64... values, they still show up as x86_64... values.

@hgy59
Copy link
Contributor

hgy59 commented Dec 1, 2025

@etcusrvar I found a solution to cross compile helix. I will continue your work here...

@hgy59 hgy59 marked this pull request as ready for review December 10, 2025 21:00
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.

2 participants