harvard-acc / LLVM-Tracer

An LLVM pass to profile dynamic LLVM IR instructions and runtime values
Other
135 stars 35 forks source link

Not able to build on macOS Sierra in spite of having the clang 3.4 toolchain. #18

Closed nalinig closed 7 years ago

nalinig commented 7 years ago

I did get the clang 3.4 from http://releases.llvm.org/3.4/clang+llvm-3.4-x86_64-apple-darwin10.9.tar.gz and set LLVM_HOME to this version after extraction. I am getting Undefined symbols while linking. 6 warnings generated. [ 14%] Linking CXX shared library full_trace.dylib Undefined symbols for architecture x86_64: "llvm::BasicBlock::getFirstInsertionPt()", referenced from: Tracer::runOnBasicBlock(llvm::BasicBlock&) in full_trace.cpp.o Tracer::handlePhiNodes(llvm::BasicBlock, InstEnv) in full_trace.cpp.o LabelMapHandler::runOnModule(llvm::Module&) in full_trace.cpp.o ... Please see the full log file - make.log.txt. I did try to get cmake install LLVM and also tried to explicitly set PATH, LD_LIBRARY_PATH, but I end up with the same error. Is there anything else to be done to get this to build on macOS Sierra? Any ideas will be greatly appreciated.

Thanks, Nalini.

xyzsam commented 7 years ago

Unfortunately I don't have a Mac so I can't test this out. Let me follow up with someone who does.

rgly commented 7 years ago
  1. On Linux, it does not require libraries when building a shared library, but it does on Mac. This patch solves the linking problem.

    --- a/full-trace/CMakeLists.txt
    +++ b/full-trace/CMakeLists.txt
    @@ -2,6 +2,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
    
    file(GLOB SRC "*.cpp")
    add_library(full_trace SHARED ${SRC})
    +target_link_libraries(full_trace ${LLVM_LIBS} ncurses)
    install(TARGETS full_trace LIBRARY DESTINATION lib)
    
    # remove name prefix in order not to generate libxxxxxx name
  2. If clang finds no stdlib.h while compiling profile-func.c, Installing xcode command line tool makes C headers under /usr/include

  3. When it comes to opt -load=fulltrace.dylib -fulltrace triad.bc, LLVM opt seems not recognize the fulltrace pass. I am still working on it. Here is the error message.

    $ make VERBOSE=2
    ......
    [ 57%] Generating triad-opt.llvm
    cd /Users/jjlab/Downloads/LLVM-Tracer/build/example/triad && WORKLOAD=triad /Users/jjlab/Downloads/clang+llvm-3.4.2-x86_64-apple-darwin10.9/bin/opt -disable-inlining -S -load=/Users/jjlab/Downloads/LLVM-Tracer/build/full-trace/full_trace.dylib -fulltrace /Users/jjlab/Downloads/LLVM-Tracer/build/example/triad/triad.llvm -o /Users/jjlab/Downloads/LLVM-Tracer/build/example/triad/triad-opt.llvm
    opt: Unknown command line argument '-fulltrace'.  Try: '/Users/jjlab/Downloads/clang+llvm-3.4.2-x86_64-apple-darwin10.9/bin/opt -help'
    opt: Did you mean '-filetype'?
    make[2]: *** [example/triad/triad-opt.llvm] Error 1
    make[1]: *** [example/triad/CMakeFiles/Tracer_triad.dir/all] Error 2
    make: *** [all] Error 2

Not sure what is the difference between Linux and Mac. Any advice will be appreciated.

xyzsam commented 7 years ago

Thanks @rgly for the help. Since there hasn't been any discussion on this in awhile, I'm closing this issue.