[libc-commits] [libc] [libc] Move from alias(X) to asm(X) for aliasing (PR #89333)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Fri Apr 19 15:08:02 PDT 2024
nickdesaulniers wrote:
Yeah that seems to work on the small scale to fix #60481.
```
$ cd <new build dir>
$ cmake ../llvm -DLLVM_ENABLE_PROJECTS="libc" -DCMAKE_BUILD_TYPE=Release -G Ninja
$ ninja libc.src.stdlib.bsearch
<explosion from #60481>
```
apply the above diff plus:
```diff
diff --git a/libc/src/stdlib/bsearch.cpp b/libc/src/stdlib/bsearch.cpp
index 4292d6b6fe04..fe02f5fb8366 100644
--- a/libc/src/stdlib/bsearch.cpp
+++ b/libc/src/stdlib/bsearch.cpp
@@ -9,9 +9,8 @@
#include "src/stdlib/bsearch.h"
#include "src/__support/common.h"
-#include <stdint.h>
-
-namespace LIBC_NAMESPACE {
+#include <stdint.h> // uint8_t
+#include <stddef.h> // size_t
LLVM_LIBC_FUNCTION(void *, bsearch,
(const void *key, const void *array, size_t array_size,
@@ -43,5 +42,3 @@ LLVM_LIBC_FUNCTION(void *, bsearch,
return nullptr;
}
-
-} // namespace LIBC_NAMESPACE
diff --git a/libc/src/stdlib/bsearch.h b/libc/src/stdlib/bsearch.h
index 1de7e051ff6c..cf3188c3adc7 100644
--- a/libc/src/stdlib/bsearch.h
+++ b/libc/src/stdlib/bsearch.h
@@ -9,13 +9,9 @@
#ifndef LLVM_LIBC_SRC_STDLIB_BSEARCH_H
#define LLVM_LIBC_SRC_STDLIB_BSEARCH_H
-#include <stdlib.h>
+#include <stddef.h> // size_t
-namespace LIBC_NAMESPACE {
-
-void *bsearch(const void *key, const void *array, size_t array_size,
+extern "C" void *bsearch(const void *key, const void *array, size_t array_size,
size_t elem_size, int (*compare)(const void *, const void *));
-} // namespace LIBC_NAMESPACE
-
#endif //LLVM_LIBC_SRC_STDLIB_BSEARCH_H
```
```
$ ninja libc.src.stdlib.bsearch
$ llvm-readelf -sW projects/libc/src/stdlib/CMakeFiles/libc.src.stdlib.bsearch.dir/bsearch.cpp.o | llvm-cxxfilt
Symbol table '.symtab' contains 4 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS bsearch.cpp
2: 0000000000000000 154 FUNC GLOBAL DEFAULT 4 bsearch
3: 0000000000000000 154 FUNC GLOBAL DEFAULT 4 __llvm_libc_19_0_0_git::bsearch(void const*, void const*, unsigned long, unsigned long, int (*)(void const*, void const*))
```
https://github.com/llvm/llvm-project/pull/89333
More information about the libc-commits
mailing list