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

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


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

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.

>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] 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.



More information about the llvm-commits mailing list