Skip to content

Commit

Permalink
[CMake][compiler-rt] Use copying instead of symlinking for LSE builti…
Browse files Browse the repository at this point in the history
…ns on non-Unix-likes

As reported in D93278 post-review symlinking requires privilege escalation on Windows.
Copying is functionally same, so fallback to it for systems that aren't Unix-like.
This is similar to the solution in AddLLVM.cmake.

Reviewed By: ikudrin

Differential Revision: https://reviews.llvm.org/D98111

(cherry picked from commit ba86096)
  • Loading branch information
tambry authored and tstellar committed Mar 9, 2021
1 parent bff59ac commit 15d1ee3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion compiler-rt/lib/builtins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -515,14 +515,20 @@ set(aarch64_SOURCES
set(OA_HELPERS_DIR "${CMAKE_CURRENT_BINARY_DIR}/outline_atomic_helpers.dir")
file(MAKE_DIRECTORY "${OA_HELPERS_DIR}")

if(CMAKE_HOST_UNIX)
set(COMPILER_RT_LINK_OR_COPY create_symlink)
else()
set(COMPILER_RT_LINK_OR_COPY copy)
endif()

foreach(pat cas swp ldadd ldclr ldeor ldset)
foreach(size 1 2 4 8 16)
foreach(model 1 2 3 4)
if(pat STREQUAL "cas" OR NOT size STREQUAL "16")
set(helper_asm "${OA_HELPERS_DIR}/outline_atomic_${pat}${size}_${model}.S")
add_custom_command(
OUTPUT ${helper_asm}
COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/aarch64/lse.S" "${helper_asm}"
COMMAND ${CMAKE_COMMAND} -E ${COMPILER_RT_LINK_OR_COPY} "${CMAKE_CURRENT_SOURCE_DIR}/aarch64/lse.S" "${helper_asm}"
)
set_source_files_properties("${helper_asm}"
PROPERTIES
Expand Down

0 comments on commit 15d1ee3

Please sign in to comment.