Search code examples
clangllvm-clang

Apple Clang on Debian8.1


Recently I'm porting Apple Clang-700.1.81 to debian 8.1. I have successfuly build clang with

cmake ../llvm -DLLVM_TARGET_TO_BUILD="X86" -DCMAKE_INSTALL_PREFIX="/usr" -DDLLVM_DEFAULT_TARGET_TRIPLE="x86_64-apple-darwin15.3.0"
Make clang -j8 -s 2>Logs

CC Complier:gcc-4.9 CXX complier:g++-4.9

Coming out with default target x86_64-apple-darwin3.16.0-amd64

Is there any thing I'm missing?


Solution

  • Okay I finally found the solution for this one.

    Make sure install all these plugin.

    gcc-4.9 g++-4.9-multilib gcc-4.9-multilib gobjc automake autoconf bison flex libtool python-dev libxml2-dev
    

    Building clang-700.0.81 on Unix system

    There might be some bug fix, these are what I have done.

    1. Delete source file CFString.cpp or move out from the directory.

    2. disable SourceManager just comment those code that cause compiler error.

    3. "brace-initialization" add additional curly brackets to fix it.

    Building clang-703.0.31 on Unix system

    clang-703.0.31 do not need any configuration as clang-700.0.81 does.

    Patch clang-703.0.31 with this code to enable preprocessor to dump the right version of clang.

    src/tools/clang/lib/Basic/Version.cpp    
    @@ -112,6 +112,9 @@
               OS << LLVMRepo << ' ';
             OS << LLVMRev << ')';
           }
        +  OS << " (";
        +  OS << 'clang-703.0.31';
        +  OS << ')';
           return OS.str();
         }
    

    Finally build clang-700.0.81 or clang-703.0.31 with these arguments

    cmake -G "Unix Makefiles" ../src -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DLLVM_INCLUDE_TESTS=False -DCOMPILER_RT_INCLUDE_TESTS=False -DLLVM_USE_SANITIZER=Address
    

    Fix me if I am wrong