레이블이 LLVM인 게시물을 표시합니다. 모든 게시물 표시
레이블이 LLVM인 게시물을 표시합니다. 모든 게시물 표시

2014년 9월 8일 월요일

clang version 3.5.0 Visual Studio Build 현재 상태.



clang version 3.5.0  Visual Studio Build 현재 상태.


Visual Studio 2012 로 빌드한, clang 3.5 는 현재,

윈도우즈에서 간단한 C++ 코드조차, 컴파일 하지 못한다.

간단한 C 코드는 컴파일 가능하다.







D:\>cd D:\DEV_LANG\Work_1

D:\DEV_LANG\Work_1>dir
 D 드라이브의 볼륨: Data
 볼륨 일련 번호: 0AA4-E023

 D:\DEV_LANG\Work_1 디렉터리

2014-09-08  오후 02:11    <DIR>          .
2014-09-08  오후 02:11    <DIR>          ..
2014-09-07  오전 08:42                76 a.c
2014-09-08  오후 02:11            39,387 a.exe
2014-09-07  오전 10:32                62 bb.cpp
2014-09-08  오후 07:23               564 clang-build-1.bat
2014-09-08  오후 02:07               454 clang-build-2.bat
               5개 파일              40,543 바이트
               2개 디렉터리  148,957,941,760 바이트 남음

D:\DEV_LANG\Work_1>
D:\DEV_LANG\Work_1>
D:\DEV_LANG\Work_1>type a.c
#include <stdio.h>
int main() {
  printf("hello world\n");
  return 0;
}
D:\DEV_LANG\Work_1>clang --version
clang version 3.5.0 (tags/RELEASE_350/final)
Target: i686-pc-windows-msvc
Thread model: posix

D:\DEV_LANG\Work_1>clang a.c

D:\DEV_LANG\Work_1>dir
 D 드라이브의 볼륨: Data
 볼륨 일련 번호: 0AA4-E023

 D:\DEV_LANG\Work_1 디렉터리

2014-09-08  오후 09:43    <DIR>          .
2014-09-08  오후 09:43    <DIR>          ..
2014-09-07  오전 08:42                76 a.c
2014-09-08  오후 02:11            39,387 a.exe
2014-09-08  오후 09:43            57,344 a.out
2014-09-07  오전 10:32                62 bb.cpp
2014-09-08  오후 07:23               564 clang-build-1.bat
2014-09-08  오후 02:07               454 clang-build-2.bat
               6개 파일              97,887 바이트
               2개 디렉터리  148,957,884,416 바이트 남음

D:\DEV_LANG\Work_1>a.exe
hello world

D:\DEV_LANG\Work_1>dir
 D 드라이브의 볼륨: Data
 볼륨 일련 번호: 0AA4-E023

 D:\DEV_LANG\Work_1 디렉터리

2014-09-08  오후 09:43    <DIR>          .
2014-09-08  오후 09:43    <DIR>          ..
2014-09-07  오전 08:42                76 a.c
2014-09-08  오후 02:11            39,387 a.exe
2014-09-08  오후 09:43            57,344 a.out
2014-09-07  오전 10:32                62 bb.cpp
2014-09-08  오후 07:23               564 clang-build-1.bat
2014-09-08  오후 02:07               454 clang-build-2.bat
               6개 파일              97,887 바이트
               2개 디렉터리  148,957,884,416 바이트 남음

D:\DEV_LANG\Work_1>type bb.cpp
#include <iostream>

int main() {
    std::cout << "hi";
}
D:\DEV_LANG\Work_1>clang bb.cpp
In file included from bb.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\iostream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\istream:6:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\ostream:796:3: error:
      cannot compile this try statement yet
                _TRY_IO_BEGIN
                ^~~~~~~~~~~~~
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\ostream:19:24: note:
      expanded from macro '_TRY_IO_BEGIN'
 #define _TRY_IO_BEGIN  _TRY_BEGIN      /* begin try block */
                        ^
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xstddef:30:21: note:
      expanded from macro '_TRY_BEGIN'
 #define _TRY_BEGIN     try {
                        ^
In file included from bb.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\iostream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\istream:6:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\ostream:171:3: error:
      cannot compile this try statement yet
                _TRY_BEGIN
                ^~~~~~~~~~
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xstddef:30:21: note:
      expanded from macro '_TRY_BEGIN'
 #define _TRY_BEGIN     try {
                        ^
In file included from bb.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\iostream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\istream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\ostream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\ios:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\xlocnum:10:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\streambuf:6:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xiosbase:306:4: error:
      cannot compile this throw expression yet
                        _RERAISE;
                        ^~~~~~~~
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xstddef:36:19: note:
      expanded from macro '_RERAISE'
 #define _RERAISE       throw
                        ^~~~~
In file included from bb.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\iostream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\istream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\ostream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\ios:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\xlocnum:10:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\streambuf:6:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xiosbase:308:4: error:
      cannot compile this throw expression yet
                        _THROW_NCEE(failure, "ios_base::badbit set");
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xstddef:46:30: note:
      expanded from macro '_THROW_NCEE'
   #define _THROW_NCEE(x, y)    throw x(y)
                                ^~~~~~~~~~
In file included from bb.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\iostream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\istream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\ostream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\ios:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\xlocnum:10:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\streambuf:6:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xiosbase:310:4: error:
      cannot compile this throw expression yet
                        _THROW_NCEE(failure, "ios_base::failbit set");
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xstddef:46:30: note:
      expanded from macro '_THROW_NCEE'
   #define _THROW_NCEE(x, y)    throw x(y)
                                ^~~~~~~~~~
