[libc-commits] [libc] [libc] Provide empty weak implementation of baremetal OSUtil (PR #86916)

via libc-commits libc-commits at lists.llvm.org
Thu Mar 28 00:13:43 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Petr Hosek (petrhosek)

<details>
<summary>Changes</summary>

This avoids vendor having to provide one in order to link the libc.

---
Full diff: https://github.com/llvm/llvm-project/pull/86916.diff


2 Files Affected:

- (modified) libc/src/__support/OSUtil/baremetal/io.cpp (+1-1) 
- (modified) libc/src/__support/OSUtil/baremetal/quick_exit.cpp (+3-1) 


``````````diff
diff --git a/libc/src/__support/OSUtil/baremetal/io.cpp b/libc/src/__support/OSUtil/baremetal/io.cpp
index 347c7d405b0a9f..61d12aa7865700 100644
--- a/libc/src/__support/OSUtil/baremetal/io.cpp
+++ b/libc/src/__support/OSUtil/baremetal/io.cpp
@@ -11,7 +11,7 @@
 #include "src/__support/CPP/string_view.h"
 
 // This is intended to be provided by the vendor.
-extern "C" void __llvm_libc_log_write(const char *msg, size_t len);
+extern "C" [[gnu::weak]] void __llvm_libc_log_write(const char *, size_t) {}
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/__support/OSUtil/baremetal/quick_exit.cpp b/libc/src/__support/OSUtil/baremetal/quick_exit.cpp
index 5b6fcf42341ebb..be29e83b68ce67 100644
--- a/libc/src/__support/OSUtil/baremetal/quick_exit.cpp
+++ b/libc/src/__support/OSUtil/baremetal/quick_exit.cpp
@@ -9,7 +9,9 @@
 #include "src/__support/OSUtil/quick_exit.h"
 
 // This is intended to be provided by the vendor.
-extern "C" [[noreturn]] void __llvm_libc_quick_exit(int status);
+extern "C" [[gnu::weak]] [[noreturn]] void __llvm_libc_quick_exit(int) {
+  __builtin_trap();
+}
 
 namespace LIBC_NAMESPACE {
 

``````````

</details>


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


More information about the libc-commits mailing list