-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Fix compile error on ohos #118193
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
base: main
Are you sure you want to change the base?
Fix compile error on ohos #118193
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Peng Huang (phuang) ChangesOHOS uses musl libc which doesn't have get_current_dir_name(). Removing get_current_dir_name related dfsw and dfso methods to fix the problem. Full diff: https://github.com/llvm/llvm-project/pull/118193.diff 1 Files Affected:
diff --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index dbc00d7ac3ea39..29800479d20e66 100644
--- a/compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -1077,6 +1077,8 @@ char *__dfso_getcwd(char *buf, size_t size, dfsan_label buf_label,
return ret;
}
+#if !defined(__OHOS__)
+// OpenHOS uses musl libc which doesn't have get_current_dir_name()
SANITIZER_INTERFACE_ATTRIBUTE
char *__dfsw_get_current_dir_name(dfsan_label *ret_label) {
char *ret = get_current_dir_name();
@@ -1091,6 +1093,7 @@ char *__dfso_get_current_dir_name(dfsan_label *ret_label,
dfsan_origin *ret_origin) {
return __dfsw_get_current_dir_name(ret_label);
}
+#endif
// This function is only available for glibc 2.25 or newer. Mark it weak so
// linking succeeds with older glibcs.
|
|
Thanks for the patch! Sanitizers have a Adding @browneee (dfsan maintainer) since there are no reviewers added. |
Done. |
|
Thanks @thurstond! MUSL appears to have this, but only under
glibc also only has this under
Does your system have I think it would be better to put this function under Also note llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_platform.h Lines 34 to 35 in 31bde71
llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_platform.h Lines 133 to 134 in 31bde71
|
|
Thanks for the review. I checked ohos's musl libc header. It doesn't have https://gitee.com/openharmony/third_party_musl/blob/master/include/unistd.h#L194 |
|
Your header does appear to have |
|
You are right. But the openharmony os sdk's header file doesn't have that function. It is so weird. I will ask openharmony community about the problem. |
|
Hi @browneee , Unfortunately, the ohos sdk's header file doesn't have |
OpenHarmony's libc doesn't have get_current_dir_name(), So guard get_current_dir_name() related dfsw and dfso methods with #ifndef __OHOS__.
4caf0f7 to
867e458
Compare
|
Imo the correct solution here is fix openharmony os's sdk by adding the missing function. This approach would be better for several reasons:
Was there any explanation from the openharmony community why this function was missing? Between fixing openharmony sdk vs your latest patch, do you still feel your patch is the right solution? |
They told me this function is not exposed in ohos sdk, but they didn't explain why. I will ask them to explain it.
Another solution, I can test |
This would address this issue:
But it would slightly increase this issue:
I would still recommend fixing openharmony os's sdk by adding the missing function.
Thanks! It would be good to at least hear why, before proceeding with workarounds. |
OHOS uses musl libc which doesn't have get_current_dir_name(). Removing get_current_dir_name related dfsw and dfso methods to fix the problem.