-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat: zig cc support openharmony #21809
base: master
Are you sure you want to change the base?
Conversation
We have these in
Should those be added here as well? |
As long as OpenHarmony hasn't altered any of musl's headers or changed any of the exported symbols in |
I think it's not. There are currently no good test plans for these architectural goals. |
OpenHarmony does have some changes, which can be seen on the official website, but I think the current support is enough before being merged in #20020 . what you think?
Or is there any good way to test this ability? If so and i can try to test it with device. |
The main thing we care about is whether the support exists in some form at all, no matter how limited/early/experimental. There doesn't necessarily have to be a test plan. Is this the case? (And are there others we aren't covering?)
I hadn't seen that #20020 was closed. AFAIK, Andrew goes over all draft PRs and closes ones with no activity every once in a while, so it looks like #20020 got caught in that without him noticing that his input was needed there. 🙂 Ok, some questions:
The answers to these questions will determine how we should proceed with this. |
ok. I'll try to answer these questions.
|
Do you know if the OpenHarmony project has experimental support for more architectures in their official development repos?
I'm basically just asking for the moral equivalent of |
I can provide some embedded repositories, but it seems that there is no support for riscv and other architectures. https://gitee.com/openharmony/kernel_liteos_a And i'll provide this difference later. Can the difference content be directly followed in the comments of this PR? |
Ok, that's good to know. In that case, we should remove those target triples from
Putting them in a gist and posting the link here would probably be ideal. |
https://gist.github.com/richerfu/f411e0fc01892cc8a517f26b430b3616 Judging from the results, most of the differences are in file formats, and a few files have added or removed some definitions. Note: You can use |
It seems like a lot of these diffs are caused by line endings. Running |
Updated. I remove all the new line at the end of file and convert |
Ok, that's a lot better, thank you. I think there are enough significant differences in these header files that we can't just simply use upstream musl headers; we have to ship distinct OpenHarmony musl headers as in #20020. Fortunately, if dynamically linking libc is the norm for OpenHarmony, we can probably get away with not shipping an entire copy of the OpenHarmony musl sources as well. (Aside: Is the implementation code for OpenHarmony's musl fork actually public?) So, I think #20020 was on the right track. But as I said then, I think @andrewrk should sign off on actually adding OpenHarmony libc support to Zig. If Andrew is on board with it, then I think the changes in #20020 should be revived in this PR along with the changes you've already proposed here. We'll also need:
|
For ohos-musl you can see it with https://gitee.com/openharmony/third_party_musl. If you follow the above content, please let me know it and I will add the ohos header file to this PR. |
This PR is derived from PR #20020, aimed at adding OpenHarmony operating system support for the
zig cc
command. Since OpenHarmony's C standard library is based on musl implementation, we believe that only adding theavailable_libcs
is necessary.Additionally, we have implemented several benchmark tests based on some fundamental capabilities to ensure usability. I will provide the testing steps and my testing conclusions below.
How to Test?
You need to register on the official website and download the latest version of DevEco Studio. After installation, you need to install the emulator to provide the testing environment.
Next, you need to set an environment variable to provide platform-specific capabilities for the compiler:
Before starting the tests, we need to install some tools: cargo-zigbuild just Rust and install some toolchains.
Clone the ohos-rs repository and proceed with the build
Build example as first and just run command with below:
Open the
harmony-example
project from ohos-rs in the IDE, then right-click to run the unit tests as shownRun the complete test suite via command line to view the results
hdc shell aa test -b com.ohos.napi -m entry_test -s unittest /ets/testrunner/OpenHarmonyTestRunner
Result
Based on my current observations, the test results are consistent with those built using the NDK. All unit test cases are sourced from napi-rs. While some test cases haven't passed due to system implementation issues, I believe these can be disregarded. The successfully passed tests are sufficient to confirm the functionality of using
zig cc
as the compiler