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

Port cross oxs-arm64 build support from runtime #1642

Merged
merged 6 commits into from
Oct 10, 2020
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
16 changes: 9 additions & 7 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,16 @@ if [[ "$__BuildArch" == "armel" ]]; then
fi

# Configure environment if we are doing a cross compile.
if [ "${__BuildArch}" != "${__HostArch}" -a "${__BuildOS}" != "OSX" ]; then
if [ "${__BuildArch}" != "${__HostArch}" ]; then
__CrossBuild=true
export CROSSCOMPILE=1
if ! [[ -n "$ROOTFS_DIR" ]]; then
echo "ERROR: ROOTFS_DIR not set for cross build"
exit 1
if [ "${__BuildOS}" != "OSX" ]; then
if ! [[ -n "$ROOTFS_DIR" ]]; then
echo "ERROR: ROOTFS_DIR not set for cross build"
exit 1
fi
echo "ROOTFS_DIR: $ROOTFS_DIR"
fi
echo "ROOTFS_DIR: $ROOTFS_DIR"
fi

mkdir -p "$__IntermediatesDir"
Expand Down Expand Up @@ -378,8 +380,8 @@ initTargetDistroRid()

local passedRootfsDir=""

# Only pass ROOTFS_DIR if cross is specified.
if [ $__CrossBuild == true ]; then
# Only pass ROOTFS_DIR if cross is specified and the current platform is not OSX that doesn't use rootfs
if [ $__CrossBuild == true -a "$__HostOS" != "OSX" ]; then
passedRootfsDir=${ROOTFS_DIR}
fi

Expand Down
53 changes: 49 additions & 4 deletions eng/cross/tryrun.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,60 @@ macro(set_cache_value)
set(${ARGV0}__TRYRUN_OUTPUT "dummy output" CACHE STRING "Output from TRY_RUN" FORCE)
endmacro()

if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf OR
if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv7-alpine-linux-musleabihf OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl)

SET(ALPINE_LINUX 1)
else()
SET(ALPINE_LINUX 0)
elseif(EXISTS /System/Library/CoreServices)
set(DARWIN 1)
endif()

if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|mips64|x86)$")
if(DARWIN)
if(TARGET_ARCH_NAME MATCHES "^(arm64|x64)$")
set_cache_value(FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL_EXITCODE 1)
set_cache_value(GETPWUID_R_SETS_ERRNO_EXITCODE 1)
set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 1)
set_cache_value(HAVE_BROKEN_FIFO_KEVENT_EXITCODE 1)
set_cache_value(HAVE_BROKEN_FIFO_SELECT_EXITCODE 1)
set_cache_value(HAVE_CLOCK_MONOTONIC_COARSE_EXITCODE 1)
set_cache_value(HAVE_CLOCK_MONOTONIC_EXITCODE 0)
set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0)
set_cache_value(HAVE_CLOCK_GETTIME_NSEC_NP_EXITCODE 0)
set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 0)
set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 0)
set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 0)
set_cache_value(HAVE_COMPATIBLE_EXP_EXITCODE 1)
set_cache_value(HAVE_COMPATIBLE_ILOGB0_EXITCODE 0)
set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 1)
set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 0)
set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 0)
set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 0)
set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 1)
set_cache_value(HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 0)
set_cache_value(HAVE_MMAP_DEV_ZERO_EXITCODE 1)
set_cache_value(HAVE_PROCFS_CTL_EXITCODE 1)
set_cache_value(HAVE_PROCFS_MAPS_EXITCODE 1)
set_cache_value(HAVE_PROCFS_STATUS_EXITCODE 1)
set_cache_value(HAVE_PROCFS_STAT_EXITCODE 1)
set_cache_value(HAVE_SCHED_GETCPU_EXITCODE 1)
set_cache_value(HAVE_SCHED_GET_PRIORITY_EXITCODE 0)
set_cache_value(HAVE_VALID_NEGATIVE_INF_POW_EXITCODE 0)
set_cache_value(HAVE_VALID_POSITIVE_INF_POW_EXITCODE 0)
set_cache_value(HAVE_WORKING_CLOCK_GETTIME_EXITCODE 0)
set_cache_value(HAVE_WORKING_GETTIMEOFDAY_EXITCODE 0)
set_cache_value(MMAP_ANON_IGNORES_PROTECTION_EXITCODE 1)
set_cache_value(ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS_EXITCODE 1)
set_cache_value(PTHREAD_CREATE_MODIFIES_ERRNO_EXITCODE 1)
set_cache_value(REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE 1)
set_cache_value(SEM_INIT_MODIFIES_ERRNO_EXITCODE 1)
set_cache_value(SSCANF_CANNOT_HANDLE_MISSING_EXPONENT_EXITCODE 1)
set_cache_value(SSCANF_SUPPORT_ll_EXITCODE 0)
set_cache_value(UNGETC_NOT_RETURN_EOF_EXITCODE 1)
else()
message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only arm64 or x64 is supported for OSX cross build!")
endif()
elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|mips64|x86)$")
set_cache_value(FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL_EXITCODE 1)
set_cache_value(GETPWUID_R_SETS_ERRNO_EXITCODE 0)
set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 0)
Expand Down
11 changes: 9 additions & 2 deletions eng/gen-buildsys-clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ if [[ -n "$LLDB_INCLUDE_DIR" ]]; then
cmake_extra_defines="$cmake_extra_defines -DWITH_LLDB_INCLUDES=$LLDB_INCLUDE_DIR"
fi
if [ "$CROSSCOMPILE" == "1" ]; then
if ! [[ -n "$ROOTFS_DIR" ]]; then
platform="$(uname)"
# OSX doesn't use rootfs
if ! [[ -n "$ROOTFS_DIR" || "$platform" == "Darwin" ]]; then
echo "ROOTFS_DIR not set for crosscompile"
exit 1
fi
Expand All @@ -130,8 +132,13 @@ if [ "$CROSSCOMPILE" == "1" ]; then
fi
export TARGET_BUILD_ARCH=$build_arch
cmake_extra_defines="$cmake_extra_defines -C $CONFIG_DIR/tryrun.cmake"
cmake_extra_defines="$cmake_extra_defines -DCMAKE_TOOLCHAIN_FILE=$CONFIG_DIR/toolchain.cmake"
cmake_extra_defines="$cmake_extra_defines -DCLR_UNIX_CROSS_BUILD=1"

