[llvm-branch-commits] [compiler-rt] compiler-rt: Introduce runtime functions for emulated PAC. (PR #133530)
Peter Collingbourne via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Apr 3 21:51:59 PDT 2025
https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/133530
>From b37a44fff650b06eda249060277d0c007226cad2 Mon Sep 17 00:00:00 2001
From: Peter Collingbourne <pcc at google.com>
Date: Thu, 3 Apr 2025 21:51:44 -0700
Subject: [PATCH] Fix CMake build
Created using spr 1.3.6-beta.1
---
compiler-rt/cmake/Modules/AddCompilerRT.cmake | 8 +++++++-
compiler-rt/cmake/builtin-config-ix.cmake | 1 +
compiler-rt/lib/builtins/CMakeLists.txt | 8 ++++++--
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index c3e734f72392f..2f6fd4ba1e4c9 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -172,7 +172,7 @@ function(add_compiler_rt_runtime name type)
cmake_parse_arguments(LIB
""
"PARENT_TARGET"
- "OS;ARCHS;SOURCES;CFLAGS;LINK_FLAGS;DEFS;DEPS;LINK_LIBS;OBJECT_LIBS;ADDITIONAL_HEADERS;EXTENSIONS"
+ "OS;ARCHS;SOURCES;CFLAGS;LINK_FLAGS;DEFS;DEPS;LINK_LIBS;OBJECT_LIBS;ADDITIONAL_HEADERS;EXTENSIONS;C_STANDARD;CXX_STANDARD"
${ARGN})
set(libnames)
# Until we support this some other way, build compiler-rt runtime without LTO
@@ -360,6 +360,12 @@ function(add_compiler_rt_runtime name type)
set_target_link_flags(${libname} ${extra_link_flags_${libname}})
set_property(TARGET ${libname} APPEND PROPERTY
COMPILE_DEFINITIONS ${LIB_DEFS})
+ if(LIB_C_STANDARD)
+ set_property(TARGET ${libname} PROPERTY C_STANDARD ${LIB_C_STANDARD})
+ endif()
+ if(LIB_CXX_STANDARD)
+ set_property(TARGET ${libname} PROPERTY CXX_STANDARD ${LIB_CXX_STANDARD})
+ endif()
set_target_output_directories(${libname} ${output_dir_${libname}})
install(TARGETS ${libname}
ARCHIVE DESTINATION ${install_dir_${libname}}
diff --git a/compiler-rt/cmake/builtin-config-ix.cmake b/compiler-rt/cmake/builtin-config-ix.cmake
index 7bd3269bd999d..7bdd30ee67f3d 100644
--- a/compiler-rt/cmake/builtin-config-ix.cmake
+++ b/compiler-rt/cmake/builtin-config-ix.cmake
@@ -26,6 +26,7 @@ builtin_check_c_compiler_flag("-Xclang -mcode-object-version=none" COMPILER_RT_H
builtin_check_c_compiler_flag(-Wbuiltin-declaration-mismatch COMPILER_RT_HAS_WBUILTIN_DECLARATION_MISMATCH_FLAG)
builtin_check_c_compiler_flag(/Zl COMPILER_RT_HAS_ZL_FLAG)
builtin_check_c_compiler_flag(-fcf-protection=full COMPILER_RT_HAS_FCF_PROTECTION_FLAG)
+builtin_check_c_compiler_flag(-nostdinc++ COMPILER_RT_HAS_NOSTDINCXX_FLAG)
builtin_check_c_compiler_source(COMPILER_RT_HAS_ATOMIC_KEYWORD
"
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index e6c3273eb2859..ca5cc7d218223 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -6,7 +6,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
cmake_minimum_required(VERSION 3.20.0)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
- project(CompilerRTBuiltins C ASM)
+ project(CompilerRTBuiltins C CXX ASM)
set(COMPILER_RT_STANDALONE_BUILD TRUE)
set(COMPILER_RT_BUILTINS_STANDALONE_BUILD TRUE)
@@ -64,6 +64,8 @@ include(CMakePushCheckState)
option(COMPILER_RT_BUILTINS_HIDE_SYMBOLS
"Do not export any symbols from the static library." ON)
+include_directories(../../../third-party/siphash/include)
+
# TODO: Need to add a mechanism for logging errors when builtin source files are
# added to a sub-directory and not this CMakeLists file.
set(GENERIC_SOURCES
@@ -803,7 +805,7 @@ else ()
append_list_if(COMPILER_RT_ENABLE_CET -fcf-protection=full BUILTIN_CFLAGS)
endif()
- append_list_if(COMPILER_RT_HAS_STD_C11_FLAG -std=c11 BUILTIN_CFLAGS)
+ append_list_if(COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ BUILTIN_CFLAGS)
append_list_if(COMPILER_RT_HAS_WBUILTIN_DECLARATION_MISMATCH_FLAG -Werror=builtin-declaration-mismatch BUILTIN_CFLAGS)
# Don't embed directives for picking any specific CRT
@@ -918,6 +920,8 @@ else ()
SOURCES ${${arch}_SOURCES}
DEFS ${BUILTIN_DEFS}
CFLAGS ${BUILTIN_CFLAGS_${arch}}
+ C_STANDARD 11
+ CXX_STANDARD 17
PARENT_TARGET builtins)
cmake_pop_check_state()
endif ()
More information about the llvm-branch-commits
mailing list