[libc-commits] [clang] [libc] [llvm] [OFFLOAD] Add support to build libc for SPIRV backend (PR #181049)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Mon Feb 16 14:20:35 PST 2026


================
@@ -0,0 +1,71 @@
+//===-- Implementation of crt for amdgpu ----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "config/gpu/app.h"
+#include "src/__support/GPU/utils.h"
+#include "src/__support/RPC/rpc_client.h"
+#include "src/__support/macros/config.h"
+#include "src/stdlib/atexit.h"
+#include "src/stdlib/exit.h"
+
+extern "C" int main(int argc, char **argv, char **envp);
+extern "C" void __cxa_finalize(void *dso);
+
+namespace LIBC_NAMESPACE_DECL {
+
+// FIXME: Touch this symbol to force this to be linked in statically.
+volatile void *dummy = &LIBC_NAMESPACE::rpc::client;
+
+DataEnvironment app;
+
+extern "C" uintptr_t __init_array_start[];
----------------
jhuber6 wrote:

I doubt this works with SPIR-V, this is linker magic which will need to be looked at separately. In the future I'll probably move this to use the LLVM/Offload infra, so might be better to separately get global constructors working on SPIR-V there. This is used for testing so we should just be able to omit it for now.

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


More information about the libc-commits mailing list