[compiler-rt] Fix compile error on ohos (PR #118193)

Peng Huang via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 30 20:29:54 PST 2024


https://github.com/phuang updated https://github.com/llvm/llvm-project/pull/118193

>From eb6f3f95c29d994f82837cb268a30caa8d22f98e Mon Sep 17 00:00:00 2001
From: Peng Huang <shawn.p.huang at gmail.com>
Date: Sat, 30 Nov 2024 22:51:59 -0500
Subject: [PATCH 1/2] Fix compile error on ohos

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.
---
 compiler-rt/lib/dfsan/dfsan_custom.cpp | 3 +++
 1 file changed, 3 insertions(+)

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.

>From e12a66b511d0bc79ffdd42ee0e52db1e40dd15af Mon Sep 17 00:00:00 2001
From: Peng Huang <shawn.p.huang at gmail.com>
Date: Sat, 30 Nov 2024 23:29:41 -0500
Subject: [PATCH 2/2] wip

---
 compiler-rt/lib/dfsan/dfsan_custom.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index 29800479d20e66..004da5e231b382 100644
--- a/compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -1077,7 +1077,7 @@ char *__dfso_getcwd(char *buf, size_t size, dfsan_label buf_label,
   return ret;
 }
 
-#if !defined(__OHOS__)
+#if !SANITIZER_MUSL
 // 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) {



More information about the llvm-commits mailing list