Skip to content

libc link error for ohos #25340

@richerfu

Description

@richerfu

Zig Version

0.15.1

Steps to Reproduce and Observed Behavior

I made a repo to use zig build native addon for OpenHarmony.
https://github.com/openharmony-zig/zig-napi/tree/dev-update-15

Reproduction:

cd exmaple/basic && zig build -Dtarget=aarch64-linux-ohos

And when i upgrade zig to 0.15.1, it depends on __emutls_get_address and i add compile.root_module.link_libc = true, but got the following error.

zig build -Dtarget=aarch64-linux-ohos > a.txt
install
└─ install hello
└─ compile lib hello Debug aarch64-linux-ohos failure
error: error: unable to provide libc for target 'aarch64-linux.5.10...6.16-ohos'
info: zig can provide libc for related target aarch64-linux.3.7.0-gnu.2.17
info: zig can provide libc for related target aarch64-linux.3.7.0-musl

error: the following command exited with error code 1:
/opt/homebrew/Cellar/zig/0.15.1/bin/zig build-lib -lace_napi.z -ODebug -target aarch64-linux-ohos -mcpu baseline -I /Users/ranger/.meat/sdk/normal/default/openharmony/native/sysroot/usr/include -I /Users/ranger/.meat/sdk/normal/default/openharmony/native/sysroot/usr/include/aarch64-linux-ohos -L /Users/ranger/.meat/sdk/normal/default/openharmony/native/sysroot/usr/lib -L /Users/ranger/.meat/sdk/normal/default/openharmony/native/sysroot/usr/lib/aarch64-linux-ohos --dep napi -Mroot=/Users/ranger/Desktop/project/ohos-rs/zig-addon/examples/basic/src/hello.zig -I /Users/ranger/Desktop/project/ohos-rs/zig-addon/examples/basic/../../src/sys/header --dep napi-sys -Mnapi=/Users/ranger/Desktop/project/ohos-rs/zig-addon/src/napi.zig -I /Users/ranger/Desktop/project/ohos-rs/zig-addon/examples/basic/../../src/sys/header -Mnapi-sys=/Users/ranger/Desktop/project/ohos-rs/zig-addon/src/sys/api.zig -lc --cache-dir .zig-cache --global-cache-dir /Users/ranger/.cache/zig --name hello -dynamic --zig-lib-dir /opt/homebrew/Cellar/zig/0.15.1/lib/zig/ --listen=-

Build Summary: 0/3 steps succeeded; 1 failed
install transitive failure
└─ install hello transitive failure
└─ compile lib hello Debug aarch64-linux-ohos failure

error: the following build command failed with exit code 1:
.zig-cache/o/63eafbb47820e19c31508106598851cc/build /opt/homebrew/Cellar/zig/0.15.1/bin/zig /opt/homebrew/Cellar/zig/0.15.1/lib/zig /Users/ranger/Desktop/project/ohos-rs/zig-addon/examples/basic .zig-cache /Users/ranger/.cache/zig --seed 0x87b77cc6 -Z49538d938c743571 -Dtarget=aarch64-linux-ohos

Does it depend on the following PR?
#21809
#22109

Expected Behavior

It should work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions