diff --git a/libc/src/stdlib/gpu/free.cpp b/libc/src/stdlib/gpu/free.cpp index 1f0e9ec735974..6ef9d718315a5 100644 --- a/libc/src/stdlib/gpu/free.cpp +++ b/libc/src/stdlib/gpu/free.cpp @@ -14,6 +14,10 @@ namespace LIBC_NAMESPACE_DECL { +// FIXME: For now we just default to the NVIDIA device allocator which is +// always available on NVPTX targets. This will be implemented fully later. +#ifndef LIBC_TARGET_ARCH_IS_NVPTX LLVM_LIBC_FUNCTION(void, free, (void *ptr)) { gpu::deallocate(ptr); } +#endif } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdlib/gpu/malloc.cpp b/libc/src/stdlib/gpu/malloc.cpp index 54f2d8843996e..b5909cb9cb4d0 100644 --- a/libc/src/stdlib/gpu/malloc.cpp +++ b/libc/src/stdlib/gpu/malloc.cpp @@ -14,8 +14,12 @@ namespace LIBC_NAMESPACE_DECL { +// FIXME: For now we just default to the NVIDIA device allocator which is +// always available on NVPTX targets. This will be implemented fully later. +#ifndef LIBC_TARGET_ARCH_IS_NVPTX LLVM_LIBC_FUNCTION(void *, malloc, (size_t size)) { return gpu::allocate(size); } +#endif } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/test/src/stdlib/CMakeLists.txt b/libc/test/src/stdlib/CMakeLists.txt index 8cc0428632ba3..aba76833be9d4 100644 --- a/libc/test/src/stdlib/CMakeLists.txt +++ b/libc/test/src/stdlib/CMakeLists.txt @@ -420,7 +420,8 @@ if(LLVM_LIBC_FULL_BUILD) ) # Only baremetal and GPU has an in-tree 'malloc' implementation. - if(LIBC_TARGET_OS_IS_BAREMETAL OR LIBC_TARGET_OS_IS_GPU) + if((LIBC_TARGET_OS_IS_BAREMETAL OR LIBC_TARGET_OS_IS_GPU) AND + NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX) add_libc_test( malloc_test HERMETIC_TEST_ONLY