Microsoft MVP성태의 닷넷 이야기
.NET Framework: 506. .NETCore = CoreFX + CoreCLR [링크 복사], [링크+제목 복사],
조회: 20006
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 4개 있습니다.)

.NETCore = CoreFX + CoreCLR

".NET Core"가 공개되었습니다.

CoreCLR Now Open Source 
; http://www.i-programmer.info/news/89-net/8247-coreclr-now-open-source.html

쉽게 말해서 .NET Core는 우리가 알고 있는 ".NET Framework"의 소형 버전이라고 보시면 됩니다.

닷넷으로 만든 프로그램이 동작하려면 크게 2가지 구성요소가 있어야 하는데요. 바로 "JIT" 컴파일 등을 담당하는 런타임 환경이 그 하나이고, 또 다른 구성 요소는 우리가 프로그램을 만들 때 사용하는 여러 타입들이 정의된 "BCL(Base Class Library)"이 그것입니다.

따라서, .NET Core, CoreFX, CoreCLR을 기존의 ".NET Framework"과 비교하면 이렇게 됩니다.

.NET Core      = CoreFX + CoreCLR
.NET Framework = BCL    + CLR

그리고, CoreFX, CoreCLR의 소스 코드가 모두 github에 올라가 진행 중입니다.

dotnet/coreclr 
; https://github.com/dotnet/coreclr

dotnet/corefx 
; https://github.com/dotnet/corefx

게다가 https://github.com/dotnet/coreclr 글의 내용이 흥미진진합니다.

CoreCLR is a subset of the .NET Framework CLR. They share the same codebase and are updated together. For example, an update to the .NET GC improves both CoreCLR and the .NET Framework CLR.


CoreCLR이 .NET Framework CLR과 동일한 코드 기반이기 때문에, 이제는 .NET Framework CLR 측에서 문제가 발생했을 때 추측만이 아니라 검증도 해볼 수 있게 된 것입니다.

마이크로소프트 측은 기존 Mono에서 동작 중인 ASP.NET 5도 CoreCLR이 Linux/Mac용으로 포팅되는 시점에는 CoreCLR로 이전하겠다는 발표도 하고 있습니다.

CoreCLR is now Open Source
; https://devblogs.microsoft.com/dotnet/coreclr-is-now-open-source/

We’ve been talking about ASP.NET 5 for nearly a year now. You can build ASP.NET 5 apps with the .NET Framework or with .NET Core. Today, ASP.NET 5 uses the Mono runtime to run on Linux and Mac. Once .NET Core supports Linux and Mac, then ASP.NET 5 will move to using .NET Core for those platforms.


이렇게 되면 Mono의 향방이 궁금해집니다. 개인적인 의견으로는, Mono가 없어진다기 보다는 CoreCLR의 일정 부분을 흡수하지 않겠는가... 하는 생각을 해봅니다. 혹시 Mono가 CoreCLR 코드 베이스를 완전하게 흡수하는 것은 어떨까요? 글쎄요!!! 그렇다면 하위 호환성을 아예 포기해야 할 것입니다. 가령, Mono Profiler의 규격은 자체 확장한 것이기 때문에 CoreCLR의 Profiler 규격과는 맞지 않습니다. 그런 부분의 호환을 포기한다면 Mono가 CoreCLR을 흡수해 대대적인 성능 향상을 기대해 볼 수도 있을 것입니다. (사실... 저 쪽 동네는 하위 호환을 그다지 중요하지 않게 생각하는 분위기가 있으므로.)




그럼, 어디 ^^ 윈도우 용으로 빌드를 해볼까요?

Developer Guide - Building the repository
; https://github.com/dotnet/coreclr/wiki/Developer-Guide

우선, coreclr-master.zip를 다운로드 받아 압축을 해제합니다. 제 경우에는 e:\coreclr로 했습니다.

그다음 cmake를 다운로드 받습니다.

cmake-3.1.3-win32-x86.zip
; http://www.cmake.org/files/v3.1/cmake-3.1.3-win32-x86.zip

제 경우에는 e:\cmake에 압축을 해제했습니다.

이제 cmd.exe 창을 열고 다음과 같이 SET 명령을 수행해 cmake 폴더를 포함시켜둡니다. (또는 전역 환경 변수에 포함해둡니다.)

SET PATH=%PATH%;e:\cmake\bin

그리고, Visual Studio도 설치되어 있어야 합니다. 없다면 무료 버전인 Visual Studio Community를 다운로드 받아 설치합니다.

