Search code examples
llvmllvm-clang

About the compilation problem of Kaleidoscope in llvm tutorial


I am learning llvm.

I am trying to compile the code in Kaleidoscope Tutorial 3.6. https://llvm.org/docs/tutorial/LangImpl03.html

clang++ -g -O3 toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core` -o toy

I got some errors, but I don't know what to do.

clang++.exe: error: unsupported option '--cxxflags'
clang++.exe: error: unsupported option '--ldflags'
clang++.exe: error: unsupported option '--system-libs'
clang++.exe: error: unsupported option '--libs'
clang++.exe: error: no such file or directory: 'llvm-config'
clang++.exe: error: no such file or directory: 'core -o'
clang++.exe: error: no such file or directory: 'toy'

By the way, I compiled it under Windows.


Solution

  • The main reason you get this error is that your shell does not interpret your command correctly.

    See:

    clang++.exe: error: no such file or directory: 'llvm-config'
    

    Thus flags that should be passed to llvm-config are passed to clang.exe.

    See:

    clang++.exe: error: unsupported option '--cxxflags'
    clang++.exe: error: unsupported option '--ldflags'
    clang++.exe: error: unsupported option '--system-libs'
    clang++.exe: error: unsupported option '--libs'
    

    To solve this issue make sure to get llvm-config on you machine and make sure that you use a command line that supports the correct shell semantics. Example of such shells would be git bash or mingw.