Skip to content

build: add support for OpenHarmony operating system #58350

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hqzing
Copy link

@hqzing hqzing commented May 16, 2025

OpenHarmony is an open-source operating system. It supports running on hardware such as phones, tablets, PCs, and embedded devices.

OpenHarmony supports the following system types:

  • Mini system (device memory >= 128 KiB)
  • Small system (device memory >=1 MiB)
  • Standard system (device memory >= 128 MiB)

We only need to focus on the OpenHarmony standard system, as the other two types are insufficient in memory to run Node.js

The OpenHarmony standard system uses the Linux kernel but does not use the GNU userland. This architecture is similar to that of the Android operating system. Therefore, my adaptation process for OpenHarmony is also similar to that for Android.

This adaptation only focuses on the arm64 architecture, as I don't have other environments to test more architectures.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/gyp
  • @nodejs/net
  • @nodejs/security-wg
  • @nodejs/v8-update

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. cares Issues and PRs related to the c-ares dependency or the cares_wrap binding. dependencies Pull requests that update a dependency file. libuv Issues and PRs related to the libuv dependency or the uv binding. needs-ci PRs that need a full CI run. openssl Issues and PRs related to the OpenSSL dependency. tools Issues and PRs related to the tools directory. v8 engine Issues and PRs related to the V8 dependency. zlib Issues and PRs related to the zlib subsystem. labels May 16, 2025
@hqzing
Copy link
Author

hqzing commented May 16, 2025

After adaptation, I successfully cross-compiled Node.js for OpenHarmony on my Ubuntu 24.04 amd64 server.

My compile command is:

cd node
mkdir ohos-sdk

# download from https://ci.openharmony.cn/workbench/cicd/dailybuild/dailylist
tar -zxf version-Master_Version-OpenHarmony_5.1.0.60-20250415_021145-ohos-sdk-public.tar.gz -C ./ohos-sdk

# download from https://ci.openharmony.cn/workbench/cicd/dailybuild/dailylist
tar -zxf version-Master_Version-LLVM-19-20250407_170223-LLVM-19.tar.gz

tar -zxf llvm-19.tar.gz
pushd ohos-sdk/linux
unzip -q native-linux-x64-5.1.0.60-Beta1.zip
popd
rm -rf *.tar.gz manifest_tag.xml ohos-sdk/linux/native/llvm
mv llvm-19 ohos-sdk/linux/native/llvm

TOOLCHAIN=$(realpath ohos-sdk/linux/native/llvm)
export CC="$TOOLCHAIN/bin/clang --target=aarch64-linux-ohos -Wno-error=implicit-function-declaration"
export CXX="$TOOLCHAIN/bin/clang++ --target=aarch64-linux-ohos -I $TOOLCHAIN/include/libcxx-ohos/include/c++/v1/ -L $TOOLCHAIN/aarch64-unknown-linux-ohos/ -Wno-error=implicit-function-declaration"
export CC_host="gcc"
export CXX_host="g++"
./configure --dest-cpu=arm64 --dest-os=openharmony --cross-compiling --partly-static
make -j64

As the OpenHarmony compilation toolchain continues to mature, the compile command will be further simplified. At that time, I will add the compilation guide to the BUILDING.md file.

Additionally, I have run test cases on my device (RK3568, OpenHarmony 5.0 arm64), achieving a pass rate of approximately 98%.

Copy link
Member

@RaisinTen RaisinTen left a comment

Choose a reason for hiding this comment

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

Can you assign an Experimental tier to this platform in BUILDING.md?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina added commit-queue Add this label to land a pull request using GitHub Actions. request-ci Add this label to start a Jenkins CI on a PR. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels May 16, 2025
@hqzing
Copy link
Author

hqzing commented May 16, 2025

Can you assign an Experimental tier to this platform in BUILDING.md?

ok, I'm done.

@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 16, 2025
@nodejs-github-bot

This comment was marked as outdated.

@RaisinTen RaisinTen added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 16, 2025
@hqzing hqzing requested a review from RaisinTen May 16, 2025 13:20
@RaisinTen RaisinTen added the request-ci Add this label to start a Jenkins CI on a PR. label May 16, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 16, 2025
@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@anonrig anonrig left a comment

Choose a reason for hiding this comment

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

~~This PR updates deps folder and those changes can go away with the next release. You need to land these changes to upstream repositories and later we should add openharmony to experimental. ~~

Edit: my bad. The changes are only to gyp files.

@hqzing
Copy link
Author

hqzing commented May 18, 2025

It seems that I'm blocked by a flaky-test #58353 . What should I do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. build Issues and PRs related to build files or the CI. cares Issues and PRs related to the c-ares dependency or the cares_wrap binding. dependencies Pull requests that update a dependency file. libuv Issues and PRs related to the libuv dependency or the uv binding. needs-ci PRs that need a full CI run. openssl Issues and PRs related to the OpenSSL dependency. tools Issues and PRs related to the tools directory. v8 engine Issues and PRs related to the V8 dependency. zlib Issues and PRs related to the zlib subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants