Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Closed
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
30 changes: 14 additions & 16 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ prepare_native_build()
build_managed()
{
__buildproj=$__scriptpath/build.proj
__buildlog=$__scriptpath/msbuild.log
__buildlog=$__scriptpath/msbuild.$__BuildArch.log
__binclashlog=$__scriptpath/binclash.log
__binclashloggerdll=$__scriptpath/Tools/Microsoft.DotNet.Build.Tasks.dll

Expand All @@ -123,8 +123,8 @@ build_native()
cd "$__IntermediatesDir"

# Regenerate the CMake solution
echo "Invoking cmake with arguments: \"$__nativeroot\" $__CMakeArgs $__CMakeExtraArgs"
"$__nativeroot/gen-buildsys-clang.sh" "$__nativeroot" $__ClangMajorVersion $__ClangMinorVersion $__BuildArch $__CMakeArgs "$__CMakeExtraArgs"
echo "Invoking cmake with arguments: \"$__scriptpath\" $__BuildType $__CMakeExtraArgs"
"$__scriptpath/src/Native/gen-buildsys-clang.sh" "$__scriptpath" $__ClangMajorVersion $__ClangMinorVersion $__BuildArch $__BuildType "$__CMakeExtraArgs"

# Check that the makefiles were created.

Expand Down Expand Up @@ -159,7 +159,6 @@ build_native()
}

__scriptpath=$(cd "$(dirname "$0")"; pwd -P)
__nativeroot=$__scriptpath/src/Native
__packageroot=$__scriptpath/packages
__sourceroot=$__scriptpath/src
__rootbinpath="$__scriptpath/bin"
Expand Down Expand Up @@ -237,7 +236,6 @@ case $OSName in
esac
__BuildOS=$__HostOS
__BuildType=Debug
__CMakeArgs=DEBUG
__CMakeExtraArgs=""
__MakeExtraArgs=""

Expand All @@ -252,6 +250,7 @@ __ServerGC=0
__VerboseBuild=false
__ClangMajorVersion=3
__ClangMinorVersion=5
__CrossBuild=0

while :; do
if [ $# -le 0 ]; then
Expand Down Expand Up @@ -290,7 +289,6 @@ while :; do
;;
release)
__BuildType=Release
__CMakeArgs=RELEASE
;;
clean)
__CleanBuild=1
Expand Down Expand Up @@ -388,14 +386,22 @@ fi
# Disable the native build when targeting Windows.

if [ "$__BuildOS" != "$__HostOS" ]; then
echo "Warning: cross compiling native components is not yet supported"
echo "Warning: compiling native components for a different OS is not yet supported"
__buildnative=false
fi

if [ ! -e "$__nativeroot" ]; then
if [ ! -e "$__scriptpath/src/Native" ]; then
__buildnative=false
fi

# Configure environment if we are doing a cross compile.
if [ $__CrossBuild == 1 ]; then
export CROSSCOMPILE=1
if ! [[ -n "$ROOTFS_DIR" ]]; then
export ROOTFS_DIR="$__scriptpath/cross/rootfs/$__BuildArch"
fi
fi

# Set the remaining variables based upon the determined build configuration
__IntermediatesDir="$__rootbinpath/obj/$__BuildOS.$__BuildArch.$__BuildType/Native"
__BinDir="$__rootbinpath/$__BuildOS.$__BuildArch.$__BuildType/Native"
Expand All @@ -404,14 +410,6 @@ __BinDir="$__rootbinpath/$__BuildOS.$__BuildArch.$__BuildType/Native"

setup_dirs

# Configure environment if we are doing a cross compile.
if [ "$__CrossBuild" == 1 ]; then
export CROSSCOMPILE=1
if ! [[ -n "$ROOTFS_DIR" ]]; then
export ROOTFS_DIR="$__scriptpath/cross/rootfs/$__BuildArch"
fi
fi

export CORECLR_SERVER_GC="$__ServerGC"

if $__buildnative; then
Expand Down
1 change: 1 addition & 0 deletions cross/arm/tryrun.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SET( HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE
0
CACHE STRING "Result from TRY_RUN" FORCE)

Copy link

Choose a reason for hiding this comment

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

Was this intentional, looks like a mistake.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, to be like CoreCLR and CoreRT that have empty lines between the various SET commands.

Copy link

Choose a reason for hiding this comment

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

Yeah my bad sorry, saw a + and assumed it was a literal + forgetting it's used to mean addition.

SET( HAVE_CLOCK_MONOTONIC_EXITCODE
0
CACHE STRING "Result from TRY_RUN" FORCE)
1 change: 1 addition & 0 deletions cross/arm64/tryrun.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SET( HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE
0
CACHE STRING "Result from TRY_RUN" FORCE)

Copy link

Choose a reason for hiding this comment

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

Same as the above.

