From: Jan Vorlicek Date: Tue, 9 May 2017 09:03:32 +0000 (+0200) Subject: Enable build on old Linux (dotnet/coreclr#11414) X-Git-Tag: submit/tizen/20210909.063632~11030^2~6975 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c9a5c256ea6bd4afc4dd06c749e4d1a9b139daf2;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Enable build on old Linux (dotnet/coreclr#11414) This change enables building coreclr on old Linux distros that don't have PR_SET_PTRACER and don't have _xstate struct in the standard sigcontext.h header. Commit migrated from https://github.com/dotnet/coreclr/commit/3437a820fdc94caa3d1775bcee802b056f3adce2 --- diff --git a/src/coreclr/src/debug/createdump/threadinfo.cpp b/src/coreclr/src/debug/createdump/threadinfo.cpp index 8e73fcf..e2c10fc 100644 --- a/src/coreclr/src/debug/createdump/threadinfo.cpp +++ b/src/coreclr/src/debug/createdump/threadinfo.cpp @@ -38,7 +38,7 @@ ThreadInfo::Initialize(ICLRDataTarget* dataTarget) return false; } } - TRACE("Thread %04x RIP %016llx RSP %016llx\n", m_tid, m_gpRegisters.rip, m_gpRegisters.rsp); + TRACE("Thread %04x RIP %016llx RSP %016llx\n", m_tid, (unsigned long long)m_gpRegisters.rip, (unsigned long long)m_gpRegisters.rsp); return true; } diff --git a/src/coreclr/src/pal/src/CMakeLists.txt b/src/coreclr/src/pal/src/CMakeLists.txt index 145c2c9..b8a9fe9 100644 --- a/src/coreclr/src/pal/src/CMakeLists.txt +++ b/src/coreclr/src/pal/src/CMakeLists.txt @@ -93,10 +93,10 @@ elseif(PAL_CMAKE_PLATFORM_ARCH_I386) set(PAL_ARCH_SOURCES_DIR i386) endif() -if(CMAKE_SYSTEM_NAME STREQUAL Linux AND NOT CLR_CMAKE_PLATFORM_ALPINE_LINUX) +if(PAL_CMAKE_PLATFORM_ARCH_AMD64 AND CMAKE_SYSTEM_NAME STREQUAL Linux AND NOT CLR_CMAKE_PLATFORM_ALPINE_LINUX) # Currently the _xstate is not available on Alpine Linux add_definitions(-DXSTATE_SUPPORTED) -endif(CMAKE_SYSTEM_NAME STREQUAL Linux AND NOT CLR_CMAKE_PLATFORM_ALPINE_LINUX) +endif(PAL_CMAKE_PLATFORM_ARCH_AMD64 AND CMAKE_SYSTEM_NAME STREQUAL Linux AND NOT CLR_CMAKE_PLATFORM_ALPINE_LINUX) if(CLR_CMAKE_PLATFORM_ALPINE_LINUX) # Setting RLIMIT_NOFILE breaks debugging of coreclr on Alpine Linux for some reason diff --git a/src/coreclr/src/pal/src/config.h.in b/src/coreclr/src/pal/src/config.h.in index 7f37f42..48677df 100644 --- a/src/coreclr/src/pal/src/config.h.in +++ b/src/coreclr/src/pal/src/config.h.in @@ -66,6 +66,8 @@ #cmakedefine HAVE_UNW_GET_ACCESSORS #cmakedefine01 HAVE_XSWDEV #cmakedefine01 HAVE_XSW_USAGE +#cmakedefine01 HAVE_PUBLIC_XSTATE_STRUCT +#cmakedefine01 HAVE_PR_SET_PTRACER #cmakedefine01 HAVE_STAT_TIMESPEC #cmakedefine01 HAVE_STAT_NSEC diff --git a/src/coreclr/src/pal/src/configure.cmake b/src/coreclr/src/pal/src/configure.cmake index b5b98d5..d5c6577 100644 --- a/src/coreclr/src/pal/src/configure.cmake +++ b/src/coreclr/src/pal/src/configure.cmake @@ -1022,6 +1022,25 @@ int main(int argc, char **argv) return 0; }" HAVE_XSW_USAGE) +check_cxx_source_compiles(" +#include + +int main(int argc, char **argv) +{ + struct _xstate xstate; + struct _fpx_sw_bytes bytes; + return 0; +}" HAVE_PUBLIC_XSTATE_STRUCT) + +check_cxx_source_compiles(" +#include + +int main(int argc, char **argv) +{ + int flag = (int)PR_SET_PTRACER; + return 0; +}" HAVE_PR_SET_PTRACER) + set(CMAKE_REQUIRED_LIBRARIES pthread) check_cxx_source_compiles(" #include diff --git a/src/coreclr/src/pal/src/include/pal/context.h b/src/coreclr/src/pal/src/include/pal/context.h index db6d695..2c86a03 100644 --- a/src/coreclr/src/pal/src/include/pal/context.h +++ b/src/coreclr/src/pal/src/include/pal/context.h @@ -39,6 +39,16 @@ typedef ucontext_t native_context_t; #else // HAVE_UCONTEXT_T #error Native context type is not known on this platform! #endif // HAVE_UCONTEXT_T + +#if defined(XSTATE_SUPPORTED) && !HAVE_PUBLIC_XSTATE_STRUCT +namespace asm_sigcontext +{ +#include +}; +using asm_sigcontext::_fpx_sw_bytes; +using asm_sigcontext::_xstate; +#endif // defined(XSTATE_SUPPORTED) && !HAVE_PUBLIC_XSTATE_STRUCT + #else // !HAVE_MACH_EXCEPTIONS #include #include diff --git a/src/coreclr/src/pal/src/thread/process.cpp b/src/coreclr/src/pal/src/thread/process.cpp index 2a93d3c..6db9bf6 100644 --- a/src/coreclr/src/pal/src/thread/process.cpp +++ b/src/coreclr/src/pal/src/thread/process.cpp @@ -2981,7 +2981,7 @@ PROCAbort() // Do any shutdown cleanup before aborting or creating a core dump PROCNotifyProcessShutdown(); -#if HAVE_PRCTL_H +#if HAVE_PRCTL_H && HAVE_PR_SET_PTRACER // If enabled, launch the create minidump utility and wait until it completes if (g_argvCreateDump[0] != nullptr) { @@ -3018,7 +3018,7 @@ PROCAbort() } } } -#endif // HAVE_PRCTL_H +#endif // HAVE_PRCTL_H && HAVE_PR_SET_PTRACER // Abort the process after waiting for the core dump to complete abort(); }