Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move llvm-libunwind to src/native/external #72418

Merged
merged 1 commit into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion eng/native/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ endfunction(find_unwind_libs)
function(convert_to_absolute_path RetSources)
set(Sources ${ARGN})
foreach(Source IN LISTS Sources)
list(APPEND AbsolutePathSources ${CMAKE_CURRENT_SOURCE_DIR}/${Source})
get_filename_component(AbsolutePathSource ${Source} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
list(APPEND AbsolutePathSources ${AbsolutePathSource})
endforeach()
set(${RetSources} ${AbsolutePathSources} PARENT_SCOPE)
endfunction(convert_to_absolute_path)
Expand Down
43 changes: 8 additions & 35 deletions src/coreclr/nativeaot/Runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ set(FULL_RUNTIME_SOURCES
ThunksMapping.cpp
)

set(RUNTIME_SOURCES_ARCH_ASM
)

set(PORTABLE_RUNTIME_SOURCES
)

include_directories(inc)

include_directories(.)
Expand Down Expand Up @@ -124,18 +118,13 @@ if(WIN32)
rheventtrace.cpp
)

list(APPEND FULL_RUNTIME_SOURCES
windows/CoffNativeCodeManager.cpp
)
list(APPEND FULL_RUNTIME_SOURCES windows/CoffNativeCodeManager.cpp)

set(ASM_SUFFIX asm)

if (CLR_CMAKE_TARGET_ARCH_I386 OR CLR_CMAKE_TARGET_ARCH_AMD64)
list(APPEND RUNTIME_SOURCES_ARCH_ASM
${ARCH_SOURCES_DIR}/GC.${ASM_SUFFIX}
)
set(RUNTIME_SOURCES_ARCH_ASM ${ARCH_SOURCES_DIR}/GC.${ASM_SUFFIX})
endif()

else()

include_directories(unix)
Expand All @@ -148,16 +137,11 @@ else()
include(CheckLibraryExists)

include(${GC_DIR}/unix/configure.cmake)

if(NOT CLR_CMAKE_TARGET_ARCH_WASM)
include_directories(../libunwind/include)
else()

if(CLR_CMAKE_TARGET_ARCH_WASM)
include_directories($ENV{EMSCRIPTEN/system/lib/libcxxabi/include})
endif()

include_directories(../libunwind/include)
include_directories(../libunwind)

# Disable building _Unwind_XXX style APIs of libunwind, since we don't use them.
add_definitions(-D_LIBUNWIND_DISABLE_ZERO_COST_APIS=1)

Expand All @@ -178,22 +162,14 @@ else()
unix/UnixSignals.cpp
unix/UnwindHelpers.cpp
unix/UnixNativeCodeManager.cpp
../libunwind/src/Unwind-EHABI.cpp
../libunwind/src/libunwind.cpp
)

if(CLR_CMAKE_TARGET_OSX)
list(APPEND FULL_RUNTIME_SOURCES
../libunwind/src/Unwind_AppleExtras.cpp
)
endif()
include(${CLR_SRC_NATIVE_DIR}/external/llvm-libunwind.cmake)

set(ASM_SUFFIX S)
list(APPEND FULL_RUNTIME_SOURCES ${LLVM_LIBUNWIND_SOURCES})
set(RUNTIME_SOURCES_ARCH_ASM ${LLVM_LIBUNWIND_ASM_SOURCES})

list(APPEND RUNTIME_SOURCES_ARCH_ASM
../libunwind/src/UnwindRegistersRestore.S
../libunwind/src/UnwindRegistersSave.S
)
set(ASM_SUFFIX S)
endif()

if (CLR_CMAKE_TARGET_ARCH_AMD64 AND CLR_CMAKE_TARGET_WIN32)
Expand Down Expand Up @@ -270,11 +246,8 @@ set(RUNTIME_DIR ${CMAKE_CURRENT_SOURCE_DIR})
list(APPEND COMMON_RUNTIME_SOURCES ${GC_HEADERS})