SET( HAVE_CLOCK_MONOTONIC_EXITCODE
0
CACHE STRING "Result from TRY_RUN" FORCE)
93 changes: 75 additions & 18 deletions src/Native/gen-buildsys-clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@
if [ $# -lt 4 -o $# -gt 6 ]
then
echo "Usage..."
echo "gen-buildsys-clang.sh <path to top level CMakeLists.txt> <ClangMajorVersion> <ClangMinorVersion> <Architecture> [build flavor] [cmakeargs]"
echo "Specify the path to the top level CMake file - <corefx>/src/Native"
echo "gen-buildsys-clang.sh <path to top level> <ClangMajorVersion> <ClangMinorVersion> <Architecture> [build flavor] [cmakeargs]"
echo "Specify the path to the top level folder - <corefx>"
echo "Specify the clang version to use, split into major and minor version"
echo "Specify the target architecture."
echo "Optionally specify the build configuration (flavor.) Defaults to DEBUG."
echo "Optionally pass additional arguments to CMake call."
exit 1
fi

#Set the root directory of the project
project_root="$1"/../..

# Set up the environment to be used for building with clang.
if which "clang-$2.$3" > /dev/null 2>&1
then
Expand All @@ -37,18 +34,71 @@ else
fi

build_arch="$4"
# Possible build types are DEBUG, RELEASE, RELWITHDEBINFO, MINSIZEREL.
# Default to DEBUG
if [ -z "$5" ]
then
echo "Defaulting to DEBUG build."
buildtype="DEBUG"
if [ -z "$5" ]; then
echo "Defaulting to DEBUG build."
build_type="DEBUG"
else
# Possible build types are DEBUG, RELEASE
build_type="$(echo $5 | awk '{print toupper($0)}')"
if [ "$build_type" != "DEBUG" ] && [ "$build_type" != "RELEASE" ]; then
echo "Invalid Build type, only debug or release is accepted."
exit 1
fi
fi

OS=`uname`

# Locate llvm
# This can be a little complicated, because the common use-case of Ubuntu with
# llvm-3.5 installed uses a rather unusual llvm installation with the version
# number postfixed (i.e. llvm-ar-3.5), so we check for that first.
# On FreeBSD the version number is appended without point and dash (i.e.
# llvm-ar35).
# Additionally, OSX doesn't use the llvm- prefix.
if [ $OS = "Linux" -o $OS = "FreeBSD" -o $OS = "OpenBSD" -o $OS = "NetBSD" ]; then
llvm_prefix="llvm-"
elif [ $OS = "Darwin" ]; then
llvm_prefix=""
else
buildtype="$5"
echo "Unable to determine build platform"
exit 1
fi

cmake_extra_defines="-DCMAKE_BUILD_TYPE=$buildtype"
desired_llvm_major_version=$2
desired_llvm_minor_version=$3
if [ $OS = "FreeBSD" ]; then
desired_llvm_version="$desired_llvm_major_version$desired_llvm_minor_version"
elif [ $OS = "OpenBSD" ]; then
desired_llvm_version=""
elif [ $OS = "NetBSD" ]; then
desired_llvm_version=""
else
desired_llvm_version="-$desired_llvm_major_version.$desired_llvm_minor_version"
fi
locate_llvm_exec() {
if which "$llvm_prefix$1$desired_llvm_version" > /dev/null 2>&1
then
echo "$(which $llvm_prefix$1$desired_llvm_version)"
elif which "$llvm_prefix$1" > /dev/null 2>&1
then
echo "$(which $llvm_prefix$1)"
else
exit 1
fi
}

llvm_ar="$(locate_llvm_exec ar)"
[[ $? -eq 0 ]] || { echo "Unable to locate llvm-ar"; exit 1; }
llvm_link="$(locate_llvm_exec link)"
[[ $? -eq 0 ]] || { echo "Unable to locate llvm-link"; exit 1; }
llvm_nm="$(locate_llvm_exec nm)"
[[ $? -eq 0 ]] || { echo "Unable to locate llvm-nm"; exit 1; }
if [ $OS = "Linux" -o $OS = "FreeBSD" -o $OS = "OpenBSD" -o $OS = "NetBSD" ]; then
llvm_objdump="$(locate_llvm_exec objdump)"
[[ $? -eq 0 ]] || { echo "Unable to locate llvm-objdump"; exit 1; }
fi

cmake_extra_defines=
if [[ -n "$LLDB_LIB_DIR" ]]; then
cmake_extra_defines="$cmake_extra_defines -DWITH_LLDB_LIBS=$LLDB_LIB_DIR"
fi
Expand All @@ -60,8 +110,8 @@ if [[ -n "$CROSSCOMPILE" ]]; then
echo "ROOTFS_DIR not set for crosscompile"
exit 1
fi
cmake_extra_defines="$cmake_extra_defines -C $project_root/cross/$build_arch/tryrun.cmake"
cmake_extra_defines="$cmake_extra_defines -DCMAKE_TOOLCHAIN_FILE=$project_root/cross/$build_arch/toolchain.cmake"
cmake_extra_defines="$cmake_extra_defines -C $1/cross/$build_arch/tryrun.cmake"
cmake_extra_defines="$cmake_extra_defines -DCMAKE_TOOLCHAIN_FILE=$1/cross/$build_arch/toolchain.cmake"
fi
if [ "$build_arch" == "arm-softfp" ]; then
cmake_extra_defines="$cmake_extra_defines -DARM_SOFTFP=1"
Expand All @@ -74,6 +124,13 @@ else
__UnprocessedCMakeArgs="$6"
fi

cmake $cmake_extra_defines \
$__UnprocessedCMakeArgs \
$1
cmake \
"-DCMAKE_AR=$llvm_ar" \
"-DCMAKE_LINKER=$llvm_link" \
"-DCMAKE_NM=$llvm_nm" \
"-DCMAKE_OBJDUMP=$llvm_objdump" \
"-DCMAKE_RANLIB=$llvm_ranlib" \
"-DCMAKE_BUILD_TYPE=$build_type" \
$cmake_extra_defines \
$__UnprocessedCMakeArgs \
"$1/src/Native"