[compiler-rt] r278454 - [CMake] If the compiler supports _Atomic include atomic.c in builtins libraries
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 12 17:56:19 PDT 2016
On Thu, Aug 11, 2016 at 6:29 PM, Chris Bieneman via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: cbieneman
> Date: Thu Aug 11 20:29:26 2016
> New Revision: 278454
>
> URL: http://llvm.org/viewvc/llvm-project?rev=278454&view=rev
> Log:
> [CMake] If the compiler supports _Atomic include atomic.c in builtins
> libraries
>
> This fixes a long-standing TODO by implementing a compiler check for
> supporting the _Atomic keyword. If the _Atomic keyword is supported by the
> compiler we should include it in the builtin library sources.
>
> Modified:
> compiler-rt/trunk/cmake/Modules/BuiltinTests.cmake
> compiler-rt/trunk/cmake/builtin-config-ix.cmake
> compiler-rt/trunk/lib/builtins/CMakeLists.txt
>
I think this belongs in 3.9 as well as otherwise you end up with the
builtins missing the atomics which are needed for sizes which cannot be
lowered directly to instructions.
> Modified: compiler-rt/trunk/cmake/Modules/BuiltinTests.cmake
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/
> cmake/Modules/BuiltinTests.cmake?rev=278454&r1=278453&r2=278454&view=diff
> ============================================================
> ==================
> --- compiler-rt/trunk/cmake/Modules/BuiltinTests.cmake (original)
> +++ compiler-rt/trunk/cmake/Modules/BuiltinTests.cmake Thu Aug 11
> 20:29:26 2016
> @@ -3,11 +3,15 @@ include(CMakeCheckCompilerFlagCommonPatt
> # This function takes an OS and a list of architectures and identifies the
> # subset of the architectures list that the installed toolchain can
> target.
> function(try_compile_only output)
> + cmake_parse_arguments(ARG "" "" "SOURCE;FLAGS" ${ARGN})
> + if(NOT ARG_SOURCE)
> + set(ARG_SOURCE "int foo(int x, int y) { return x + y; }\n")
> + endif()
> set(SIMPLE_C ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/src.c)
> - file(WRITE ${SIMPLE_C} "int foo(int x, int y) { return x + y; }\n")
> + file(WRITE ${SIMPLE_C} "${ARG_SOURCE}\n")
> string(REGEX MATCHALL "<[A-Za-z0-9_]*>" substitutions
> ${CMAKE_C_COMPILE_OBJECT})
> - string(REPLACE ";" " " extra_flags "${ARGN}")
> + string(REPLACE ";" " " extra_flags "${ARG_FLAGS}")
>
> set(test_compile_command "${CMAKE_C_COMPILE_OBJECT}")
> foreach(substitution ${substitutions})
> @@ -63,7 +67,20 @@ endfunction()
> function(builtin_check_c_compiler_flag flag output)
> if(NOT DEFINED ${output})
> message(STATUS "Performing Test ${output}")
> - try_compile_only(result ${flag})
> + try_compile_only(result FLAGS ${flag})
> + set(${output} ${result} CACHE INTERNAL "Compiler supports ${flag}")
> + if(${result})
> + message(STATUS "Performing Test ${output} - Success")
> + else()
> + message(STATUS "Performing Test ${output} - Failed")
> + endif()
> + endif()
> +endfunction()
> +
> +function(builtin_check_c_compiler_source output source)
> + if(NOT DEFINED ${output})
> + message(STATUS "Performing Test ${output}")
> + try_compile_only(result SOURCE ${source})
> set(${output} ${result} CACHE INTERNAL "Compiler supports ${flag}")
> if(${result})
> message(STATUS "Performing Test ${output} - Success")
>
> Modified: compiler-rt/trunk/cmake/builtin-config-ix.cmake
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/
> cmake/builtin-config-ix.cmake?rev=278454&r1=278453&r2=278454&view=diff
> ============================================================
> ==================
> --- compiler-rt/trunk/cmake/builtin-config-ix.cmake (original)
> +++ compiler-rt/trunk/cmake/builtin-config-ix.cmake Thu Aug 11 20:29:26
> 2016
> @@ -1,4 +1,5 @@
> include(BuiltinTests)
> +include(CheckCSourceCompiles)
>
> # Make all the tests only check the compiler
> set(TEST_COMPILE_ONLY On)
> @@ -14,6 +15,15 @@ builtin_check_c_compiler_flag(-mfloat-ab
> builtin_check_c_compiler_flag(-mfloat-abi=hard
> COMPILER_RT_HAS_FLOAT_ABI_HARD_FLAG)
> builtin_check_c_compiler_flag(-static
> COMPILER_RT_HAS_STATIC_FLAG)
>
> +builtin_check_c_compiler_source(COMPILER_RT_SUPPORTS_ATOMIC_KEYWORD
> +"
> +int foo(int x, int y) {
> + _Atomic int result = x * y;
> + return result;
> +}
> +")
> +
> +
> set(ARM64 aarch64)
> set(ARM32 arm armhf)
> set(X86 i386 i686)
>
> Modified: compiler-rt/trunk/lib/builtins/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/
> builtins/CMakeLists.txt?rev=278454&r1=278453&r2=278454&view=diff
> ============================================================
> ==================
> --- compiler-rt/trunk/lib/builtins/CMakeLists.txt (original)
> +++ compiler-rt/trunk/lib/builtins/CMakeLists.txt Thu Aug 11 20:29:26 2016
> @@ -42,8 +42,6 @@ set(GENERIC_SOURCES
> ashlti3.c
> ashrdi3.c
> ashrti3.c
> - # FIXME: atomic.c may only be compiled if host compiler understands
> _Atomic
> - # atomic.c
> clear_cache.c
> clzdi2.c
> clzsi2.c
> @@ -166,6 +164,12 @@ set(GENERIC_SOURCES
> umodsi3.c
> umodti3.c)
>
> +if(COMPILER_RT_SUPPORTS_ATOMIC_KEYWORD)
> + set(GENERIC_SOURCES
> + ${GENERIC_SOURCES}
> + atomic.c)
> +endif()
> +
> set(MSVC_SOURCES
> divsc3.c
> divdc3.c
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
--
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160812/74626653/attachment.html>
More information about the llvm-commits
mailing list