diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -71,9 +71,13 @@ message(STATUS "Set COMPILER_RESOURCE_DIR to " "${COMPILER_RESOURCE_DIR} using --print-resource-dir") else() - set(COMPILER_RESOURCE_DIR OFF) - message(STATUS "COMPILER_RESOURCE_DIR not set - --print-resource-dir not supported by host compiler") + if (LIBC_TARGET_ARCHITECTURE_IS_GPU) + message(FATAL_ERROR "COMPILER_RESOURCE_DIR must be set for GPU builds") + else() + set(COMPILER_RESOURCE_DIR OFF) + message(STATUS "COMPILER_RESOURCE_DIR not set + --print-resource-dir not supported by host compiler") + endif() endif() option(LLVM_LIBC_FULL_BUILD "Build and test LLVM libc as if it is the full libc" OFF) diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake --- a/libc/cmake/modules/LLVMLibCObjectRules.cmake +++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake @@ -68,6 +68,11 @@ if (LIBC_TARGET_ARCHITECTURE_IS_GPU) list(APPEND compile_options "-nogpulib") list(APPEND compile_options "-fvisibility=hidden") + + # Manually disable all standard include paths and include the resource + # directory to prevent system headers from being included. + list(APPEND compile_options "-isystem${COMPILER_RESOURCE_DIR}/include") + list(APPEND compile_options "-nostdinc") endif() set(${output_var} ${compile_options} PARENT_SCOPE) endfunction()