convert_to_absolute_path(COMMON_RUNTIME_SOURCES ${COMMON_RUNTIME_SOURCES})

convert_to_absolute_path(FULL_RUNTIME_SOURCES ${FULL_RUNTIME_SOURCES})
convert_to_absolute_path(PORTABLE_RUNTIME_SOURCES ${PORTABLE_RUNTIME_SOURCES})
convert_to_absolute_path(SERVER_GC_SOURCES ${SERVER_GC_SOURCES})

convert_to_absolute_path(RUNTIME_SOURCES_ARCH_ASM ${RUNTIME_SOURCES_ARCH_ASM})

if(NOT CLR_CMAKE_TARGET_ARCH_WASM)
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/nativeaot/Runtime/unix/UnwindHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

// libunwind headers
#include <libunwind.h>
#include <src/config.h>
#include <src/Registers.hpp>
#include <src/AddressSpace.hpp>
#include <external/llvm-libunwind/src/config.h>
#include <external/llvm-libunwind/src/Registers.hpp>
#include <external/llvm-libunwind/src/AddressSpace.hpp>
#if defined(TARGET_ARM)
#include <src/libunwind_ext.h>
#include <external/llvm-libunwind/src/libunwind_ext.h>
#endif
#include <src/UnwindCursor.hpp>
#include <external/llvm-libunwind/src/UnwindCursor.hpp>


#if defined(TARGET_AMD64)
Expand Down
5 changes: 5 additions & 0 deletions src/native/external/llvm-libunwind-version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
v9.0.0
https://github.com/llvm/llvm-project/releases/tag/llvmorg-9.0.0

Apply https://github.com/dotnet/runtime/commit/371905898f2c036cc30d662e8a6df162a21967a5
Reapply changes from https://github.com/dotnet/runtime/commit/62075f115efeecaee9d94f87d0766d657a72fa76
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file keeps track of how to reproduce src/native/external/llvm-libunwind/ directory from scratch. When we will upgrade to https://github.com/llvm/llvm-project/releases/tag/llvmorg-14.0.6 for example, we can update this file to reflect how are we diverging from upstream. It will also help us plan upstreaming the local patches.

Copy link
Member

@VSadov VSadov Jul 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 62075f1 has the changes that the upstream also has.
I am ok with including that commit, if it makes the tracking more convenient, just wonder if that is expected.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those changes were added in v14.0.0-rc1:
image

our current version is 9.0.0. We can adjust the these additional deltas once we upgrade to newer version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Makes sense.

23 changes: 23 additions & 0 deletions src/native/external/llvm-libunwind.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
if(NOT CLR_CMAKE_TARGET_ARCH_WASM)
include_directories(BEFORE "${CMAKE_CURRENT_LIST_DIR}/llvm-libunwind/include")
endif()

set (LLVM_LIBUNWIND_SOURCES_BASE
src/Unwind-EHABI.cpp
src/libunwind.cpp
)

if(CLR_CMAKE_TARGET_OSX)
set(LLVM_LIBUNWIND_SOURCES_BASE
${LLVM_LIBUNWIND_SOURCES_BASE}
src/Unwind_AppleExtras.cpp
)
endif()

set(LLVM_LIBUNWIND_ASM_SOURCES_BASE
src/UnwindRegistersRestore.S
src/UnwindRegistersSave.S
)

addprefix(LLVM_LIBUNWIND_SOURCES "${CMAKE_CURRENT_LIST_DIR}/llvm-libunwind" "${LLVM_LIBUNWIND_SOURCES_BASE}")
addprefix(LLVM_LIBUNWIND_ASM_SOURCES "${CMAKE_CURRENT_LIST_DIR}/llvm-libunwind" "${LLVM_LIBUNWIND_ASM_SOURCES_BASE}")