Visual Studio Community
; https://app.vssps.visualstudio.com/profile/review?download=true&family=VisualStudio&edition=Community&release=VisualStudio2013Upd4

설치 후, "DIA SDK"가 있는지 아래의 경로에서 확인합니다.

"C:\Program Files (x86)\Microsoft Visual Studio 12.0\DIA SDK"

없으면, 이 글의 마지막에 있는 DIA SDK 관련 설명을 참조하세요.

이걸로 사전 설치 준비 작업은 끝!

(** 2016-08-23 업데이트: 빌드를 위해 Python이 추가되었습니다. 자세한 사항은 Build CoreCLR on Windows 글을 참고하세요.)




자, 이제 명령행에서 루트에 있는 build.cmd 파일을 실행해 빌드해 줍니다.

E:\coreclr>build.cmd
Commencing CoreCLR Repo build

Checking pre-requisites...

Commencing build of native components for Windows_NT.x64.debug

-- The C compiler identification is MSVC 18.0.31101.0
-- The CXX compiler identification is MSVC 18.0.31101.0
-- Check for working C compiler using: Visual Studio 12 2013 Win64
-- Check for working C compiler using: Visual Studio 12 2013 Win64 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 12 2013 Win64
-- Check for working CXX compiler using: Visual Studio 12 2013 Win64 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- The ASM_MASM compiler identification is MSVC
-- Found assembler: c:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/x86_amd64/ml64.exe
-- Configuring done
-- Generating done
-- Build files have been written to: E:/coreclr/binaries/intermediates/Windows_NT.x64.debug
Build started 2015-03-04 10:22:07.

...[생략]...

빌드 하다가 "error CS0518: Predefined type 'System.Object' is not defined or imported" 오류가 발생할 수 있는데 일단 이것은 무시합니다. 그 오류 메시지가 나타날때까지 빌드가 진행되었으면 이미 필요한 DLL들은 다음의 폴더에 생성된 이후입니다. (예를 들어, coreclr.dll, mscorlib.dll, sos.dll, ...)

E:\coreclr\binaries\Product\Windows_NT.x64.debug

이렇게 build.cmd로 빌드를 한번 해주면 "E:\coreclr\binaries\intermediates\Windows_NT.x64.debug\CoreCLR.sln" 파일이 생성됩니다. 이후부터는, 이것을 Visual Studio에 로드해서 컴파일하고 디버깅할 수 있습니다. 물론, "F5 디버깅"도 가능하겠지요? ^^ 방법은 이전에 설명했던 글과 유사하게 진행하시면 됩니다.

OpenCover 소스 코드 분석을 Visual Studio 2013에서 하는 방법
; https://www.sysnet.pe.kr/2/0/2883




그럼, 이제 (Microsoft .NET Framework 런타임이 아닌) "E:\coreclr\binaries\Product\Windows_NT.x64.debug" 폴더에 있는 CoreCLR 런타임으로 간단한 응용 프로그램 하나 실행해 볼까요? ^^

Visual Studio를 이용해 아래와 같은 콘솔 프로젝트를 하나 만들어 빌드하고,

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Main");
            Console.ReadLine();
        }
    }
}

"E:\coreclr\binaries\Product\Windows_NT.x64.debug" 폴더의 corerun.exe를 이용해 다음과 같이 실행해 볼 수 있습니다.

E:\coreclr\binaries\Product\Windows_NT.x64.debug>corerun .\samples\ConsoleApplication1.exe
Main

Console.ReadLine 코드는 일부러 집어 넣은 것입니다. 그 코드로 인해 실행 중에 대기를 하면, 그 시점에 Process Explorer를 이용해 재미있는 결과를 확인할 수 있습니다. 즉, ConsoleApplication1.exe 파일이 CoreRun.exe의 자식이 아닌 CoreRun.exe 자체 내에서 DLL처럼 로드되어 Main 함수가 실행된 것을 확인할 수 있습니다.

corerun_1.png

그러니까, java.exe가 .class파일을 실행하는 것처럼, coreclr에서는 exe파일은 단지 "Main 메서드를 포함하고 있는 dll"이라는 의미에 불과합니다.

물론, 윈도우 환경에서는 ConsoleApplication1.exe 파일을 직접 실행할 수 있고 그런 경우에는 .NET Framework의 영향을 받게 됩니다. (나중에 CoreCLR이 Max/Linux 환경에 포팅이 되면, 방금 전에 만들어 둔 ConsoleApplication1.exe 파일만 다른 환경의 CoreCLR 폴더에 복사해 동일하게 corerun을 이용해 실행해 볼 수 있습니다.)




