Problems with compiling gollvm project (CMake version 3.18.0)

Hi.
I am experiencing some issues, related to https://go.googlesource.com/gollvm/.

C:\Users\Worker\gollvm\build-debug>cmake -DCMAKE_BUILD_TYPE=Debug -DLLVM_USE_LINKER=gold -G Ninja …/llvm-project/llvm
– The C compiler identification is Clang 11.0.0 with GNU-like command-line
– The CXX compiler identification is Clang 11.0.0 with GNU-like command-line
– The ASM compiler identification is Clang
– Found assembler: C:/Program Files/LLVM/bin/clang.exe
– Detecting C compiler ABI info
– Detecting C compiler ABI info - failed
– Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe
– Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.18/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler

"C:/Program Files/LLVM/bin/clang.exe"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: C:/Users/Worker/gollvm/build-debug/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Users/Worker/AppData/Local/Programs/Python/Python38-32/Scripts/ninja.exe cmTC_6ed0b && [1/2] Building C object CMakeFiles/cmTC_6ed0b.dir/testCCompiler.c.obj
[2/2] Linking C executable cmTC_6ed0b.exe
FAILED: cmTC_6ed0b.exe
cmd.exe /C "cd . && C:\PROGRA~1\LLVM\bin\clang.exe -fuse-ld=lld-link -nostartfiles -nostdlib -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd  CMakeFiles/cmTC_6ed0b.dir/testCCompiler.c.obj -o cmTC_6ed0b.exe -Xlinker /implib:cmTC_6ed0b.lib -Xlinker /pdb:cmTC_6ed0b.pdb -Xlinker /version:0.0   -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames && cd ."
lld-link: error: <root>: undefined symbol: mainCRTStartup
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:57 (project)

– Configuring incomplete, errors occurred!
See also “C:/Users/Worker/gollvm/build-debug/CMakeFiles/CMakeOutput.log”.
See also “C:/Users/Worker/gollvm/build-debug/CMakeFiles/CMakeError.log”.

C:\Users\Worker\gollvm\build-debug>clang -v
clang version 11.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin

cl /Wv
Оптимизирующий компилятор Microsoft ® C/C++ версии 19.24.28117 для x86
I am using VS 2019 Preview.

Ivan

Looks like the compiler that you are using with those flags does not work. CMake is basically compiling a hello world program and the linker is missing mainCRTStartup. Outside of CMake if you ran clang with those options it should fail in the same way.

Yes, that’s right.
You may close this.