# - for windows we use the passed in parameter to CMAKE to determine build arch
#----------------------------------------
set(CLR_CMAKE_HOST_OS ${CMAKE_SYSTEM_NAME})
-if(CLR_CMAKE_HOST_OS STREQUAL Linux)
+if(CLR_CMAKE_HOST_OS STREQUAL Linux OR CLR_CMAKE_HOST_OS STREQUAL Android)
set(CLR_CMAKE_HOST_UNIX 1)
- if(CLR_CROSS_COMPONENTS_BUILD)
+ if(CLR_CROSS_COMPONENTS_BUILD AND NOT CLR_CMAKE_HOST_OS STREQUAL Android)
# CMAKE_HOST_SYSTEM_PROCESSOR returns the value of `uname -p` on host.
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL amd64)
if(CLR_CMAKE_TARGET_ARCH STREQUAL "arm" OR CLR_CMAKE_TARGET_ARCH STREQUAL "armel")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
set(CLR_CMAKE_HOST_UNIX_ARM 1)
set(CLR_CMAKE_HOST_UNIX_ARMV7L 1)
- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm OR CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a)
set(CLR_CMAKE_HOST_UNIX_ARM 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
set(CLR_CMAKE_HOST_UNIX_ARM64 1)
set(LINUX_ID_FILE "${CMAKE_SYSROOT}${LINUX_ID_FILE}")
endif()
- execute_process(
- COMMAND bash -c "source ${LINUX_ID_FILE} && echo \$ID"
- OUTPUT_VARIABLE CLR_CMAKE_LINUX_ID
- OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(EXISTS ${LINUX_ID_FILE})
+ execute_process(
+ COMMAND bash -c "source ${LINUX_ID_FILE} && echo \$ID"
+ OUTPUT_VARIABLE CLR_CMAKE_LINUX_ID
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ endif()
if(DEFINED CLR_CMAKE_LINUX_ID)
if(CLR_CMAKE_LINUX_ID STREQUAL tizen)
elseif(CLR_CMAKE_LINUX_ID STREQUAL alpine)
set(CLR_CMAKE_HOST_ALPINE_LINUX 1)
set(CLR_CMAKE_HOST_OS ${CLR_CMAKE_LINUX_ID})
- elseif(CLR_CMAKE_LINUX_ID STREQUAL android)
- set(CLR_CMAKE_HOST_ANDROID 1)
- set(CLR_CMAKE_HOST_OS ${CLR_CMAKE_LINUX_ID})
endif()
endif(DEFINED CLR_CMAKE_LINUX_ID)
-endif(CLR_CMAKE_HOST_OS STREQUAL Linux)
+
+ if(CLR_CMAKE_HOST_OS STREQUAL Android)
+ set(CLR_CMAKE_HOST_ANDROID 1)
+ set(CLR_CMAKE_HOST_OS ${CLR_CMAKE_HOST_OS})
+ endif()
+endif(CLR_CMAKE_HOST_OS STREQUAL Linux OR CLR_CMAKE_HOST_OS STREQUAL Android)
if(CLR_CMAKE_HOST_OS STREQUAL Darwin)
set(CLR_CMAKE_HOST_UNIX 1)
set(CLR_CMAKE_TARGET_ALPINE_LINUX 1)
endif(CLR_CMAKE_TARGET_OS STREQUAL alpine)
-if(CLR_CMAKE_TARGET_OS STREQUAL android)
+if(CLR_CMAKE_TARGET_OS STREQUAL Android)
set(CLR_CMAKE_TARGET_UNIX 1)
set(CLR_CMAKE_TARGET_LINUX 1)
set(CLR_CMAKE_TARGET_ANDROID 1)
-endif(CLR_CMAKE_TARGET_OS STREQUAL android)
+endif(CLR_CMAKE_TARGET_OS STREQUAL Android)
if(CLR_CMAKE_TARGET_OS STREQUAL Darwin)
set(CLR_CMAKE_TARGET_UNIX 1)
-if(NOT CLR_CMAKE_CONFIGURE_PLATFORM_INCLUDED)
- message(FATAL_ERROR "configuretools.cmake needs to be included after configureplatform.cmake")
-endif()
+include(${CMAKE_CURRENT_LIST_DIR}/configureplatform.cmake)
# Get the version of the compiler that is in the file name for tool location.
set (CLR_CMAKE_COMPILER_FILE_NAME_VERSION "")
if(NOT CLR_CMAKE_TARGET_DARWIN AND NOT CLR_CMAKE_TARGET_IOS)
locate_toolchain_exec(objdump CMAKE_OBJDUMP)
- if(CMAKE_CROSSCOMPILING AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD AND (CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l OR
+ if(CMAKE_SYSTEM_NAME STREQUAL Android)
+ set(TOOSET_PREFIX ${ANDROID_TOOLCHAIN_PREFIX})
+ elseif(CMAKE_CROSSCOMPILING AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD AND (CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l OR
CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm))
set(TOOLSET_PREFIX "${TOOLCHAIN}-")
else()
function(clr_unknown_arch)
if (WIN32)
- message(FATAL_ERROR "Only AMD64, ARM64, ARM and I386 are supported")
+ message(FATAL_ERROR "Only AMD64, ARM64, ARM and I386 are supported. Found: ${CMAKE_SYSTEM_PROCESSOR}")
elseif(CLR_CROSS_COMPONENTS_BUILD)
- message(FATAL_ERROR "Only AMD64, I386 host are supported for linux cross-architecture component")
+ message(FATAL_ERROR "Only AMD64, I386 host are supported for linux cross-architecture component. Found: ${CMAKE_SYSTEM_PROCESSOR}")
else()
- message(FATAL_ERROR "Only AMD64, ARM64 and ARM are supported")
+ message(FATAL_ERROR "Only AMD64, ARM64 and ARM are supported. Found: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
endfunction()
# Set the project name
project(CoreCLR)
-include(${CLR_ENG_NATIVE_DIR}/configureplatform.cmake)
+include(${CLR_ENG_NATIVE_DIR}/configuretools.cmake)
if (CLR_CMAKE_HOST_WIN32)
message(STATUS "VS_PLATFORM_TOOLSET is ${CMAKE_VS_PLATFORM_TOOLSET}")
endif()
endif(CLR_CMAKE_HOST_WIN32)
+if(CLR_CMAKE_TARGET_ANDROID)
+ add_definitions(-DTARGET_ANDROID)
+endif()
+
#----------------------------------------------------
# Configure compiler settings for environment
#----------------------------------------------------
include(configurecompiler.cmake)
-include(${CLR_ENG_NATIVE_DIR}/configuretools.cmake)
#----------------------------------------------------
# Cross target Component build specific configuration
# - do not depend on clr's compile definitions
#-----------------------------------------
if(CLR_CMAKE_HOST_UNIX)
+ if(CLR_CMAKE_TARGET_ANDROID)
+ find_library(LZMA NAMES lzma)
+ if(LZMA STREQUAL LZMA-NOTFOUND)
+ message(FATAL_ERROR "Cannot find liblzma.")
+ endif(LZMA STREQUAL LZMA-NOTFOUND)
+
+ find_library(ANDROID_GLOB NAMES android-glob)
+ if(ANDROID_GLOB STREQUAL ANDROID_GLOB-NOTFOUND)
+ message(FATAL_ERROR "Cannot find android-glob.")
+ endif()
+ endif()
+
add_subdirectory(src/pal)
add_subdirectory(src/hosts)
endif(CLR_CMAKE_HOST_UNIX)
endif(NOT DEFINED FEATURE_PERFTRACING AND FEATURE_EVENT_TRACE)
if(NOT DEFINED FEATURE_DBGIPC)
- if(CLR_CMAKE_TARGET_UNIX AND (NOT CLR_CMAKE_TARGET_ANDROID))
+ if(CLR_CMAKE_TARGET_UNIX)
set(FEATURE_DBGIPC 1)
endif()
endif(NOT DEFINED FEATURE_DBGIPC)
add_subdirectory(debug/dbgutil)
if(CLR_CMAKE_HOST_UNIX)
- if(CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_UNIX_X86)
+ if(CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_UNIX_X86 AND NOT CLR_CMAKE_HOST_ANDROID)
add_subdirectory(debug/createdump)
- endif(CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_UNIX_X86)
+ endif(CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_UNIX_X86 AND NOT CLR_CMAKE_HOST_ANDROID)
# Include the dummy c++ include files
include_directories("pal/inc/rt/cpp")
set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${EXPORTS_FILE})
endif(CLR_CMAKE_TARGET_DARWIN)
+ if(CLR_CMAKE_TARGET_ANDROID AND CLR_CMAKE_HOST_ARCH_ARM)
+ set(EXPORTS_LINKER_OPTION "${EXPORTS_LINKER_OPTION} -Wl,--no-warn-shared-textrel")
+ endif()
+
endif (CLR_CMAKE_HOST_WIN32)
add_definitions(-DFX_VER_INTERNALNAME_STR=CoreCLR.dll)
#undef min
#undef max
+#include <algorithm>
+
#if HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#endif // defined(HOST_UNIX) && (defined(FEATURE_EVENT_TRACE) || defined(FEATURE_EVENTSOURCE_XPLAT))
-#if defined(FEATURE_PERFTRACING)
+#if defined(FEATURE_PERFTRACING) || defined(FEATURE_EVENTSOURCE_XPLAT)
/***************************************/
/* Tracing levels supported by CLR ETW */
NewArrayHolder<WCHAR> _argument;
bool _isValid;
};
-#endif // FEATURE_PERFTRACING
+#endif // defined(FEATURE_PERFTRACING) || defined(FEATURE_EVENTSOURCE_XPLAT)
#if defined(HOST_UNIX) && (defined(FEATURE_EVENT_TRACE) || defined(FEATURE_EVENTSOURCE_XPLAT))
pthread
rt
)
- endif()
-
- if(CLR_CMAKE_TARGET_ANDROID)
- find_library(LZMA NAMES lzma)
-
- if(LZMA STREQUAL LZMA-NOTFOUND)
- message(FATAL_ERROR "Cannot find liblzma.")
- endif(LZMA STREQUAL LZMA-NOTFOUND)
-
+ else(NOT CLR_CMAKE_TARGET_ANDROID)
target_link_libraries(coreclrpal
- gnustl_shared
- android-support
- android-glob
+ ${ANDROID_GLOB}
${LZMA})
- endif()
-
- if(CLR_MAKE_TARGET_ANDROID)
- find_library(ANDROID_SUPPORT NAMES android-support)
- find_library(ANDROID_GLOB NAMES android-glob)
-
- if(ANDROID_SUPPORT STREQUAL ANDROID_SUPPORT-NOTFOUND)
- message(FATAL_ERROR "Cannot find android-support.")
- endif()
-
- if(ANDROID_GLOB STREQUAL ANDROID_GLOB-NOTFOUND)
- message(FATAL_ERROR "Cannot find android-glob.")
- endif()
- endif()
+ endif(NOT CLR_CMAKE_TARGET_ANDROID)
target_link_libraries(coreclrpal
dl
#ifndef MBUSAFECRT_INTERNAL_H
#define MBUSAFECRT_INTERNAL_H
+#define PAL_IMPLEMENTATION
+
#include "pal_mstypes.h"
#ifndef DLLEXPORT
ucontext_t registers;
#if HAVE_PT_REGS
struct pt_regs ptrace_registers;
- if (ptrace((__ptrace_request)PT_GETREGS, processId, (caddr_t) &ptrace_registers, 0) == -1)
+ if (ptrace((__ptrace_request)PTRACE_GETREGS, processId, (caddr_t) &ptrace_registers, 0) == -1)
#elif HAVE_BSD_REGS_T
struct reg ptrace_registers;
if (PAL_PTRACE(PT_GETREGS, processId, &ptrace_registers, 0) == -1)
(CONTEXT_CONTROL | CONTEXT_INTEGER) & CONTEXT_AREA_MASK)
{
#if HAVE_PT_REGS
- if (ptrace((__ptrace_request)PT_GETREGS, dwProcessId, (caddr_t)&ptrace_registers, 0) == -1)
+ if (ptrace((__ptrace_request)PTRACE_GETREGS, dwProcessId, (caddr_t)&ptrace_registers, 0) == -1)
#elif HAVE_BSD_REGS_T
if (PAL_PTRACE(PT_GETREGS, dwProcessId, &ptrace_registers, 0) == -1)
#endif
#undef ASSIGN_REG
#if HAVE_PT_REGS
- if (ptrace((__ptrace_request)PT_SETREGS, dwProcessId, (caddr_t)&ptrace_registers, 0) == -1)
+ if (ptrace((__ptrace_request)PTRACE_SETREGS, dwProcessId, (caddr_t)&ptrace_registers, 0) == -1)
#elif HAVE_BSD_REGS_T
if (PAL_PTRACE(PT_SETREGS, dwProcessId, &ptrace_registers, 0) == -1)
#endif
{
int const Level;
ULONGLONG const Keyword;
-} EVENT_DESCRIPTOR;""")
+} EVENT_DESCRIPTOR;
+""")
if not is_windows:
Clrproviders.write(eventpipe_trace_context_typedef) # define EVENTPIPE_TRACE_CONTEXT
hr = g_pGCHeap->Initialize();
IfFailGo(hr);
+#ifdef FEATURE_EVENT_TRACE
// Finish setting up rest of EventPipe - specifically enable SampleProfiler if it was requested at startup.
// SampleProfiler needs to cooperate with the GC which hasn't fully finished setting up in the first part of the
// EventPipe initialization, so this is done after the GC has been fully initialized.
EventPipe::FinishInitialize();
+#endif
// This isn't done as part of InitializeGarbageCollector() above because thread
// creation requires AppDomains to have been set up.
void GCToCLREventSink::FireGCStart_V2(uint32_t count, uint32_t depth, uint32_t reason, uint32_t type)
{
+#ifdef FEATURE_EVENT_TRACE
LIMITED_METHOD_CONTRACT;
ETW::GCLog::ETW_GC_INFO gcStartInfo;
gcStartInfo.GCStart.Reason = static_cast<ETW::GCLog::ETW_GC_INFO::GC_REASON>(reason);
gcStartInfo.GCStart.Type = static_cast<ETW::GCLog::ETW_GC_INFO::GC_TYPE>(type);
ETW::GCLog::FireGcStart(&gcStartInfo);
+#endif
}
void GCToCLREventSink::FireGCGenerationRange(uint8_t generation, void* rangeStart, uint64_t rangeUsedLength, uint64_t rangeReservedLength)
cmake_policy(SET CMP0042 NEW)
project(Tests)
-include(${CLR_ENG_NATIVE_DIR}/configureplatform.cmake)
+include(${CLR_ENG_NATIVE_DIR}/configuretools.cmake)
set(INC_PLATFORM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/Common/Platform)
if (CLR_CMAKE_TARGET_WIN32)
# Include global configure settings
include(${CMAKE_CURRENT_SOURCE_DIR}/../configurecompiler.cmake)
-include(${CLR_ENG_NATIVE_DIR}/configuretools.cmake)
# Compile options
if (CLR_CMAKE_HOST_WIN32)
project(corehost)
-include(${CLR_ENG_NATIVE_DIR}/configureplatform.cmake)
include(${CLR_ENG_NATIVE_DIR}/configuretools.cmake)
include(../settings.cmake)
include(../functions.cmake)
# Libraries used for exe projects
if (${TargetType} STREQUAL "exe")
- if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD)
+ if((CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD) AND NOT CLR_CMAKE_TARGET_ANDROID)
target_link_libraries (${DOTNET_PROJECT_NAME} "pthread")
endif()
add_compile_options(-fstack-protector)
endif()
+if(CLR_CMAKE_TARGET_ANDROID)
+ add_compile_options(-Wno-user-defined-warnings)
+endif()
+
add_definitions(-D_NO_ASYNCRTIMP)
add_definitions(-D_NO_PPLXIMP)
if(CLR_CMAKE_TARGET_LINUX)
project(CoreFX C)
-include(${CLR_ENG_NATIVE_DIR}/configureplatform.cmake)
+include(${CLR_ENG_NATIVE_DIR}/configuretools.cmake)
if(CLR_CMAKE_TARGET_IOS)
cmake_minimum_required(VERSION 3.14.5)
endif()
endif ()
+if(CLR_CMAKE_TARGET_ANDROID)
+ add_definitions(-DTARGET_ANDROID)
+ include_directories(SYSTEM "${CROSS_ROOTFS}/usr/include")
+endif()
+
string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_CMAKE_BUILD_TYPE)
if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
add_compile_options(-O0)
endfunction()
include(configure.cmake)
-include(${CLR_ENG_NATIVE_DIR}/configuretools.cmake)
add_subdirectory(System.IO.Compression.Native)
#cmakedefine01 HAVE_TCP_H_TCP_KEEPALIVE
#cmakedefine01 HAVE_BUILTIN_MUL_OVERFLOW
#cmakedefine01 HAVE_DISCONNECTX
+#cmakedefine01 HAVE_PTHREAD_SETCANCELSTATE
// Mac OS X has stat64, but it is deprecated since plain stat now
// provides the same 64-bit aware struct when targeting OS X > 10.5
set(CMAKE_REQUIRED_INCLUDES ${UTYPES_H} ${ICU_HOMEBREW_INC_PATH})
+if(CLR_CMAKE_TARGET_ANDROID)
+ string(REPLACE ";" ":" ANDROID_RPATHS "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}:${CMAKE_SYSTEM_LIBRARY_PATH}")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rpath ${ANDROID_RPATHS}")
+endif()
+
CHECK_C_SOURCE_COMPILES("
#include <unicode/udat.h>
int main(void) { enum UDateFormatSymbolType e = UDAT_STANDALONE_SHORTER_WEEKDAYS; }
return error;
#else
+ (void)windowSize; // unused
errno = ENOTSUP;
return -1;
#endif
freeifaddrs(headAddr);
return -1;
}
-
+
assert(result == actualName);
int family = current->ifa_addr->sa_family;
if (family == AF_INET)
ecmd.cmd = ETHTOOL_GSET;
if (ioctl(socketfd, SIOCETHTOOL, &ifr) == 0)
{
+#ifdef TARGET_ANDROID
+ nii->Speed = (int64_t)ecmd.speed;
+#else
nii->Speed = (int64_t)ethtool_cmd_speed(&ecmd);
+#endif
if (nii->Speed > 0)
{
// If we did not get -1
}
// Skip loopback addresses if at least one interface has non-loopback one.
- if ((!includeIPv4Loopback && ifa->ifa_addr->sa_family == AF_INET && (ifa->ifa_flags & IFF_LOOPBACK) != 0) ||
+ if ((!includeIPv4Loopback && ifa->ifa_addr->sa_family == AF_INET && (ifa->ifa_flags & IFF_LOOPBACK) != 0) ||
(!includeIPv6Loopback && ifa->ifa_addr->sa_family == AF_INET6 && (ifa->ifa_flags & IFF_LOOPBACK) != 0))
{
entry->IPAddressCount--;
iovlen = (int)IOV_MAX;
}
header->msg_name = messageHeader->SocketAddress;
- header->msg_namelen = (unsigned int)messageHeader->SocketAddressLen;
+ header->msg_namelen = (socklen_t)messageHeader->SocketAddressLen;
header->msg_iov = (struct iovec*)messageHeader->IOVectors;
header->msg_iovlen = (__typeof__(header->msg_iovlen))iovlen;
header->msg_control = messageHeader->ControlBuffer;
if (socketAddress == NULL || socketAddressLen < 0)
{
return Error_EFAULT;
- }
+ }
int fd = ToFileDescriptor(socket);
int stdinFds[2] = {-1, -1}, stdoutFds[2] = {-1, -1}, stderrFds[2] = {-1, -1}, waitForChildToExecPipe[2] = {-1, -1};
pid_t processId = -1;
uint32_t* getGroupsBuffer = NULL;
- int thread_cancel_state;
sigset_t signal_set;
sigset_t old_signal_set;
+#ifndef HAVE_PTHREAD_SETCANCELSTATE
+ int thread_cancel_state;
+
// None of this code can be canceled without leaking handles, so just don't allow it
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &thread_cancel_state);
+#endif
// Validate arguments
if (NULL == filename || NULL == argv || NULL == envp || NULL == stdinFd || NULL == stdoutFd ||
errno = priorErrno;
}
+#ifndef HAVE_PTHREAD_SETCANCELSTATE
// Restore thread cancel state
pthread_setcancelstate(thread_cancel_state, &thread_cancel_state);
-
+#endif
+
free(getGroupsBuffer);
return success ? 0 : -1;
pal->MaximumLimit = ConvertFromNativeRLimitInfinityToManagedIfNecessary(native->rlim_max);
}
-#if defined __USE_GNU && !defined __cplusplus
+#if defined(__USE_GNU) && !defined(__cplusplus) && !defined(TARGET_ANDROID)
typedef __rlimit_resource_t rlimitResource;
typedef __priority_which_t priorityWhich;
#else
cpu_set_t set;
CPU_ZERO(&set);
- intptr_t bits = *mask;
+ intptr_t bits = *mask;
for (int cpu = 0; cpu < maxCpu; cpu++)
{
if ((bits & (((intptr_t)1u) << cpu)) != 0)
CPU_SET(cpu, &set);
}
}
-
+
return sched_setaffinity(pid, sizeof(cpu_set_t), &set);
}
#endif
include(CheckStructHasMember)
include(CheckSymbolExists)
include(CheckTypeSize)
+include(CheckFunctionExists)
if (CLR_CMAKE_TARGET_LINUX)
set(PAL_UNIX_NAME \"LINUX\")
"
HAVE_BUILTIN_MUL_OVERFLOW)
+check_function_exists(pthread_setcancelstate HAVE_PTHREAD_SETCANCELSTATE)
+
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/Common/pal_config.h.in
${CMAKE_CURRENT_BINARY_DIR}/Common/pal_config.h)