예전에 아래와 같은 주제로 이야기한 적이 있었지요?

.NET EXE 파일을 닷넷 프레임워크 버전에 상관없이 실행할 수 있을까요? - 두 번째 이야기
; https://www.sysnet.pe.kr/2/0/1746

이젠, corerun.exe 파일과 함께 몇몇 필요한 파일을 함께 배포해 주면 더 이상 .NET Framework 버전에 의존하지 않는 응용 프로그램을 제작할 수 있습니다.

단지, 크로스-플랫폼적인 것이 고려되었기 때문에 아직 WinForm/WPF/WCF와 같은 라이브러리들은 CoreFX에서 지원되지 않아 사용할 수 없습니다. (지원 여부가 불투명 합니다. 아마... 이런 부분은 지원한다고 해도 시간이 제법 걸릴 것입니다.) 현재로써는 ASP.NET 5나 콘솔 응용 프로그램 정도를 개발할 때 쓸 수 있습니다. 아쉽지만! ^^

참고로 맥 운영체제인 OSX에서도 coreclr을 빌드하는 글이 있습니다.

Building and Running .NET’s CoreCLR on OS X
; http://praeclarum.org/post/110552954728/building-and-running-nets-coreclr-on-os-x

점점 더 영역을 확장할 테니 기대해도 좋을 듯 합니다. ^^




지금부터는 빌드 시 겪을 수 있는 오류 상황에 대한 설명입니다.

만약 DIA SDK가 정상적으로 설치되지 않았다면 다음과 같은 오류가 발생합니다.

E:\coreclr>build.cmd Commencing CoreCLR Repo build

Checking pre-requisites...

Commencing build of native components for Windows_NT.x64.debug

Error: DIA SDK is missing at "C:\Program Files (x86)\Microsoft Visual Studio 12.0\DIA SDK". This is due to a bug in the Visual Studio installer. It does not install DIA SDK at "C:\Program Files (x86)\Microsoft Visual Studio 12.0\" but rather at VS install location of previous version. Workaround is to copy DIA SDK fold
er from VS install location of previous version to "C:\Program Files (x86)\Microsoft Visual Studio 12.0\" and then resume build.
Visual Studio 2013 Express does not include the DIA SDK. You need Visual Studio 2013 Community (free).
See: https://github.com/dotnet/coreclr/wiki/Developer-Guide#prerequisites


오류 메시지에 의하면, Visual Studio 2013을 설치할 때 이전 버전의 Visual Studio가 설치되어 있으면 그쪽 폴더에 설치된다고 합니다. 예를 들어, 제 경우에는 컴퓨터에 Visual Studio 2012가 설치되어 있었는데 그래서 다음의 경로에 DIA SDK가 설치되어 있었습니다.

C:\Program Files (x86)\Microsoft Visual Studio 11.0\DIA SDK

따라서 다음의 명령을 관리자 권한으로 실행한 cmd.exe 창에서 실행해 주면 됩니다.

robocopy "C:\Program Files (x86)\Microsoft Visual Studio 11.0\DIA SDK" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\DIA SDK" /S

또 다른 상황으로, 만약 cmake가 정상적으로 PATH에 연결되어 있지 않으면 다음과 같은 오류가 발생합니다.

E:\coreclr>build.cmd Commencing CoreCLR Repo build

Checking pre-requisites...

CMake is a pre-requisite to build this repository but it was not found on the path. Please install CMake from http://www.cmake.org/download/ and ensure it is on your path.


당연히 cmake를 다운로드/압축 풀고 PATH 환경 변수에 경로를 설정해 주면 문제가 해결됩니다.

마지막으로, 본문에서 다뤘던 "CSC : error CS0518: Predefined type 'System.Object' is not defined or imported" 오류가 빌드를 완료하지 못하고 나타나는 문제입니다.

Commencing build of tests for Windows_NT.x64.debug

Doing a clean test build

Starting the Test Build

  Restoring build tools...
  Restoring all package dependencies...