if [[ "$platform" == "Darwin" ]]; then
cmake_extra_defines="$cmake_extra_defines -DCMAKE_SYSTEM_NAME=Darwin"
else
cmake_extra_defines="$cmake_extra_defines -DCMAKE_TOOLCHAIN_FILE=$CONFIG_DIR/toolchain.cmake"
fi
fi
if [ $OS == "Linux" ]; then
linux_id_file="/etc/os-release"
Expand Down
2 changes: 1 addition & 1 deletion src/pal/src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
#cmakedefine01 HAVE_WORKING_CLOCK_GETTIME
#cmakedefine01 HAVE_CLOCK_MONOTONIC
#cmakedefine01 HAVE_CLOCK_MONOTONIC_COARSE
#cmakedefine01 HAVE_MACH_ABSOLUTE_TIME
#cmakedefine01 HAVE_CLOCK_GETTIME_NSEC_NP
#cmakedefine01 HAVE_CLOCK_THREAD_CPUTIME
#cmakedefine01 HAVE_PTHREAD_CONDATTR_SETCLOCK
#cmakedefine01 STATVFS64_PROTOTYPE_BROKEN
Expand Down
10 changes: 4 additions & 6 deletions src/pal/src/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -406,16 +406,14 @@ int main()
}" HAVE_CLOCK_MONOTONIC_COARSE)
check_cxx_source_runs("
#include <stdlib.h>
#include <mach/mach_time.h>
#include <time.h>

int main()
{
int ret;
mach_timebase_info_data_t timebaseInfo;
ret = mach_timebase_info(&timebaseInfo);
mach_absolute_time();
exit(ret);
}" HAVE_MACH_ABSOLUTE_TIME)
ret = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
exit((ret == 0) ? 1 : 0);
}" HAVE_CLOCK_GETTIME_NSEC_NP)
check_cxx_source_runs("
#include <stdlib.h>
#include <time.h>
Expand Down
12 changes: 0 additions & 12 deletions src/pal/src/include/pal/misc.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

/*++

Expand Down Expand Up @@ -43,17 +42,6 @@ Function :
--*/
PAL_time_t __cdecl PAL_time(PAL_time_t*);

/*++
Function:
TIMEInitialize

Return value:
TRUE if initialize succeeded
FALSE otherwise

--*/
BOOL TIMEInitialize( void );

/*++
Function :
MsgBoxInitialize
Expand Down
6 changes: 0 additions & 6 deletions src/pal/src/init/pal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,6 @@ Initialize(
{
palError = ERROR_GEN_FAILURE;

if (FALSE == TIMEInitialize())
{
ERROR("Unable to initialize TIME support\n");
goto CLEANUP2;
}

/* Initialize the File mapping critical section. */
if (FALSE == MAPInitialize())
{
Expand Down
Loading