[libc-commits] [libc] [libc] Silence `-Winconsistent-dllimport` on Windows (PR #191560)

via libc-commits libc-commits at lists.llvm.org
Fri Apr 10 15:53:25 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Alexandre Ganea (aganea)

<details>
<summary>Changes</summary>

On non-GPU targets, malloc/free are already declared (with `dllimport` on Windows) via the system headers included by `rpc_util.h`. Re-declaring them without `dllimport` triggers `-Winconsistent-dllimport` on Windows.

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


1 Files Affected:

- (modified) libc/shared/rpc_dispatch.h (+9-1) 


``````````diff
diff --git a/libc/shared/rpc_dispatch.h b/libc/shared/rpc_dispatch.h
index dcc54852b40bc..5603eb232b149 100644
--- a/libc/shared/rpc_dispatch.h
+++ b/libc/shared/rpc_dispatch.h
@@ -12,12 +12,20 @@
 #include "rpc.h"
 #include "rpc_util.h"
 
+#ifndef RPC_TARGET_IS_GPU
+#include <cstdlib>
+#endif
+
 namespace rpc {
 namespace {
 
-// Forward declarations needed for the server, we assume these are present.
+// On non-GPU targets, malloc/free are already declared (with dllimport on
+// Windows) via the system headers included by rpc_util.h. Re-declaring them
+// without dllimport triggers -Winconsistent-dllimport on Windows.
+#ifdef RPC_TARGET_IS_GPU
 extern "C" void *malloc(__SIZE_TYPE__);
 extern "C" void free(void *);
+#endif
 
 // Traits to convert between a tuple and binary representation of an argument
 // list.

``````````

</details>


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


More information about the libc-commits mailing list