E:\coreclr\tests\src\packages\Microsoft.DotNet.BuildTools.1.0.21-prerelease\lib\packageresolve.targets(25,5): warning : Unable to resolve the assets of System.Diagnostics.Process: Couldn't find a matching group [E:\coreclr\tests\src\Common\Coreclr.TestWrapper\Coreclr.TestWrapper.csproj]
E:\coreclr\tests\src\packages\Microsoft.DotNet.BuildTools.1.0.21-prerelease\lib
...[생략]....

E:\coreclr\tests\src\packages\Microsoft.DotNet.BuildTools.1.0.21-prerelease\lib\packageresolve.targets(25,5): warning : Unable to resolve the assets of System.Reflection.Primitives: Couldn't find a matching group [E:\coreclr\tests\src\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj]
CSC : error CS0518: Predefined type 'System.Object' is not defined or imported
[E:\coreclr\tests\src\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj]

...[생략]....

최초 발생하는 오류는 System.Object를 찾을 수 없다는 것입니다.

CSC : error CS0518: Predefined type 'System.Object' is not defined or imported [E:\coreclr\tests\src\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj]

왜냐하면 해당 csproj 프로젝트 빌드가 nostdlib 옵션으로 컴파일되기 때문인데 구체적인 해결 방법은 다음에 더 알아보도록 하겠습니다. 지금은 일단, 이 빌드 오류가 발생해도 CoreCLR 빌드는 정상적으로 되었으므로 무시해도 좋습니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 4/23/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 



2015-03-13 04시05분
[ryujh] 안녕하세요.

본문 중에

.NET Core = CoreFX + CoreCLR
.NET Framework = BCL + CLR

이런 관계인데 .NET Framework Client Profile 과 위의 것의 관계는 어떤지 문의합니다.

본문 아래의 실행법은 java의 영향을 받은 것인가요?


저는 아직도 vs2008을 사용하고 있는데(가끔 vs2012 사용) 이제 버전업을 해야할 것 같습니다.

감사합니다.
[guest]
2015-03-13 04시28분
.NET Framework Client Profile은 위의 관계에 낄 수는 없습니다. ^^ .NET 런타임이 40MB 넘게 무거워지니까, 서버 쪽 구성요소같은 클라이언트 응용 프로그램 제작에 잘 쓰이지 않는 구성 요소를 제거해서 만든 .NET 런타임이 "Client Profile"입니다. (ClickOnce 응용 프로그램 배포를 빠르게 하기 위해 만들어진 듯 하지만... 실상은 얼마 차이기 나지 않기 때문에 혹시 모를 타입 사용을 위해 Full Framework 버전을 보통 사용하게 됩니다.)

java의 영향을 받았다기 보다는, 운영체제에 의해 직접 해석되는 실행 모듈이 아니기 때문에 저렇게 다른 프로세스에 실려서 실행할 수 밖에 없습니다.
정성태
2016-08-23 02시43분
copy bin\Product\Windows_NT.x64.debug\clrjit.dll ..\coreclr-demo\runtime
copy bin\Product\Windows_NT.x64.debug\CoreRun.exe ..\coreclr-demo\runtime
copy bin\Product\Windows_NT.x64.debug\coreclr.dll ..\coreclr-demo\runtime
copy bin\Product\Windows_NT.x64.debug\mscorlib.dll ..\coreclr-demo\runtime
copy bin\Product\Windows_NT.x64.debug\System.Private.CoreLib.dll ..\coreclr-demo\runtime
정성태
2016-08-23 02시49분
copy bin\Windows_NT.AnyCPU.Debug\System.Console\System.Console.dll ..\coreclr-demo\runtime
copy bin\Windows_NT.AnyCPU.Debug\System.Diagnostics.Debug\System.Diagnostics.Debug.dll ..\coreclr-demo\runtime
copy bin\AnyOS.AnyCPU.Debug\System.IO\System.IO.dll ..\coreclr-demo\runtime
copy bin\AnyOS.AnyCPU.Debug\System.IO.FileSystem.Primitives\System.IO.FileSystem.Primitives.dll ..\coreclr-demo\runtime
copy bin\AnyOS.AnyCPU.Debug\System.Runtime\System.Runtime.dll ..\coreclr-demo\runtime
copy bin\AnyOS.AnyCPU.Debug\System.Runtime.InteropServices\System.Runtime.InteropServices.dll ..\coreclr-demo\runtime
copy bin\AnyOS.AnyCPU.Debug\System.Text.Encoding\System.Text.Encoding.dll ..\coreclr-demo\runtime
copy bin\AnyOS.AnyCPU.Debug\System.Text.Encoding.Extensions\System.Text.Encoding.Extensions.dll ..\coreclr-demo\runtime
copy bin\AnyOS.AnyCPU.Debug\System.Threading\System.Threading.dll ..\coreclr-demo\runtime
copy bin\AnyOS.AnyCPU.Debug\System.Threading.Tasks\System.Threading.Tasks.dll ..\coreclr-demo\runtime
정성태
2017-01-31 01시00분
정성태

