diff options
Diffstat (limited to 'libc/cmake/modules')
| -rw-r--r-- | libc/cmake/modules/CheckCompilerFeatures.cmake | 3 | ||||
| -rw-r--r-- | libc/cmake/modules/LLVMLibCLibraryRules.cmake | 29 | ||||
| -rw-r--r-- | libc/cmake/modules/LLVMLibCObjectRules.cmake | 25 | ||||
| -rw-r--r-- | libc/cmake/modules/LibcParseArguments.cmake | 87 | ||||
| -rw-r--r-- | libc/cmake/modules/compiler_features/check_ext_vector_type.cpp | 7 | ||||
| -rw-r--r-- | libc/cmake/modules/prepare_libc_gpu_build.cmake | 10 |
6 files changed, 101 insertions, 60 deletions
diff --git a/libc/cmake/modules/CheckCompilerFeatures.cmake b/libc/cmake/modules/CheckCompilerFeatures.cmake index a5ea66a5935b..4d50d81e0ce4 100644 --- a/libc/cmake/modules/CheckCompilerFeatures.cmake +++ b/libc/cmake/modules/CheckCompilerFeatures.cmake @@ -15,6 +15,7 @@ set( "fixed_point" "cfloat16" "cfloat128" + "ext_vector_type" ) # Making sure ALL_COMPILER_FEATURES is sorted. @@ -126,6 +127,8 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES) set(LIBC_COMPILER_HAS_BUILTIN_ROUND TRUE) elseif(${feature} STREQUAL "builtin_roundeven") set(LIBC_COMPILER_HAS_BUILTIN_ROUNDEVEN TRUE) + elseif(${feature} STREQUAL "ext_vector_type") + set(LIBC_COMPILER_HAS_EXT_VECTOR_TYPE TRUE) endif() endif() endforeach() diff --git a/libc/cmake/modules/LLVMLibCLibraryRules.cmake b/libc/cmake/modules/LLVMLibCLibraryRules.cmake index b464c189420b..80439de6bb4b 100644 --- a/libc/cmake/modules/LLVMLibCLibraryRules.cmake +++ b/libc/cmake/modules/LLVMLibCLibraryRules.cmake @@ -151,35 +151,6 @@ function(add_entrypoint_library target_name) set_target_properties(${target_name} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${LIBC_LIBRARY_DIR}) endfunction(add_entrypoint_library) -# Rule to build a shared library of redirector objects. -function(add_redirector_library target_name) - cmake_parse_arguments( - "REDIRECTOR_LIBRARY" - "" - "" - "DEPENDS" - ${ARGN} - ) - - set(obj_files "") - foreach(dep IN LISTS REDIRECTOR_LIBRARY_DEPENDS) - # TODO: Ensure that each dep is actually a add_redirector_object target. - list(APPEND obj_files $<TARGET_OBJECTS:${dep}>) - endforeach(dep) - - # TODO: Call the linker explicitly instead of calling the compiler driver to - # prevent DT_NEEDED on C++ runtime. - add_library( - ${target_name} - EXCLUDE_FROM_ALL - SHARED - ${obj_files} - ) - set_target_properties(${target_name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${LIBC_LIBRARY_DIR}) - target_link_libraries(${target_name} -nostdlib -lc -lm) - set_target_properties(${target_name} PROPERTIES LINKER_LANGUAGE "C") -endfunction(add_redirector_library) - set(HDR_LIBRARY_TARGET_TYPE "HDR_LIBRARY") # Internal function, used by `add_header_library`. diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake index 030157bf6458..6c534dfccec1 100644 --- a/libc/cmake/modules/LLVMLibCObjectRules.cmake +++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake @@ -470,31 +470,6 @@ function(add_entrypoint_external target_name) endfunction(add_entrypoint_external) -# Rule build a redirector object file. -function(add_redirector_object target_name) - cmake_parse_arguments( - "REDIRECTOR_OBJECT" - "" # No optional arguments - "SRC" # The cpp file in which the redirector is defined. - "" # No multivalue arguments - ${ARGN} - ) - if(NOT REDIRECTOR_OBJECT_SRC) - message(FATAL_ERROR "'add_redirector_object' rule requires SRC option listing one source file.") - endif() - - add_library( - ${target_name} - EXCLUDE_FROM_ALL - OBJECT - ${REDIRECTOR_OBJECT_SRC} - ) - target_compile_options( - ${target_name} - BEFORE PRIVATE -fPIC ${LIBC_COMPILE_OPTIONS_DEFAULT} - ) -endfunction(add_redirector_object) - # Helper to define a function with multiple implementations # - Computes flags to satisfy required/rejected features and arch, # - Declares an entry point, diff --git a/libc/cmake/modules/LibcParseArguments.cmake b/libc/cmake/modules/LibcParseArguments.cmake new file mode 100644 index 000000000000..ef4a2aff0ce8 --- /dev/null +++ b/libc/cmake/modules/LibcParseArguments.cmake @@ -0,0 +1,87 @@ +set(LLVM_LIBC_OPTIONAL_ARGS + ALIAS + PUBLIC + NO_GPU_BUNDLE + NO_RUN_POSTBUILD + C_TEST + NEED_MPFR + NEED_MPC + IS_GPU_BENCHMARK +) + +set(LLVM_LIBC_SINGLE_VALUE_ARGS + CXX_STANDARD + SUITE + CREATE_TARGET_FUNCTION + HDR + DEST_HDR + YAML_FILE + GEN_HDR + NAME +) + +set(LLVM_LIBC_MULTI_VALUE_ARGS + HDRS + SRCS + COMPILE_OPTIONS + LINK_OPTIONS + LINK_LIBRARIES + ENV + DEPENDS + FLAGS + ARGS + LOADER_ARGS +) + +foreach(arg_list LLVM_LIBC_OPTIONAL_ARGS LLVM_LIBC_SINGLE_VALUE_ARGS LLVM_LIBC_MULTI_VALUE_ARGS) + list(TRANSFORM ${arg_list} + PREPEND "OVERLAY_" + OUTPUT_VARIABLE ${arg_list}_OVERLAY + ) + list(TRANSFORM ${arg_list} + PREPEND "FULL_BUILD_" + OUTPUT_VARIABLE ${arg_list}_FULL_BUILD + ) + set(${arg_list}_COMPLETE ${${arg_list}} ${${arg_list}_OVERLAY} ${${arg_list}_FULL_BUILD}) +endforeach() + +macro(llvm_libc_parse_arguments name_prefix) + cmake_parse_arguments( + ${name_prefix} + "${LLVM_LIBC_OPTIONAL_ARGS_COMPLETE}" + "${LLVM_LIBC_SINGLE_VALUE_ARGS_COMPLETE}" + "${LLVM_LIBC_MULTI_VALUE_ARGS_COMPLETE}" + ${ARGN} + ) + + # Collect overlay and full build args + foreach(argument IN LISTS LLVM_LIBC_OPTIONAL_ARGS LLVM_LIBC_SINGLE_VALUE_ARGS LLVM_LIBC_MULTI_VALUE_ARGS) + if(LLVM_LIBC_FULL_BUILD) + if(${name_prefix}_${argument}_FULL_BUILD) + list(APPEND ${name_prefix}_${argument} ${${name_prefix}_${argument}_FULL_BUILD}) + endif() + else() + if(${name_prefix}_${argument}_OVERLAY) + list(APPEND ${name_prefix}_${argument} ${${name_prefix}_${argument}_OVERLAY}) + endif() + endif() + endforeach() +endmacro() + +# Forward all arguments that can be used for llvm_libc_parse_arguments again. +# Assume that *_OVERLAY and *_FULL_BUILD args have been merged properly. +macro(forward_arguments name_prefix output) + set(${output} "") + + foreach(argument ${LLVM_LIBC_OPTIONAL_ARGS}) + if(${name_prefix}_${argument}) + list(APPEND output ${argument}) + endif() + endforeach() + + foreach(argument ${LLVM_LIBC_SINGLE_VALUE_ARGS} ${LLVM_LIBC_MULTI_VALUE_ARGS}) + if(${name_prefix}_${argument}) + list(APPEND output ${argument} "${${name_prefix}_${argument}}") + endif() + endforeach() +endmacro() diff --git a/libc/cmake/modules/compiler_features/check_ext_vector_type.cpp b/libc/cmake/modules/compiler_features/check_ext_vector_type.cpp new file mode 100644 index 000000000000..f268a8ff540f --- /dev/null +++ b/libc/cmake/modules/compiler_features/check_ext_vector_type.cpp @@ -0,0 +1,7 @@ +#include "src/__support/macros/attributes.h" + +#if !LIBC_HAS_VECTOR_TYPE +#error unsupported +#endif + +bool [[clang::ext_vector_type(1)]] v; diff --git a/libc/cmake/modules/prepare_libc_gpu_build.cmake b/libc/cmake/modules/prepare_libc_gpu_build.cmake index f8f5a954e5e9..df1de1454c3e 100644 --- a/libc/cmake/modules/prepare_libc_gpu_build.cmake +++ b/libc/cmake/modules/prepare_libc_gpu_build.cmake @@ -100,12 +100,10 @@ if(NOT TARGET libc.utils.gpu.loader AND gpu_loader_executable) ) endif() -if(LIBC_TARGET_ARCHITECTURE_IS_AMDGPU) - # The AMDGPU environment uses different code objects to encode the ABI for - # kernel calls and intrinsic functions. We want to specify this manually to - # conform to whatever the test suite was built to handle. - set(LIBC_GPU_CODE_OBJECT_VERSION 6) -endif() +# The AMDGPU environment uses different code objects to encode the ABI for +# kernel calls and intrinsic functions. We want to expose this to conform to +# whatever the test suite was built to handle. +set(LIBC_GPU_CODE_OBJECT_VERSION "6" CACHE STRING "AMDGPU Code object ABI to use") if(LIBC_TARGET_ARCHITECTURE_IS_NVPTX) # FIXME: This is a hack required to keep the CUDA package from trying to find |
