2016-09-29 8 views
2

이 예제를 사용하여 Flex, Bison 및 LLVM (모두 최신 버전)으로 컴파일러 작성을 탐색합니다. http://gnuu.org/2009/09/18/writing-your-own-toy-compiler/ Github 소스는 해당 링크의 마지막 페이지에 있습니다. 나는 그것을 컴파일 할 수 없으며 어떤 도움을 주시면 감사하겠습니다.네임 스페이스 std 및 LLVM PassManagerInternal.h 파일

불행히도 나를 위해, 해결책은 분명하지 않습니다.

In file included from codegen.cpp:2: 
In file included from ./codegen.h:8: 
In file included from /usr/local/Cellar/llvm/3.8.1/include/llvm/IR/PassManager.h:46: 
/usr/local/Cellar/llvm/3.8.1/include/llvm/IR/PassManagerInternal.h:298:12: error: use of undeclared identifier 'make_unique' 
    return make_unique<ResultModelT>(Pass.run(IR, AM)); 
     ^
/usr/local/Cellar/llvm/3.8.1/include/llvm/IR/PassManagerInternal.h:298:24: error: unexpected type name 'ResultModelT': expected expression 
    return make_unique<ResultModelT>(Pass.run(IR, AM)); 
        ^
/usr/local/Cellar/llvm/3.8.1/include/llvm/IR/PassManagerInternal.h:336:12: error: use of undeclared identifier 'make_unique' 
    return make_unique<ResultModelT>(Pass.run(IR)); 
     ^
/usr/local/Cellar/llvm/3.8.1/include/llvm/IR/PassManagerInternal.h:336:24: error: unexpected type name 'ResultModelT': expected expression 
    return make_unique<ResultModelT>(Pass.run(IR)); 
        ^
codegen.cpp:36:24: error: no matching conversion for functional-style cast from 'unique_ptr<llvm::Module>' to 'llvm::EngineBuilder' 
     ExecutionEngine *ee = EngineBuilder(unique_ptr<Module>(module)).create(); 
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
/anaconda/include/llvm/ExecutionEngine/ExecutionEngine.h:493:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion 
     from 'unique_ptr<llvm::Module>' to 'llvm::EngineBuilder' for 1st argument 
class EngineBuilder { 
    ^
/anaconda/include/llvm/ExecutionEngine/ExecutionEngine.h:493:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion 
     from 'unique_ptr<llvm::Module>' to 'const llvm::EngineBuilder' for 1st argument 
/anaconda/include/llvm/ExecutionEngine/ExecutionEngine.h:525:3: note: candidate constructor not viable: no known conversion from 'unique_ptr<llvm::Module>' 
     to 'llvm::Module *' for 1st argument 
    EngineBuilder(Module *m) : M(m) { 
^
codegen.cpp:131:49: warning: expression with side effects will be evaluated despite being used as an operand to 'typeid' 
     [-Wpotentially-evaluated-expression] 
       std::cout << "Generating code for " << typeid(**it).name() << endl; 
                  ^
In file included from codegen.cpp:2: 
In file included from ./codegen.h:8: 
/usr/local/Cellar/llvm/3.8.1/include/llvm/IR/PassManager.h:207:22: error: no member named 'getName' in 'llvm::Module' 
       << IR.getName() << "\n"; 
        ~~^
codegen.cpp:30:5: note: in instantiation of member function 'llvm::PassManager<llvm::Module>::run' requested here 
     pm.run(*module); 
     ^
In file included from codegen.cpp:2: 
In file included from ./codegen.h:8: 
/usr/local/Cellar/llvm/3.8.1/include/llvm/IR/PassManager.h:517:20: error: no member named 'getName' in 'llvm::Module' 
      << IR.getName() << "\n"; 
       ~~^
/usr/local/Cellar/llvm/3.8.1/include/llvm/IR/PassManager.h:372:28: note: in instantiation of member function 
     'llvm::AnalysisManager<llvm::Module>::invalidateImpl' requested here 
    return derived_this()->invalidateImpl(IR, std::move(PA)); 
         ^
/usr/local/Cellar/llvm/3.8.1/include/llvm/IR/PassManager.h:217:22: note: in instantiation of member function 
     'llvm::detail::AnalysisManagerBase<llvm::AnalysisManager<llvm::Module>, llvm::Module>::invalidate' requested here 
     PassPA = AM->invalidate(IR, std::move(PassPA)); 
        ^
codegen.cpp:30:5: note: in instantiation of member function 'llvm::PassManager<llvm::Module>::run' requested here 
     pm.run(*module); 
     ^
+0

방금 ​​소스 헤더 파일을 편집했습니다. 그러나 덜 침입적인 해결 방법을 아는 사람이라면 누구나 듣고 싶습니다. –

+0

문제가있는 헤더 목록을 신고 해 주시겠습니까? 그것들은'llvm :: make_unique'를 참조 할 가능성이 있지만 오른쪽 헤더 자체는 포함하지 않습니다. 트리를 포함하는 구현 파일에서 아마도 사용되기 때문에 트리에 걸리지 않습니다. – Joky

+0

@Joky PassManagerInternal.h (제목 있음). 다음은 제가 수행중인 예제입니다. 그것은 github 링크 끝에 있습니다. http://gnuu.org/2009/09/18/writing-your-own-toy-compiler/ –

답변

1

음, include/llvm/ADT/STLExtras.h에서 llvm::make_unique가 :

다음은 오류입니다. 당신은 llvm 소스를 기반으로 자신의 코드를 작성하고 있거나 llvm을 컴파일하고 있다면 무엇을 말했는지 모르겠지만, 그 이유 때문에 정확히 llvm::make_unique이 C++ 11의 누락 부분을 채울 것으로 가정합니다.

또한 tutorials을 보면 llvm::make_unique이 어디에서나 명시 적으로 사용 된 것으로 보입니다.

업데이트 그래서 성공적으로 SVN에서 LLVM 3.9.0에 주어진 예를 구축 할 수 있습니다. 그것이 변경되었으므로 모든 호출을 getGlobalContext()으로 수정해야만합니다. LLVM 3.9.0에서 사라 졌으므로, make_unique 관련 문제가 발생하지 않았습니다. 그러나 예제 자체가 조금 손상되었습니다. 에 포함 보호가 누락 된 경우 에 누락 된 문자는 메서드를 사용하려는 경우에도 #include "llvm/IR/LLVMContext.h"에 대한 포함입니다. MSVC 2015가 설치된 Windows에서이 작업을 수행 했으므로 환경 및 컴파일러를 지정하여 동일한 작업을 수행 할 수 있습니까?

+0

위의 의견에 게시 한 링크를 참조하십시오. 그것은 당신에게 맑은 그림을 줄 것입니다. –

+0

@Dylan_Larkin 좋아, 집에서 노트북에 컴파일 된 버전의 llvm이 있는데이 예제를 컴파일 할 수 있는지 살펴 보겠습니다. –

+0

굉장합니다. Flex, Bison 및 LLVM과 C++ 또는 Objective-C를 사용하여 Xcode 내에서 기본 Mac 터미널뿐만 아니라 몇 가지 다른 프로그램을 컴파일했습니다. 이 특정 사례는 나를 위해 일하지 않습니다. 나는 또한 저자를 썼다. 그는 기본적으로 그가 작성한 (오래된) 버전으로 시도해 보겠다고 말했다. 그것은 나의 마지막 선택 일 것이다. –