-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake script does not take Clang compiler variables properly #5096
Comments
~/zig-master/build$ cmake --version CMake suite maintained and supported by Kitware (kitware.com/cmake).
|
Running with cmake .. -DCMAKE_C_COMPILER=/usr/bin/clang-10 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-10 -DCMAKE_NM=/usr/bin/llvm-nm-10 -DCMAKE_RANLIB=/usr/bin/llvm-ranlib-10 -DCMAKE_LINKER=/usr/bin/llvm-link-10 -DCMAKE_AR=/usr/bin/llvm-ar-10 I reduced linker problems to [ 99%] Linking CXX executable zig0 |
Duplicate of pinned issue #4799 |
When compiling with clang-10, llvm-10 paths all set. Even correcting path for LLD does not help to get successive build.
zig-build.txt
with 'make -d' running
Putting child 0x55b32b5336d0 (zig0) PID 12040 on the chain.
Live child 0x55b32b5336d0 (zig0) PID 12040
[ 98%] Linking CXX executable zig0
Reaping winning child 0x55b32b5336d0 PID 12040
Live child 0x55b32b5336d0 (zig0) PID 12042
zig_cpp/libzig_cpp.a(zig_clang_cc1_main.cpp.o): In function
cc1_main(llvm::ArrayRef<char const*>, char const*, void*)': /home/san/zig-master/src/zig_clang_cc1_main.cpp:187: undefined reference to
clang::CompilerInstance::CompilerInstance(std::shared_ptrclang::PCHContainerOperations, clang::InMemoryModuleCache*)'/home/san/zig-master/src/zig_clang_cc1_main.cpp:188: undefined reference to
clang::DiagnosticIDs::DiagnosticIDs()' /home/san/zig-master/src/zig_clang_cc1_main.cpp:205: undefined reference to
clang::DiagnosticsEngine::DiagnosticsEngine(llvm::IntrusiveRefCntPtrclang::DiagnosticIDs, llvm::IntrusiveRefCntPtrclang::DiagnosticOptions, clang::DiagnosticConsumer*, bool)'/home/san/zig-master/src/zig_clang_cc1_main.cpp:207: undefined reference to
clang::CompilerInvocation::CreateFromArgs(clang::CompilerInvocation&, llvm::ArrayRef<char const*>, clang::DiagnosticsEngine&)' /home/san/zig-master/src/zig_clang_cc1_main.cpp:221: undefined reference to
clang::CompilerInvocation::GetResourcesPath[abi:cxx11](char const*, void*)'/home/san/zig-master/src/zig_clang_cc1_main.cpp:224: undefined reference to
clang::CompilerInstance::createDiagnostics(clang::DiagnosticConsumer*, bool)' /home/san/zig-master/src/zig_clang_cc1_main.cpp:233: undefined reference to
clang::TextDiagnosticBuffer::FlushDiagnostics(clang::DiagnosticsEngine&) const'/home/san/zig-master/src/zig_clang_cc1_main.cpp:240: undefined reference to
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)' /home/san/zig-master/src/zig_clang_cc1_main.cpp:252: undefined reference to
clang::CompilerInstance::createOutputFile(llvm::StringRef, bool, bool, llvm::StringRef, llvm::StringRef, bool, bool)'/home/san/zig-master/src/zig_clang_cc1_main.cpp:277: undefined reference to
clang::DiagnosticsEngine::~DiagnosticsEngine()' zig_cpp/libzig_cpp.a(zig_clang_cc1_main.cpp.o): In function
TextDiagnosticBuffer':/usr/lib/llvm-10/include/clang/Frontend/TextDiagnosticBuffer.h:25: undefined reference to
vtable for clang::TextDiagnosticBuffer' zig_cpp/libzig_cpp.a(zig_clang_cc1_main.cpp.o): In function
void __gnu_cxx::new_allocatorclang::PCHContainerOperations::constructclang::PCHContainerOperations(clang::PCHContainerOperations*)':/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/ext/new_allocator.h:136: undefined reference to
clang::PCHContainerOperations::PCHContainerOperations()' zig_cpp/libzig_cpp.a(zig_clang_cc1_main.cpp.o): In function
ObjectFilePCHContainerWriter':/usr/lib/llvm-10/include/clang/CodeGen/ObjectFilePCHContainerOperations.h:18: undefined reference to
vtable for clang::ObjectFilePCHContainerWriter' zig_cpp/libzig_cpp.a(zig_clang_cc1_main.cpp.o): In function
ObjectFilePCHContainerReader':/usr/lib/llvm-10/include/clang/CodeGen/ObjectFilePCHContainerOperations.h:34: undefined reference to
vtable for clang::ObjectFilePCHContainerReader' zig_cpp/libzig_cpp.a(zig_clang_driver.cpp.o): In function
ZigClang_main':/home/san/zig-master/src/zig_clang_driver.cpp:338: undefined reference to
clang::noteBottomOfStack()' /home/san/zig-master/src/zig_clang_driver.cpp:347: undefined reference to
clang::driver::ToolChain::getTargetAndModeFromProgramName(llvm::StringRef)'/home/san/zig-master/src/zig_clang_driver.cpp:458: undefined reference to
clang::TextDiagnosticPrinter::TextDiagnosticPrinter(llvm::raw_ostream&, clang::DiagnosticOptions*, bool)' /home/san/zig-master/src/zig_clang_driver.cpp:461: undefined reference to
clang::DiagnosticIDs::DiagnosticIDs()'/home/san/zig-master/src/zig_clang_driver.cpp:463: undefined reference to
clang::DiagnosticsEngine::DiagnosticsEngine(llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs>, llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions>, clang::DiagnosticConsumer*, bool)' /home/san/zig-master/src/zig_clang_driver.cpp:467: undefined reference to
clang::serialized_diags::create(llvm::StringRef, clang::DiagnosticOptions*, bool)'/home/san/zig-master/src/zig_clang_driver.cpp:469: undefined reference to
clang::DiagnosticsEngine::setClient(clang::DiagnosticConsumer*, bool)' /home/san/zig-master/src/zig_clang_driver.cpp:473: undefined reference to
clang::ProcessWarningOptions(clang::DiagnosticsEngine&, clang::DiagnosticOptions const&, bool)'/home/san/zig-master/src/zig_clang_driver.cpp:475: undefined reference to
clang::driver::Driver::Driver(llvm::StringRef, llvm::StringRef, clang::DiagnosticsEngine&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>)' /home/san/zig-master/src/zig_clang_driver.cpp:489: undefined reference to
clang::driver::Driver::BuildCompilation(llvm::ArrayRef<char const*>)'/home/san/zig-master/src/zig_clang_driver.cpp:493: undefined reference to
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)' /home/san/zig-master/src/zig_clang_driver.cpp:522: undefined reference to
clang::driver::Driver::generateCompilationDiagnostics(clang::driver::Compilation&, clang::driver::Command const&, llvm::StringRef, clang::driver::Driver::CompilationDiagnosticReport*)'/home/san/zig-master/src/zig_clang_driver.cpp:546: undefined reference to
clang::DiagnosticsEngine::~DiagnosticsEngine()' zig_cpp/libzig_cpp.a(zig_clang_driver.cpp.o): In function
CreateAndPopulateDiagOpts(llvm::ArrayRef<char const*>, bool&)':/home/san/zig-master/src/zig_clang_driver.cpp:275: undefined reference to
clang::driver::getDriverOptTable()' /home/san/zig-master/src/zig_clang_driver.cpp:280: undefined reference to
clang::ParseDiagnosticArgs(clang::DiagnosticOptions&, llvm::opt::ArgList&, clang::DiagnosticsEngine*, bool, bool)'zig_cpp/libzig_cpp.a(zig_clang_driver.cpp.o): In function
ChainedDiagnosticConsumer': /usr/lib/llvm-10/include/clang/Frontend/ChainedDiagnosticConsumer.h:29: undefined reference to
vtable for clang::ChainedDiagnosticConsumer'zig_cpp/libzig_cpp.a(zig_clang_driver.cpp.o): In function
DiagnosticConsumer': /usr/lib/llvm-10/include/clang/Basic/Diagnostic.h:1505: undefined reference to
vtable for clang::DiagnosticConsumer'zig_cpp/libzig_cpp.a(zig_clang_driver.cpp.o): In function
clang::DiagnosticBuilder::Emit()': /usr/lib/llvm-10/include/clang/Basic/Diagnostic.h:1112: undefined reference to
clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool)'zig_cpp/libzig_cpp.a(zig_clang_driver.cpp.o): In function
llvm::RefCountedBase<clang::DiagnosticIDs>::Release() const': /usr/lib/llvm-10/include/llvm/ADT/IntrusiveRefCntPtr.h:82: undefined reference to
clang::DiagnosticIDs::~DiagnosticIDs()'zig_cpp/libzig_cpp.a(zig_clang_driver.cpp.o): In function
std::default_delete<clang::driver::Compilation>::operator()(clang::driver::Compilation*) const': /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/unique_ptr.h:78: undefined reference to
clang::driver::Compilation::~Compilation()'zig_cpp/libzig_cpp.a(zig_clang_cc1as_main.cpp.o): In function
cc1as_main(llvm::ArrayRef<char const*>, char const*, void*)': /home/san/zig-master/src/zig_clang_cc1as_main.cpp:563: undefined reference to
clang::TextDiagnosticPrinter::TextDiagnosticPrinter(llvm::raw_ostream&, clang::DiagnosticOptions*, bool)'/home/san/zig-master/src/zig_clang_cc1as_main.cpp:565: undefined reference to
clang::DiagnosticIDs::DiagnosticIDs()' /home/san/zig-master/src/zig_clang_cc1as_main.cpp:566: undefined reference to
clang::DiagnosticsEngine::DiagnosticsEngine(llvm::IntrusiveRefCntPtrclang::DiagnosticIDs, llvm::IntrusiveRefCntPtrclang::DiagnosticOptions, clang::DiagnosticConsumer*, bool)'/home/san/zig-master/src/zig_clang_cc1as_main.cpp:579: undefined reference to
clang::driver::getDriverOptTable()' /home/san/zig-master/src/zig_clang_cc1as_main.cpp:617: undefined reference to
clang::DiagnosticsEngine::~DiagnosticsEngine()'zig_cpp/libzig_cpp.a(zig_clang_cc1as_main.cpp.o): In function
(anonymous namespace)::AssemblerInvocation::CreateFromArgs((anonymous namespace)::AssemblerInvocation&, llvm::ArrayRef<char const*>, clang::DiagnosticsEngine&)': /home/san/zig-master/src/zig_clang_cc1as_main.cpp:180: undefined reference to
clang::driver::getDriverOptTable()'zig_cpp/libzig_cpp.a(zig_clang_cc1as_main.cpp.o): In function
clang::getLastArgIntValue(llvm::opt::ArgList const&, llvm::opt::OptSpecifier, int, clang::DiagnosticsEngine&, unsigned int)': /usr/lib/llvm-10/include/clang/Driver/OptionUtils.h:40: undefined reference to
clang::getLastArgIntValue(llvm::opt::ArgList const&, llvm::opt::OptSpecifier, int, clang::DiagnosticsEngine*, unsigned int)'clang: error: linker command failed with exit code 1 (use -v to see invocation)
Reaping losing child 0x55b32b5336d0 PID 12042
CMakeFiles/zig0.dir/build.make:134: recipe for target 'zig0' failed
make[3]: *** [zig0] Error 1
Removing child 0x55b32b5336d0 PID 12042 from chain.
Reaping losing child 0x55b8d49bb900 PID 12039
CMakeFiles/Makefile2:261: recipe for target 'CMakeFiles/zig0.dir/all' failed
make[2]: *** [CMakeFiles/zig0.dir/all] Error 2
Removing child 0x55b8d49bb900 PID 12039 from chain.
Reaping losing child 0x557f686f6d30 PID 12010
CMakeFiles/Makefile2:273: recipe for target 'CMakeFiles/zig0.dir/rule' failed
make[1]: *** [CMakeFiles/zig0.dir/rule] Error 2
Removing child 0x557f686f6d30 PID 12010 from chain.
Reaping losing child 0x56131eb19fa0 PID 12007
Makefile:229: recipe for target 'zig0' failed
make: *** [zig0] Error 2
Removing child 0x56131eb19fa0 PID 12007 from chain.
As you can see, something bugged and instead of following only Clang environment it started walking around GCC in the system, which ofc has different version from Clang and when it tried to link against GCC it was not able to do it. Link against Clang instead!
########################
EXTERNAL cache entries
########################
//Path to a file.
CLANG_INCLUDE_DIRS:PATH=/usr/include/clang/10/include
//No help, variable specified on the command line.
CLANG_LIBRARIES:UNINITIALIZED=/usr/lib/clang/10/
//Path to a program.
CMAKE_AR:FILEPATH=/usr/bin/ar
//Choose the type of build, options are: None Debug Release RelWithDebInfo
// MinSizeRel.
CMAKE_BUILD_TYPE:STRING=Debug
//Enable/Disable color output during build.
CMAKE_COLOR_MAKEFILE:BOOL=ON
//CXX compiler
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-10
//LLVM archiver
CMAKE_CXX_COMPILER_AR:FILEPATH=/usr/lib/llvm-10/bin/llvm-ar
//Generate index for LLVM archive
CMAKE_CXX_COMPILER_RANLIB:FILEPATH=/usr/lib/llvm-10/bin/llvm-ranlib
//Flags used by the compiler during all build types.
CMAKE_CXX_FLAGS:STRING=
//Flags used by the compiler during debug builds.
CMAKE_CXX_FLAGS_DEBUG:STRING=-g
//Flags used by the compiler during release builds for minimum
// size.
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
//Flags used by the compiler during release builds.
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
//Flags used by the compiler during release builds with debug info.
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
//C compiler
CMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-10
//LLVM archiver
CMAKE_C_COMPILER_AR:FILEPATH=/usr/lib/llvm-10/bin/llvm-ar
//Generate index for LLVM archive
CMAKE_C_COMPILER_RANLIB:FILEPATH=/usr/lib/llvm-10/bin/llvm-ranlib
//Flags used by the compiler during all build types.
CMAKE_C_FLAGS:STRING=
//Flags used by the compiler during debug builds.
CMAKE_C_FLAGS_DEBUG:STRING=-g
//Flags used by the compiler during release builds for minimum
// size.
CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
//Flags used by the compiler during release builds.
CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
//Flags used by the compiler during release builds with debug info.
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
//Flags used by the linker.
CMAKE_EXE_LINKER_FLAGS:STRING=
//Flags used by the linker during debug builds.
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=
//Flags used by the linker during release minsize builds.
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=
//Flags used by the linker during release builds.
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=
//Flags used by the linker during Release with Debug Info builds.
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
//Enable/Disable output of compile commands during generation.
CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=OFF
//Directory to install zig to
CMAKE_INSTALL_PREFIX:STRING=/home/san/zig-master/build
//Path to a program.
CMAKE_LINKER:FILEPATH=/usr/bin/ld.lld-10
//Path to a program.
CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make
//Flags used by the linker during the creation of modules.
CMAKE_MODULE_LINKER_FLAGS:STRING=
//Flags used by the linker during debug builds.
CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=
//Flags used by the linker during release minsize builds.
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=
//Flags used by the linker during release builds.
CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=
//Flags used by the linker during Release with Debug Info builds.
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
//Path to a program.
CMAKE_NM:FILEPATH=/usr/bin/nm
//Path to a program.
CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy
//Path to a program.
CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump
//Value Computed by CMake
CMAKE_PROJECT_NAME:STATIC=zig
//Path to a program.
CMAKE_RANLIB:FILEPATH=/usr/bin/ranlib
//Flags used by the linker during the creation of dll's.
CMAKE_SHARED_LINKER_FLAGS:STRING=
//Flags used by the linker during debug builds.
CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=
//Flags used by the linker during release minsize builds.
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=
//Flags used by the linker during release builds.
CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=
//Flags used by the linker during Release with Debug Info builds.
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=
//If set, runtime paths are not added when installing shared libraries,
// but are added when building.
CMAKE_SKIP_INSTALL_RPATH:BOOL=NO
//If set, runtime paths are not added when using shared libraries.
CMAKE_SKIP_RPATH:BOOL=NO
//Flags used by the linker during the creation of static libraries.
CMAKE_STATIC_LINKER_FLAGS:STRING=
//Flags used by the linker during debug builds.
CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING=
//Flags used by the linker during release minsize builds.
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING=
//Flags used by the linker during release builds.
CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=
//Flags used by the linker during Release with Debug Info builds.
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=
//Path to a program.
CMAKE_STRIP:FILEPATH=/usr/bin/strip
//If this value is on, makefiles will be generated without the
// .SILENT directive, and all commands will be echoed to the console
// during the make. This is useful for debugging only. With Visual
// Studio IDE projects all commands are done without /nologo.
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
//Path to a program.
GIT_EXE:FILEPATH=/usr/bin/git
//Path to a file.
LLD_INCLUDE_DIRS:PATH=/usr/lib/llvm-10/include
//Path to a library.
LLD_LIBRARY:FILEPATH=LLD_LIBRARY-NOTFOUND
//Path to a library.
LLD_LLDCOFF_LIB:FILEPATH=/usr/lib/llvm-10/lib/liblldCOFF.a
//Path to a library.
LLD_LLDCOMMON_LIB:FILEPATH=/usr/lib/llvm-10/lib/liblldCommon.a
//Path to a library.
LLD_LLDCORE_LIB:FILEPATH=/usr/lib/llvm-10/lib/liblldCore.a
//Path to a library.
LLD_LLDDRIVER_LIB:FILEPATH=/usr/lib/llvm-10/lib/liblldDriver.a
//Path to a library.
LLD_LLDELF_LIB:FILEPATH=/usr/lib/llvm-10/lib/liblldELF.a
//Path to a library.
LLD_LLDMACHO_LIB:FILEPATH=/usr/lib/llvm-10/lib/liblldMachO.a
//Path to a library.
LLD_LLDMINGW_LIB:FILEPATH=/usr/lib/llvm-10/lib/liblldMinGW.a
//Path to a library.
LLD_LLDREADERWRITER_LIB:FILEPATH=/usr/lib/llvm-10/lib/liblldReaderWriter.a
//Path to a library.
LLD_LLDWASM_LIB:FILEPATH=/usr/lib/llvm-10/lib/liblldWasm.a
//Path to a library.
LLD_LLDYAML_LIB:FILEPATH=/usr/lib/llvm-10/lib/liblldYAML.a
//Path to a program.
LLVM_CONFIG_EXE:FILEPATH=/usr/bin/llvm-config-10
//Path to a file.
LLVM_INCLUDE_DIRS:PATH=/usr/lib/llvm-10/include
//Activate memory usage instrumentation
ZIG_ENABLE_MEM_PROFILE:BOOL=off
//(when cross compiling) path to already-built zig binary
ZIG_EXECUTABLE:STRING=
//does nothing
ZIG_FORCE_EXTERNAL_LLD:BOOL=OFF
//Try to link against -lclang-cpp
ZIG_PREFER_CLANG_CPP_DYLIB:BOOL=off
//Attempt to build a static zig executable (not compatible with
// glibc)
ZIG_STATIC:BOOL=off
//Prefer linking against static LLVM libraries
ZIG_STATIC_LLVM:BOOL=off
//-mcpu parameter to output binaries for
ZIG_TARGET_MCPU:STRING=baseline
//arch-os-abi to output binaries for
ZIG_TARGET_TRIPLE:STRING=native
//Build Zig with test coverage instrumentation
ZIG_TEST_COVERAGE:BOOL=OFF
//Dependencies for target
embedded_softfloat_LIB_DEPENDS:STATIC=
//Dependencies for target
opt_c_util_LIB_DEPENDS:STATIC=
//Value Computed by CMake
zig_BINARY_DIR:STATIC=/home/san/zig-master/build
//Value Computed by CMake
zig_SOURCE_DIR:STATIC=/home/san/zig-master
//Dependencies for the target
zig_cpp_LIB_DEPENDS:STATIC=general;/usr/lib/clang/10/;general;/usr/lib/llvm-10/lib/liblldDriver.a;general;/usr/lib/llvm-10/lib/liblldMinGW.a;general;/usr/lib/llvm-10/lib/liblldELF.a;general;/usr/lib/llvm-10/lib/liblldCOFF.a;general;/usr/lib/llvm-10/lib/liblldMachO.a;general;/usr/lib/llvm-10/lib/liblldWasm.a;general;/usr/lib/llvm-10/lib/liblldReaderWriter.a;general;/usr/lib/llvm-10/lib/liblldCore.a;general;/usr/lib/llvm-10/lib/liblldYAML.a;general;/usr/lib/llvm-10/lib/liblldCommon.a;general;-lLLVM-10;
//Dependencies for the target
zigcompiler_LIB_DEPENDS:STATIC=general;zig_cpp;general;opt_c_util;general;embedded_softfloat;general;-lpthread;
The text was updated successfully, but these errors were encountered: