From: Petr Hosek Date: Thu, 20 Aug 2020 07:03:45 +0000 (-0700) Subject: [compiler-rt] Compile assembly files as ASM not C X-Git-Tag: llvmorg-13-init~14206 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d58fd4e52197d55bf42ca446c8b0ed31b5c2ec1f;p=platform%2Fupstream%2Fllvm.git [compiler-rt] Compile assembly files as ASM not C It isn't very wise to pass an assembly file to the compiler and tell it to compile as a C file and hope that the compiler recognizes it as assembly instead. Instead enable the ASM language and mark the files as being ASM. [525/634] Building C object lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o FAILED: lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o /opt/tooling/drive/host/bin/clang --target=aarch64-linux-gnu -I/opt/tooling/drive/llvm/compiler-rt/lib/tsan/.. -isystem /opt/tooling/drive/toolchain/opt/drive/toolchain/include -x c -Wall -Wno-unused-parameter -fno-lto -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fPIE -fno-rtti -Wframe-larger-than=530 -Wglobal-constructors --sysroot=. -MD -MT lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o -MF lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o.d -o lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o -c /opt/tooling/drive/llvm/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S /opt/tooling/drive/llvm/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S:29:1: error: expected identifier or '(' .section .text ^ 1 error generated. Fixed Clang not being passed as the assembly compiler for compiler-rt runtime build. Patch By: tambre Differential Revision: https://reviews.llvm.org/D85706 --- diff --git a/clang/runtime/CMakeLists.txt b/clang/runtime/CMakeLists.txt index e20cc26..61bbbf8 100644 --- a/clang/runtime/CMakeLists.txt +++ b/clang/runtime/CMakeLists.txt @@ -75,6 +75,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/) CMAKE_ARGS ${CLANG_COMPILER_RT_CMAKE_ARGS} -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++ + -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake index efb6608..7063cf89 100644 --- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -109,13 +109,11 @@ endfunction() function(add_asm_sources output) set(${output} ${ARGN} PARENT_SCOPE) - # Xcode will try to compile asm files as C ('clang -x c'), and that will fail. - if (${CMAKE_GENERATOR} STREQUAL "Xcode") - enable_language(ASM) - else() - # Pass ASM file directly to the C++ compiler. - set_source_files_properties(${ARGN} PROPERTIES LANGUAGE C) - endif() + # Make sure ASM language is available. + # We explicitly mark the source files as ASM, so they don't get passed to the + # C/CXX compiler and hopes that it recognizes them as assembly. + enable_language(ASM) + set_source_files_properties(${ARGN} PROPERTIES LANGUAGE ASM) endfunction() macro(set_output_name output name arch)