After CoreCLR landed on GitHub, the first way to experience CoreCLR was to compile it on his own computer, and yesterday successfully compiled the CORECLR on Windows and Linux, as described in:
1) successfully compiled CORECLR source code on Windows;
2) successfully compiled CORECLR source code on Linux.
After the successful compilation of Windows and Linux, there is an irresistible impulse to compile coreclr on the Mac. Although Microsoft's priority now is Windows and Linux two platforms, CORECLR's compilation temporarily does not support Mac OS X, but I am most looking forward to compiling coreclr on Mac OS X, and compiling coreclr required CMake and LLVM on Mac OS It's all on X, and it's necessary to try.
So, the heartbeat than action, began the Mac OS X compiled CORECLR tour.
The build operation steps are as follows:
1) Check out the CORECLR code base on GitHub: git clone https://github.com/dotnet/coreclr.git
2) Install CMake: Brew Install CMake
3) Run build command: sh build.sh
3) Build result-failed with error message as follows:
Unable to locate llvm-ar
Failed to generate native component build project!
The error message shows that the Llvm-ar command could not be found.
Run the command clang--version , confirming that LLVM 3.5 is installed:
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5SVN)
Run command ls/usr/bin/llvm* , indeed no Llvm-ar:
/usr/bin/llvm-g++/usr/bin/llvm-gcc
Later found that the original hidden in the /usr/local/opt/llvm/bin/folder:
Ls/usr/local/opt/llvm/bin/llvm-ar/usr/local/opt/llvm/bin/llvm-ar
But the environment variable $path does not have this path, so add this path:
Export Path=/usr/local/opt/llvm/bin: $PATH
After adding, continue with build, "Unable to locate Llvm-ar" error disappears.
However, a new error has occurred:
-- The C compiler identification is AppleClang 6.0.0.6000056
-- The CXX compiler identification is AppleClang 6.0.0.6000056
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at CMakeLists.txt:317 (message):
Not Implemented!
To view the code in CMakeLists.txt:
if (IS_64BIT_BUILD EQUAL 1)
if (CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64)
add_definitions(-DDBG_TARGET_AMD64_UNIX)
endif (CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64)
add_definitions(-D_TARGET_AMD64_=1)
add_definitions(-DDBG_TARGET_AMD64)
else (IS_64BIT_BUILD EQUAL 1)
# TODO: Support this
message(FATAL_ERROR "Not Implemented!") #line 317
endif (IS_64BIT_BUILD EQUAL 1)
The No. 317 code is message (fatal_error "notimplemented! ") . By analyzing this block of if code, you know that when the operating system is Mac OS X, the value of Is_64bit_build is not 1, and if you set it to 1, you can avoid this error.
Then, in the 128th line of CMakeLists.txt found the code to set the Is_64bit_build:
elseif (CLR_CMAKE_PLATFORM_UNIX)
# Set flag to indicate if this will be a 64bit Linux build
if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
set(IS_64BIT_BUILD 1)
endif (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
When Clr_cmake_platform_unix is true, the value of Is_64bit_build is set to 1.
Continue the follow-up and find the code to set Clr_cmake_platform_unix in line 7th of CMakeLists.txt:
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
set(CLR_CMAKE_PLATFORM_UNIX 1)
set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1)
endif(CMAKE_SYSTEM_NAME STREQUAL Linux)
Then you add the code for Mac OS x according to the gourd Scoop:
# Mac OS X
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(CLR_CMAKE_PLATFORM_UNIX 1)
set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1)
endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
Then run the./build.sh compile coreclr, and finally the build.sh run up. Although there are some errors, the build execution is not interrupted:
Commencing CoreCLR Repo build
Checking pre-requisites...
Commencing build of native components for amd64/debug
Invoking cmake with arguments: /git/dotnet/coreclr DEBUG
Detected Linux x86_64
-- Configuring done
CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake
--help-policy CMP0042" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
MACOSX_RPATH is not specified for the following targets:
coreclr
mscordaccore
This warning is for project developers. Use -Wno-dev to suppress it.
-- Generating done
-- Build files have been written to: /git/dotnet/coreclr/binaries/CMake
Executing make
./build.sh: line 84: nproc: command not found
[ 0%] Building C object src/pal/tools/cppmunge/CMakeFiles/cppmunge.dir/cppmunge.c.o
[ 1%] [ 1%] Built target palrt
[ 1%] Built target mdhotdata_full
Built target gcinfo
/git/dotnet/coreclr/src/pal/tools/cppmunge/cppmunge.c:38:10: fatal error: ‘linux/limits.h‘ file not found
#include <linux/limits.h>
^
[ 1%] [ 1%] Built target ildbsymlib
Built target dbgutil
[ 2%] Built target corguids
[ 3%] Built target ceefgen
Waiting for the result of the build with anticipation ...
However, during the build process, the MacBook's CPU fan suddenly creaked, then OS X system stopped responding, only forced shutdown.
Try again after booting, and still keep your Mac out of the build process. Then make several attempts, as long as the Build,mac will hang.
Compiling coreclr on Mac OS x is interrupted because of this temporary unresolved problem.
Although this attempt failed, but the infatuation of compiling coreclr on Mac OS X does not change, the expectation of developing. NET programs on Mac OS X is constant!
Try compiling coreclr source code on MAC OS x