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

Andrew Browne via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 1 10:02:51 PST 2024


browneee wrote:

Thanks @thurstond!

MUSL appears to have this, but only under `_GNU_SOURCE`: 

* https://git.musl-libc.org/cgit/musl/tree/include/unistd.h#n193
* https://git.musl-libc.org/cgit/musl/tree/src/misc/get_current_dir_name.c


glibc also only has this under  `_GNU_SOURCE` (via glibc's internal set `__USE_GNU`). 
* https://sourceware.org/git/?p=glibc.git;a=blob;f=include/features.h;h=0a8aa7c4f9b8c6e27215ec67829f6306a7e5dc06;hb=refs/heads/master#l429
* https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/unistd.h;h=54d7d7527ee216ff653374e0d834e3994f952ce6;hb=refs/heads/master#l533

Does your system have `_GNU_SOURCE` defined?

I think it would be better to put this function under `#ifdef _GNU_SOURCE`.

----

Also note `SANITIZER_MUSL` looks at `__GLIBC__`, not `_GNU_SOURCE` so I think it would be less precise than using `_GNU_SOURCE` here.

https://github.com/llvm/llvm-project/blob/31bde711c4098b3136edd1cb92dd4e0cc1d4d179/compiler-rt/lib/sanitizer_common/sanitizer_platform.h#L34-L35

https://github.com/llvm/llvm-project/blob/31bde711c4098b3136edd1cb92dd4e0cc1d4d179/compiler-rt/lib/sanitizer_common/sanitizer_platform.h#L133-L134

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


More information about the llvm-commits mailing list