[compiler-rt] [compiler-rt] Allow using a compiler without `stdio` and `printf` (PR #95234)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 12 05:17:31 PDT 2024


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/95234

Summary:
Part of attempts to get `compiler-rt` working for NVPTX and AMDGPU
targets. We only wish to build the builtins, which are unhosted.
Currently the build system rejects any compiler that isn't hosted due to
the check requiring `printf`. SImply make it return zero instead.


>From 59bf248e3e436855301b5a0f9924fbc8b65121d5 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Wed, 12 Jun 2024 07:15:38 -0500
Subject: [PATCH] [compiler-rt] Allow using a compiler without `stdio` and
 `printf`

Summary:
Part of attempts to get `compiler-rt` working for NVPTX and AMDGPU
targets. We only wish to build the builtins, which are unhosted.
Currently the build system rejects any compiler that isn't hosted due to
the check requiring `printf`. SImply make it return zero instead.
---
 compiler-rt/cmake/config-ix.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index bddaa37579fd7..9fe622a128ebf 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -223,7 +223,7 @@ set(COMPILER_RT_SUPPORTED_ARCH)
 # runtime libraries supported by our current compilers cross-compiling
 # abilities.
 set(SIMPLE_SOURCE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/simple.cc)
-file(WRITE ${SIMPLE_SOURCE} "#include <stdlib.h>\n#include <stdio.h>\nint main(void) { printf(\"hello, world\"); }\n")
+file(WRITE ${SIMPLE_SOURCE} "#include <stdint.h>\nint main(void) { return 0; }\n")
 
 # Detect whether the current target platform is 32-bit or 64-bit, and setup
 # the correct commandline flags needed to attempt to target 32-bit and 64-bit.



More information about the llvm-commits mailing list