Skip to content

harmony-contrib/ohos-atomic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

zig-atomic-ohos

Build OpenHarmony libatomic.so and libatomic.a from the OpenHarmony LLVM compiler-rt atomic builtins.

The source dependency is:

https://gitcode.com/openharmony/third_party_llvm-project

Requirements

  • Zig with OHOS target support.
  • OpenHarmony native SDK sysroot.
  • An OpenHarmony third_party_llvm-project checkout.

The scripts resolve the sysroot from one of:

export OHOS_NDK_HOME=/path/to/ohos-sdk/native
export OHOS_SDK_HOME=/path/to/ohos-sdk
export OHOS_SYSROOT=/path/to/ohos-sdk/native/sysroot

Fetch Dependency

scripts/fetch-llvm-project.sh --ref OpenHarmony-6.0-Release

--ref is required so the packaged artifacts can be tied back to a specific OpenHarmony LLVM branch. Use the exact branch/tag name published by the remote. For example, when a 6.1 release branch is available:

scripts/fetch-llvm-project.sh --ref OpenHarmony-6.1-Release

The default URL is GitCode. If GitCode is unavailable in the current network, the script falls back to the OpenHarmony Gitee mirror. Override either endpoint when needed:

LLVM_PROJECT_URL=https://gitcode.com/openharmony/third_party_llvm-project.git \
LLVM_PROJECT_REF=OpenHarmony-6.0-Release \
scripts/fetch-llvm-project.sh

Build And Package

zig build -Dllvm-project-ref=OpenHarmony-6.0-Release

This builds both debug and release profiles for:

  • aarch64-linux-ohos
  • arm-linux-ohoseabi
  • x86_64-linux-ohos

The final archive is:

zig-out/OpenHarmony-6.0-Release-libatomic-ohos.tar.gz

If -Dllvm-project-ref is omitted, the build script tries to infer the prefix from the checked-out git branch, tag, or commit.

The archive layout is:

debug/
  arm64-v8a/libatomic.so
  arm64-v8a/libatomic.a
  armeabi-v7a/libatomic.so
  armeabi-v7a/libatomic.a
  x86_64/libatomic.so
  x86_64/libatomic.a
release/
  arm64-v8a/libatomic.so
  arm64-v8a/libatomic.a
  armeabi-v7a/libatomic.so
  armeabi-v7a/libatomic.a
  x86_64/libatomic.so
  x86_64/libatomic.a

Intermediate build outputs are kept under:

zig-out/build/<profile>/<target>/lib/
zig-out/package/<profile>/<abi>/

You can call the build script directly:

scripts/build-libatomic.sh --targets "aarch64-linux-ohos arm-linux-ohoseabi x86_64-linux-ohos"

Use a different release optimization mode:

zig build -Drelease-optimize=ReleaseFast

Use a custom dependency checkout:

zig build -Dllvm-project-dir=/path/to/third_party_llvm-project -Dsysroot=/path/to/ohos-sdk/native/sysroot

About

stdatomic dynamic/static library for OpenHarmony by zig

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors