Microsoft MVP성태의 닷넷 이야기
.NET Framework: 506. .NETCore = CoreFX + CoreCLR [링크 복사], [링크+제목 복사],
조회: 20269
글쓴 사람
정성태 (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분
정성태

... 61  62  63  64  65  66  67  68  69  70  71  72  [73]  74  75  ...
NoWriterDateCnt.TitleFile(s)
11822정성태2/20/201911635오류 유형: 517. docker에 설치한 MongoDB 서버로 연결이 안 되는 경우
11821정성태2/20/201912090오류 유형: 516. Visual Studio 2019 - This extension uses deprecated APIs and is at risk of not functioning in a future VS update. [1]
11820정성태2/20/201915235오류 유형: 515. 윈도우 10 1809 업데이트 후 "User Profiles Service" 1534 경고 발생
11819정성태2/20/201913906Windows: 158. 컴퓨터와 사용자의 SID(security identifier) 확인 방법
11818정성태2/20/201912831VS.NET IDE: 131. Visual Studio 2019 Preview의 닷넷 프로젝트 빌드가 20초 이상 걸리는 경우 [2]
11817정성태2/17/20199988오류 유형: 514. WinDbg Preview 실행 오류 - Error : DbgX.dll : WindowsDebugger.WindowsDebuggerException: Could not load dbgeng.dll
11816정성태2/17/201912490Windows: 157. 윈도우 스토어 앱(Microsoft Store App)을 명령행에서 직접 실행하는 방법
11815정성태2/14/201911385오류 유형: 513. Visual Studio 2019 - VSIX 설치 시 "The extension cannot be installed to this product due to prerequisites that cannot be resolved." 오류 발생
11814정성태2/12/201910203오류 유형: 512. VM(가상 머신)의 NT 서비스들이 자동 시작되지 않는 문제
11813정성태2/12/201911808.NET Framework: 809. C# - ("Save File Dialog" 등의) 대화 창에 확장 속성을 보이는 방법
11812정성태2/11/20199631오류 유형: 511. Windows Server 2003 VM 부팅 후 로그인 시점에 0xC0000005 BSOD 발생
11811정성태2/11/201913418오류 유형: 510. 서버 운영체제에 NVIDIA GeForce Experience 실행 시 wlanapi.dll 누락 문제
11810정성태2/11/201911485.NET Framework: 808. .NET Profiler - GAC 모듈에서 GAC 비-등록 모듈을 참조하는 경우의 문제
11809정성태2/11/201912995.NET Framework: 807. ClrMD를 이용해 메모리 덤프 파일로부터 특정 인스턴스를 참조하고 있는 소유자 확인
11808정성태2/8/201914051디버깅 기술: 123. windbg - 닷넷 응용 프로그램의 메모리 누수 분석
11807정성태1/29/201912360Windows: 156. 가상 디스크의 용량을 복구 파티션으로 인해 늘리지 못하는 경우 [4]
11806정성태1/29/201912111디버깅 기술: 122. windbg - 덤프 파일로부터 PID와 환경 변수 등의 정보를 구하는 방법
11805정성태1/28/201913959.NET Framework: 806. C# - int []와 object []의 차이로 이해하는 제네릭의 필요성 [4]파일 다운로드1
11804정성태1/24/201912005Windows: 155. diskpart - remove letter 이후 재부팅 시 다시 드라이브 문자가 할당되는 경우
11803정성태1/10/201911488디버깅 기술: 121. windbg - 닷넷 Finalizer 스레드가 멈춰있는 현상
11802정성태1/7/201912873.NET Framework: 805. 두 개의 윈도우를 각각 실행하는 방법(Windows Forms, WPF)파일 다운로드1
11801정성태1/1/201913912개발 환경 구성: 427. Netsh의 네트워크 모니터링 기능 [3]
11800정성태12/28/201813195오류 유형: 509. WCF 호출 오류 메시지 - System.ServiceModel.CommunicationException: Internal Server Error
11799정성태12/19/201813993.NET Framework: 804. WPF(또는 WinForm)에서 UWP UI 구성 요소 사용하는 방법 [3]파일 다운로드1
11798정성태12/19/201813227개발 환경 구성: 426. vcpkg - "Building vcpkg.exe failed. Please ensure you have installed Visual Studio with the Desktop C++ workload and the Windows SDK for Desktop C++"
11797정성태12/19/201810582개발 환경 구성: 425. vcpkg - CMake Error: Problem with archive_write_header(): Can't create '' 빌드 오류
... 61  62  63  64  65  66  67  68  69  70  71  72  [73]  74  75  ...