In file included from bb.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\iostream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\istream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\ostream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\ios:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\xlocnum:10:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\streambuf:6:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xiosbase:312:4: error:
      cannot compile this throw expression yet
                        _THROW_NCEE(failure, "ios_base::eofbit set");
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xstddef:46:30: note:
      expanded from macro '_THROW_NCEE'
   #define _THROW_NCEE(x, y)    throw x(y)
                                ^~~~~~~~~~
In file included from bb.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\iostream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\istream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\ostream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\ios:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\xlocnum:10:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\streambuf:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\xiosbase:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\xlocale:8:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INC
LUDE\stdexcept:7:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xstring:2195:3: error:
      cannot compile this try statement yet
                _TRY_BEGIN
                ^~~~~~~~~~
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xstddef:30:21: note:
      expanded from macro '_TRY_BEGIN'
 #define _TRY_BEGIN     try {
                        ^
7 errors generated.

D:\DEV_LANG\Work_1>

2013년 10월 19일 토요일

LLVM Introduction


Introduction to the LLVM Compiler System.

http://llvm.org/pubs/2008-10-04-ACAT-LLVM-Intro.pdf


2008 년 문서로 추정된다.

LLVM 에대한 개념을 설명한 문서다.














LLVM Project 란 무엇인가?

New compiler architecture built with reusable components.

다음과 같은 여러가지 컴파일러 기술로 이루어져있다.
- Optimizer , Code Generator
- llvm-gcc, Clang Front ends
- 그외 기타등등...


http://llvm.org





그런데, 왜?

그런데, 왜 이 시점에 뜬금없이 C 컴파일러를 또 만든단 말인가?

이미 세상에는 GCC, Xcode, Visual Studio ... 등등 수 많은 C 컴파일러가 있는데..

왜. 하필이면. 또 C 컴파일러란 말인가?




그 이유는.


1. 기존 오픈소스 C Compiler 가 침체되었다고 보기 때문이다.

그렇게 보는 이유는 다음과 같다.

- 수십년된 code generation 기술을 기반으로 한다.
- cross-file optimization 과 같은 현대적 기술을 사용하지 않는다.
- code base 가 오래되서, 배우기 어렵고, 대대적인 변경이 어렵다.
- 다른 응용프로그램에서 컴파일러기술을 재사용하기 어렵다.
- 새로운 버전이 릴리스될때마다 속도가 더욱 느려진다.


(음... 일리 있네..)


그래서 현대적기술을 사용하여 컴파일러 요소기술을 만들었고,

이것을 모듈화 시킨것이 LLVM 이다.


이것이 좋다는것을 증명하려면, 이 요소기술위에서 돌아가는 컴파일러가 있어야 한다.

그래서, LLVM 개발자는 LLVM-GCC 4.2 를 만들었다.





LLVM-GCC 4.2 는 다음과 같은 특징을 가진다.

- C, C++, Objective C, Ada and Fortran
- Standard GCC command line option
- ....






즉, LLVM-GCC 4.2 는 C Front-end 는 GCC 4.2 를 쓰고, Optimizer 와 Code Generator 는 LLVM 을 쓰는 물건이다.


( 이걸 왜 이렇게 복잡하게 섞어 놓는거지..? )



이걸 이렇게 섞어서 LLVM 을 쓰면 다음과 같은 좋은 점이 생긴다.


1. 기존에는 없었던, Link Time Optimization 이라는 새로운 기능이 가능해진다.

2. 컴파일 시간이 줄어든다.



3. 실행시간이 빨라진다.





결론은 장점이 분명 존재한다.


기타 다음과 같은 LLVM 의 특징과 장점이 있다.

- 새로운 언어를 만들때 LLVM 을 target 으로 쓸수있다.
- Just-In-Time optimization 과 compillation 을 제공한다.
- Better tools for source level analysis of C/C++ program







LLVM 기술로 만들어진것중에 Clang 이란것이 있다.

Clang 은 이런것이다.
- C, Objective-C, and C++ front-end.
- GCC 와 호환성 유지.
- 컴파일 속도 향상.
- 알아보기 편한, 컴파일러 에러메시지.

( 별거아니네. 뭐야, GCC 랑 똑같은건가..? )





컴파일 속도는 GCC 보다 Clang 이 좀 빠른가 보네.








- C++11 support 에서도 Clang 은 뛰어나다.

    C++11 compiler support shootout: Visual Studio, GCC, Clang, Intel
   ( http://cpprocks.com/c11-compiler-support-shootout-visual-studio-gcc-clang-intel/ )









- 이렇게 좋은 Clang 인데... Visual Studio 에서는, MinGW 에서는...

   ...  Windows 에서는 아직 찬밥이라는 현실.





http://llvm.org/docs/GettingStarted.html )







Windows8 에서 MinGW64 로는 빌드가 되지 않는다.

(  MinGW32 로는 빌드가 된다. )











- LLVM, Clang 은 완료된 프로젝트가 아니다.
  현재, 개발 진행중인 프로젝트다.
  뭔가, 안되거나 없으면 정상이다.

  예를 들어 Clang 링커가 없다면, 정상이다.
  지금 개발 중이다.


The lld project aims to to be the built-in linker for clang/llvm. 
Currently, clang must invoke the system linker to produce executables.

현재로서는, MinGW 에 있는 링커 또는 Visual Studio 에 있는 링커를 써야한다.