... 46  47  48  49  50  51  52  [53]  54  55  56  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
12313정성태9/6/202012041개발 환경 구성: 509. Logstash - 사용자 정의 grok 패턴 추가를 이용한 IIS 로그 처리
12312정성태9/5/202015938개발 환경 구성: 508. Logstash 기본 사용법 [2]
12311정성태9/4/202011150.NET Framework: 937. C# - 간단하게 만들어 보는 리눅스의 nc(netcat), json_pp 프로그램 [1]
12310정성태9/3/202010424오류 유형: 644. Windows could not start the Elasticsearch 7.9.0 (elasticsearch-service-x64) service on Local Computer.
12309정성태9/3/202010167개발 환경 구성: 507. Elasticsearch 6.6부터 기본 추가된 한글 형태소 분석기 노리(nori) 사용법
12308정성태9/2/202011405개발 환경 구성: 506. Windows - 단일 머신에서 단일 바이너리로 여러 개의 ElasticSearch 노드를 실행하는 방법
12307정성태9/2/202012168오류 유형: 643. curl - json_parse_exception / Invalid UTF-8 start byte
12306정성태9/1/202010347오류 유형: 642. SQL Server 시작 오류 - error code 10013
12305정성태9/1/202011222Windows: 172. "Administered port exclusions"이 아닌 포트 범위 항목을 삭제하는 방법
12304정성태8/31/202010192개발 환경 구성: 505. 윈도우 - (네트워크 어댑터의 우선순위로 인한) 열거되는 IP 주소 순서를 조정하는 방법
12303정성태8/30/202010333개발 환경 구성: 504. ETW - 닷넷 프레임워크 기반의 응용 프로그램을 위한 명령행 도구 etrace 소개
12302정성태8/30/202010245.NET Framework: 936. C# - ETW 관련 Win32 API 사용 예제 코드 (5) - Private Logger파일 다운로드1
12301정성태8/30/202010548오류 유형: 641. error MSB4044: The "Fody.WeavingTask" task was not given a value for the required parameter "IntermediateDir".
12300정성태8/29/20209960.NET Framework: 935. C# - ETW 관련 Win32 API 사용 예제 코드 (4) CLR ETW Consumer파일 다운로드1
12299정성태8/27/202010905.NET Framework: 934. C# - ETW 관련 Win32 API 사용 예제 코드 (3) ETW Consumer 구현파일 다운로드1
12298정성태8/27/202010626오류 유형: 640. livekd - Could not resolve symbols for ntoskrnl.exe: MmPfnDatabase
12297정성태8/25/20209830개발 환경 구성: 503. SHA256 테스트 인증서 생성 방법
12296정성태8/24/202010257.NET Framework: 933. C# - ETW 관련 Win32 API 사용 예제 코드 (2) NT Kernel Logger파일 다운로드1
12295정성태8/24/20209691오류 유형: 639. Bitvise - Address is already in use; bind() in ListeningSocket::StartListening() failed: Windows error 10013: An attempt was made to access a socket ,,,
12293정성태8/24/202011017Windows: 171. "Administered port exclusions" 설명
12292정성태8/20/202012332.NET Framework: 932. C# - ETW 관련 Win32 API 사용 예제 코드 (1)파일 다운로드2
12291정성태8/15/202011266오류 유형: 638. error 1297: Device driver does not install on any devices, use primitive driver if this is intended.
12290정성태8/11/202011943.NET Framework: 931. C# - IP 주소에 따른 국가별 위치 확인 [8]파일 다운로드1
12289정성태8/6/20209458개발 환경 구성: 502. Portainer에 윈도우 컨테이너를 등록하는 방법
12288정성태8/5/20209483오류 유형: 637. WCF - The protocol 'net.tcp' does not have an implementation of HostedTransportConfiguration type registered.
12287정성태8/5/20209947오류 유형: 636. C# - libdl.so를 DllImport로 연결 시 docker container 내에서 System.DllNotFoundException 예외 발생
... 46  47  48  49  50  51  52  [53]  54  55  56  57  58  59  60  ...