[cfe-dev] Build fails on Solaris x86 (using cmake)

Vladimir Voskresensky - Oracle via cfe-dev cfe-dev at lists.llvm.org
Wed Dec 23 08:21:27 PST 2015


Hello,

Could someone advise, please, how to fix the link step to build clang trunk on 
Solaris x86?

Using configure it worked just fine in previous version.
Now with cmake the first required fix was to absolutize -include in CMakeLists.txt
-   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include llvm/Support/Solaris.h")
+   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include 
${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/Solaris.h")
after that compile phase completes (using GNU 4.9.2).

The remaining issue is building *.so.
I.e. during linking of libclang.so standard c++ methods are unresolved.

Looking at interposed link command call [1] it was observed that "gcc" is used 
as linker tool.
If manually change gcc to g++ and add -std=c++11 and then invoke the link 
command from a command line => link succeeds.

Could someone familiar with cmake point out how to change linker command in 
CMakeList.txt to use g++ for shared libs?

Thanks,
Vladimir.

[1] in folder /export1/home/username/LLVM-TRUNK/build/tools/clang/tools/libclang
calls: /export/home/username/GCC/4.9.2/bin/gcc with args [2]
which calls /usr/ccs/bin/ld with args [3]
arguments [2] and [3] can be seen below

[2] /export/home/username/GCC/4.9.2/bin/gcc
     -fPIC
     -Wl,-z
     -Wl,discard-unused=sections
  -Wl,-M,/export1/home/username/LLVM-TRUNK/build/tools/clang/tools/libclang/libclang.exports
     -Wl,-z,defs
     -shared
     -Wl,-hlibclang.so.3.8
     -o
     ../../../../lib/libclang.so.3.8
     CMakeFiles/libclang.dir/ARCMigrate.cpp.o
     CMakeFiles/libclang.dir/BuildSystem.cpp.o
     CMakeFiles/libclang.dir/CIndex.cpp.o
     CMakeFiles/libclang.dir/CIndexCXX.cpp.o
     CMakeFiles/libclang.dir/CIndexCodeCompletion.cpp.o
     CMakeFiles/libclang.dir/CIndexDiagnostic.cpp.o
     CMakeFiles/libclang.dir/CIndexHigh.cpp.o
     CMakeFiles/libclang.dir/CIndexInclusionStack.cpp.o
     CMakeFiles/libclang.dir/CIndexUSRs.cpp.o
     CMakeFiles/libclang.dir/CIndexer.cpp.o
     CMakeFiles/libclang.dir/CXComment.cpp.o
     CMakeFiles/libclang.dir/CXCursor.cpp.o
     CMakeFiles/libclang.dir/CXCompilationDatabase.cpp.o
     CMakeFiles/libclang.dir/CXLoadedDiagnostic.cpp.o
     CMakeFiles/libclang.dir/CXSourceLocation.cpp.o
     CMakeFiles/libclang.dir/CXStoredDiagnostic.cpp.o
     CMakeFiles/libclang.dir/CXString.cpp.o
     CMakeFiles/libclang.dir/CXType.cpp.o
     CMakeFiles/libclang.dir/IndexBody.cpp.o
     CMakeFiles/libclang.dir/IndexDecl.cpp.o
     CMakeFiles/libclang.dir/IndexTypeSourceInfo.cpp.o
     CMakeFiles/libclang.dir/Indexing.cpp.o
     CMakeFiles/libclang.dir/IndexingContext.cpp.o
     ../../../../lib/libclangAST.a
     ../../../../lib/libclangBasic.a
     ../../../../lib/libclangFrontend.a
     ../../../../lib/libclangIndex.a
     ../../../../lib/libclangLex.a
     ../../../../lib/libclangSema.a
     ../../../../lib/libclangTooling.a
     ../../../../lib/libclangARCMigrate.a
     -ldl
     ../../../../lib/libLLVMAArch64CodeGen.a
     ../../../../lib/libLLVMAArch64AsmPrinter.a
     ../../../../lib/libLLVMAArch64AsmParser.a
     ../../../../lib/libLLVMAArch64Desc.a
     ../../../../lib/libLLVMAArch64Info.a
     ../../../../lib/libLLVMAArch64Disassembler.a
     ../../../../lib/libLLVMAMDGPUCodeGen.a
     ../../../../lib/libLLVMAMDGPUAsmPrinter.a
     ../../../../lib/libLLVMAMDGPUAsmParser.a
     ../../../../lib/libLLVMAMDGPUDesc.a
     ../../../../lib/libLLVMAMDGPUInfo.a
     ../../../../lib/libLLVMARMCodeGen.a
     ../../../../lib/libLLVMARMAsmPrinter.a
     ../../../../lib/libLLVMARMAsmParser.a
     ../../../../lib/libLLVMARMDesc.a
     ../../../../lib/libLLVMARMInfo.a
     ../../../../lib/libLLVMARMDisassembler.a
     ../../../../lib/libLLVMBPFCodeGen.a
     ../../../../lib/libLLVMBPFAsmPrinter.a
     ../../../../lib/libLLVMBPFDesc.a
     ../../../../lib/libLLVMBPFInfo.a
     ../../../../lib/libLLVMCppBackendCodeGen.a
     ../../../../lib/libLLVMCppBackendInfo.a
     ../../../../lib/libLLVMHexagonCodeGen.a
     ../../../../lib/libLLVMHexagonAsmParser.a
     ../../../../lib/libLLVMHexagonDesc.a
     ../../../../lib/libLLVMHexagonInfo.a
     ../../../../lib/libLLVMHexagonDisassembler.a
     ../../../../lib/libLLVMMipsCodeGen.a
     ../../../../lib/libLLVMMipsAsmPrinter.a
     ../../../../lib/libLLVMMipsAsmParser.a
     ../../../../lib/libLLVMMipsDesc.a
     ../../../../lib/libLLVMMipsInfo.a
     ../../../../lib/libLLVMMipsDisassembler.a
     ../../../../lib/libLLVMMSP430CodeGen.a
     ../../../../lib/libLLVMMSP430AsmPrinter.a
     ../../../../lib/libLLVMMSP430Desc.a
     ../../../../lib/libLLVMMSP430Info.a
     ../../../../lib/libLLVMNVPTXCodeGen.a
     ../../../../lib/libLLVMNVPTXAsmPrinter.a
     ../../../../lib/libLLVMNVPTXDesc.a
     ../../../../lib/libLLVMNVPTXInfo.a
     ../../../../lib/libLLVMPowerPCCodeGen.a
     ../../../../lib/libLLVMPowerPCAsmPrinter.a
     ../../../../lib/libLLVMPowerPCAsmParser.a
     ../../../../lib/libLLVMPowerPCDesc.a
     ../../../../lib/libLLVMPowerPCInfo.a
     ../../../../lib/libLLVMPowerPCDisassembler.a
     ../../../../lib/libLLVMSparcCodeGen.a
     ../../../../lib/libLLVMSparcAsmPrinter.a
     ../../../../lib/libLLVMSparcAsmParser.a
     ../../../../lib/libLLVMSparcDesc.a
     ../../../../lib/libLLVMSparcInfo.a
     ../../../../lib/libLLVMSparcDisassembler.a
     ../../../../lib/libLLVMSystemZCodeGen.a
     ../../../../lib/libLLVMSystemZAsmPrinter.a
     ../../../../lib/libLLVMSystemZAsmParser.a
     ../../../../lib/libLLVMSystemZDesc.a
     ../../../../lib/libLLVMSystemZInfo.a
     ../../../../lib/libLLVMSystemZDisassembler.a
     ../../../../lib/libLLVMX86CodeGen.a
     ../../../../lib/libLLVMX86AsmPrinter.a
     ../../../../lib/libLLVMX86AsmParser.a
     ../../../../lib/libLLVMX86Desc.a
     ../../../../lib/libLLVMX86Info.a
     ../../../../lib/libLLVMX86Disassembler.a
     ../../../../lib/libLLVMXCoreCodeGen.a
     ../../../../lib/libLLVMXCoreAsmPrinter.a
     ../../../../lib/libLLVMXCoreDesc.a
     ../../../../lib/libLLVMXCoreInfo.a
     ../../../../lib/libLLVMXCoreDisassembler.a
     ../../../../lib/libLLVMCore.a
     ../../../../lib/libLLVMSupport.a
     ../../../../lib/libclangFormat.a
     ../../../../lib/libclangToolingCore.a
     ../../../../lib/libclangASTMatchers.a
     ../../../../lib/libclangFrontend.a
     ../../../../lib/libclangDriver.a
     ../../../../lib/libclangParse.a
     ../../../../lib/libLLVMOption.a
     ../../../../lib/libclangSerialization.a
     ../../../../lib/libclangSema.a
     ../../../../lib/libclangEdit.a
     ../../../../lib/libclangStaticAnalyzerCheckers.a
     ../../../../lib/libclangStaticAnalyzerCore.a
     ../../../../lib/libclangRewrite.a
     ../../../../lib/libclangAnalysis.a
     ../../../../lib/libclangAST.a
     ../../../../lib/libclangLex.a
     ../../../../lib/libclangBasic.a
     ../../../../lib/libLLVMAArch64Desc.a
     ../../../../lib/libLLVMAArch64AsmPrinter.a
     ../../../../lib/libLLVMAArch64Info.a
     ../../../../lib/libLLVMAArch64Utils.a
     ../../../../lib/libLLVMAMDGPUAsmPrinter.a
     ../../../../lib/libLLVMAMDGPUUtils.a
     ../../../../lib/libLLVMipo.a
     ../../../../lib/libLLVMIRReader.a
     ../../../../lib/libLLVMAsmParser.a
     ../../../../lib/libLLVMLinker.a
     ../../../../lib/libLLVMVectorize.a
     ../../../../lib/libLLVMARMDesc.a
     ../../../../lib/libLLVMARMAsmPrinter.a
     ../../../../lib/libLLVMARMInfo.a
     ../../../../lib/libLLVMBPFAsmPrinter.a
     ../../../../lib/libLLVMHexagonDesc.a
     ../../../../lib/libLLVMHexagonInfo.a
     ../../../../lib/libLLVMMipsAsmPrinter.a
     ../../../../lib/libLLVMMipsInfo.a
     ../../../../lib/libLLVMMSP430AsmPrinter.a
     ../../../../lib/libLLVMNVPTXAsmPrinter.a
     ../../../../lib/libLLVMPowerPCAsmPrinter.a
     ../../../../lib/libLLVMPowerPCInfo.a
     ../../../../lib/libLLVMSparcAsmPrinter.a
     ../../../../lib/libLLVMSparcInfo.a
     ../../../../lib/libLLVMSystemZDesc.a
     ../../../../lib/libLLVMSystemZAsmPrinter.a
     ../../../../lib/libLLVMSystemZInfo.a
     ../../../../lib/libLLVMX86CodeGen.a
     ../../../../lib/libLLVMX86Desc.a
     ../../../../lib/libLLVMX86AsmPrinter.a
     ../../../../lib/libLLVMX86Utils.a
     ../../../../lib/libLLVMX86Info.a
     ../../../../lib/libLLVMXCoreAsmPrinter.a
     ../../../../lib/libLLVMAsmPrinter.a
     ../../../../lib/libLLVMSelectionDAG.a
     ../../../../lib/libLLVMCodeGen.a
     ../../../../lib/libLLVMScalarOpts.a
     ../../../../lib/libLLVMInstCombine.a
     ../../../../lib/libLLVMBitWriter.a
     ../../../../lib/libLLVMInstrumentation.a
     ../../../../lib/libLLVMProfileData.a
     ../../../../lib/libLLVMObject.a
     ../../../../lib/libLLVMBitReader.a
     ../../../../lib/libLLVMMCParser.a
     ../../../../lib/libLLVMTarget.a
     ../../../../lib/libLLVMTransformUtils.a
     ../../../../lib/libLLVMAnalysis.a
     ../../../../lib/libLLVMCore.a
     ../../../../lib/libLLVMXCoreInfo.a
     ../../../../lib/libLLVMMCDisassembler.a
     ../../../../lib/libLLVMMC.a
     ../../../../lib/libLLVMSupport.a
     -lrt
     -ldl
     -lcurses
     -lpthread
     -lz
     -lm
     -Wl,-R$ORIGIN/../lib

[3] calls /usr/ccs/bin/ld in folder 
/export1/home/username/LLVM-TRUNK/build/tools/clang/tools/libclang
     /usr/ccs/bin/ld
     -G
     -dy
     -z
     text
     -M
  /export/home/username/GCC/4.9.2/bin/../lib/gcc/i386-pc-solaris2.10/4.9.2/../../../libgcc-unwind.map
     -Y
     P,/usr/ccs/lib:/lib:/usr/lib
     -Qy
     -o
     ../../../../lib/libclang.so.3.8
     /usr/lib/crti.o
     /usr/lib/values-Xa.o
  /export/home/username/GCC/4.9.2/bin/../lib/gcc/i386-pc-solaris2.10/4.9.2/crtbegin.o
  -L/export/home/username/GCC/4.9.2/bin/../lib/gcc/i386-pc-solaris2.10/4.9.2
     -L/export/home/username/GCC/4.9.2/bin/../lib/gcc
  -L/export/home/username/GCC/4.9.2/bin/../lib/gcc/i386-pc-solaris2.10/4.9.2/../../..
     -z
     discard-unused=sections
     -M
  /export1/home/username/LLVM-TRUNK/build/tools/clang/tools/libclang/libclang.exports
     -z
     defs
     -hlibclang.so.3.8
     CMakeFiles/libclang.dir/ARCMigrate.cpp.o
     CMakeFiles/libclang.dir/BuildSystem.cpp.o
     CMakeFiles/libclang.dir/CIndex.cpp.o
     CMakeFiles/libclang.dir/CIndexCXX.cpp.o
     CMakeFiles/libclang.dir/CIndexCodeCompletion.cpp.o
     CMakeFiles/libclang.dir/CIndexDiagnostic.cpp.o
     CMakeFiles/libclang.dir/CIndexHigh.cpp.o
     CMakeFiles/libclang.dir/CIndexInclusionStack.cpp.o
     CMakeFiles/libclang.dir/CIndexUSRs.cpp.o
     CMakeFiles/libclang.dir/CIndexer.cpp.o
     CMakeFiles/libclang.dir/CXComment.cpp.o
     CMakeFiles/libclang.dir/CXCursor.cpp.o
     CMakeFiles/libclang.dir/CXCompilationDatabase.cpp.o
     CMakeFiles/libclang.dir/CXLoadedDiagnostic.cpp.o
     CMakeFiles/libclang.dir/CXSourceLocation.cpp.o
     CMakeFiles/libclang.dir/CXStoredDiagnostic.cpp.o
     CMakeFiles/libclang.dir/CXString.cpp.o
     CMakeFiles/libclang.dir/CXType.cpp.o
     CMakeFiles/libclang.dir/IndexBody.cpp.o
     CMakeFiles/libclang.dir/IndexDecl.cpp.o
     CMakeFiles/libclang.dir/IndexTypeSourceInfo.cpp.o
     CMakeFiles/libclang.dir/Indexing.cpp.o
     CMakeFiles/libclang.dir/IndexingContext.cpp.o
     ../../../../lib/libclangAST.a
     ../../../../lib/libclangBasic.a
     ../../../../lib/libclangFrontend.a
     ../../../../lib/libclangIndex.a
     ../../../../lib/libclangLex.a
     ../../../../lib/libclangSema.a
     ../../../../lib/libclangTooling.a
     ../../../../lib/libclangARCMigrate.a
     -ldl
     ../../../../lib/libLLVMAArch64CodeGen.a
     ../../../../lib/libLLVMAArch64AsmPrinter.a
     ../../../../lib/libLLVMAArch64AsmParser.a
     ../../../../lib/libLLVMAArch64Desc.a
     ../../../../lib/libLLVMAArch64Info.a
     ../../../../lib/libLLVMAArch64Disassembler.a
     ../../../../lib/libLLVMAMDGPUCodeGen.a
     ../../../../lib/libLLVMAMDGPUAsmPrinter.a
     ../../../../lib/libLLVMAMDGPUAsmParser.a
     ../../../../lib/libLLVMAMDGPUDesc.a
     ../../../../lib/libLLVMAMDGPUInfo.a
     ../../../../lib/libLLVMARMCodeGen.a
     ../../../../lib/libLLVMARMAsmPrinter.a
     ../../../../lib/libLLVMARMAsmParser.a
     ../../../../lib/libLLVMARMDesc.a
     ../../../../lib/libLLVMARMInfo.a
     ../../../../lib/libLLVMARMDisassembler.a
     ../../../../lib/libLLVMBPFCodeGen.a
     ../../../../lib/libLLVMBPFAsmPrinter.a
     ../../../../lib/libLLVMBPFDesc.a
     ../../../../lib/libLLVMBPFInfo.a
     ../../../../lib/libLLVMCppBackendCodeGen.a
     ../../../../lib/libLLVMCppBackendInfo.a
     ../../../../lib/libLLVMHexagonCodeGen.a
     ../../../../lib/libLLVMHexagonAsmParser.a
     ../../../../lib/libLLVMHexagonDesc.a
     ../../../../lib/libLLVMHexagonInfo.a
     ../../../../lib/libLLVMHexagonDisassembler.a
     ../../../../lib/libLLVMMipsCodeGen.a
     ../../../../lib/libLLVMMipsAsmPrinter.a
     ../../../../lib/libLLVMMipsAsmParser.a
     ../../../../lib/libLLVMMipsDesc.a
     ../../../../lib/libLLVMMipsInfo.a
     ../../../../lib/libLLVMMipsDisassembler.a
     ../../../../lib/libLLVMMSP430CodeGen.a
     ../../../../lib/libLLVMMSP430AsmPrinter.a
     ../../../../lib/libLLVMMSP430Desc.a
     ../../../../lib/libLLVMMSP430Info.a
     ../../../../lib/libLLVMNVPTXCodeGen.a
     ../../../../lib/libLLVMNVPTXAsmPrinter.a
     ../../../../lib/libLLVMNVPTXDesc.a
     ../../../../lib/libLLVMNVPTXInfo.a
     ../../../../lib/libLLVMPowerPCCodeGen.a
     ../../../../lib/libLLVMPowerPCAsmPrinter.a
     ../../../../lib/libLLVMPowerPCAsmParser.a
     ../../../../lib/libLLVMPowerPCDesc.a
     ../../../../lib/libLLVMPowerPCInfo.a
     ../../../../lib/libLLVMPowerPCDisassembler.a
     ../../../../lib/libLLVMSparcCodeGen.a
     ../../../../lib/libLLVMSparcAsmPrinter.a
     ../../../../lib/libLLVMSparcAsmParser.a
     ../../../../lib/libLLVMSparcDesc.a
     ../../../../lib/libLLVMSparcInfo.a
     ../../../../lib/libLLVMSparcDisassembler.a
     ../../../../lib/libLLVMSystemZCodeGen.a
     ../../../../lib/libLLVMSystemZAsmPrinter.a
     ../../../../lib/libLLVMSystemZAsmParser.a
     ../../../../lib/libLLVMSystemZDesc.a
     ../../../../lib/libLLVMSystemZInfo.a
     ../../../../lib/libLLVMSystemZDisassembler.a
     ../../../../lib/libLLVMX86CodeGen.a
     ../../../../lib/libLLVMX86AsmPrinter.a
     ../../../../lib/libLLVMX86AsmParser.a
     ../../../../lib/libLLVMX86Desc.a
     ../../../../lib/libLLVMX86Info.a
     ../../../../lib/libLLVMX86Disassembler.a
     ../../../../lib/libLLVMXCoreCodeGen.a
     ../../../../lib/libLLVMXCoreAsmPrinter.a
     ../../../../lib/libLLVMXCoreDesc.a
     ../../../../lib/libLLVMXCoreInfo.a
     ../../../../lib/libLLVMXCoreDisassembler.a
     ../../../../lib/libLLVMCore.a
     ../../../../lib/libLLVMSupport.a
     ../../../../lib/libclangFormat.a
     ../../../../lib/libclangToolingCore.a
     ../../../../lib/libclangASTMatchers.a
     ../../../../lib/libclangFrontend.a
     ../../../../lib/libclangDriver.a
     ../../../../lib/libclangParse.a
     ../../../../lib/libLLVMOption.a
     ../../../../lib/libclangSerialization.a
     ../../../../lib/libclangSema.a
     ../../../../lib/libclangEdit.a
     ../../../../lib/libclangStaticAnalyzerCheckers.a
     ../../../../lib/libclangStaticAnalyzerCore.a
     ../../../../lib/libclangRewrite.a
     ../../../../lib/libclangAnalysis.a
     ../../../../lib/libclangAST.a
     ../../../../lib/libclangLex.a
     ../../../../lib/libclangBasic.a
     ../../../../lib/libLLVMAArch64Desc.a
     ../../../../lib/libLLVMAArch64AsmPrinter.a
     ../../../../lib/libLLVMAArch64Info.a
     ../../../../lib/libLLVMAArch64Utils.a
     ../../../../lib/libLLVMAMDGPUAsmPrinter.a
     ../../../../lib/libLLVMAMDGPUUtils.a
     ../../../../lib/libLLVMipo.a
     ../../../../lib/libLLVMIRReader.a
     ../../../../lib/libLLVMAsmParser.a
     ../../../../lib/libLLVMLinker.a
     ../../../../lib/libLLVMVectorize.a
     ../../../../lib/libLLVMARMDesc.a
     ../../../../lib/libLLVMARMAsmPrinter.a
     ../../../../lib/libLLVMARMInfo.a
     ../../../../lib/libLLVMBPFAsmPrinter.a
     ../../../../lib/libLLVMHexagonDesc.a
     ../../../../lib/libLLVMHexagonInfo.a
     ../../../../lib/libLLVMMipsAsmPrinter.a
     ../../../../lib/libLLVMMipsInfo.a
     ../../../../lib/libLLVMMSP430AsmPrinter.a
     ../../../../lib/libLLVMNVPTXAsmPrinter.a
     ../../../../lib/libLLVMPowerPCAsmPrinter.a
     ../../../../lib/libLLVMPowerPCInfo.a
     ../../../../lib/libLLVMSparcAsmPrinter.a
     ../../../../lib/libLLVMSparcInfo.a
     ../../../../lib/libLLVMSystemZDesc.a
     ../../../../lib/libLLVMSystemZAsmPrinter.a
     ../../../../lib/libLLVMSystemZInfo.a
     ../../../../lib/libLLVMX86CodeGen.a
     ../../../../lib/libLLVMX86Desc.a
     ../../../../lib/libLLVMX86AsmPrinter.a
     ../../../../lib/libLLVMX86Utils.a
     ../../../../lib/libLLVMX86Info.a
     ../../../../lib/libLLVMXCoreAsmPrinter.a
     ../../../../lib/libLLVMAsmPrinter.a
     ../../../../lib/libLLVMSelectionDAG.a
     ../../../../lib/libLLVMCodeGen.a
     ../../../../lib/libLLVMScalarOpts.a
     ../../../../lib/libLLVMInstCombine.a
     ../../../../lib/libLLVMBitWriter.a
     ../../../../lib/libLLVMInstrumentation.a
     ../../../../lib/libLLVMProfileData.a
     ../../../../lib/libLLVMObject.a
     ../../../../lib/libLLVMBitReader.a
     ../../../../lib/libLLVMMCParser.a
     ../../../../lib/libLLVMTarget.a
     ../../../../lib/libLLVMTransformUtils.a
     ../../../../lib/libLLVMAnalysis.a
     ../../../../lib/libLLVMCore.a
     ../../../../lib/libLLVMXCoreInfo.a
     ../../../../lib/libLLVMMCDisassembler.a
     ../../../../lib/libLLVMMC.a
     ../../../../lib/libLLVMSupport.a
     -lrt
     -ldl
     -lcurses
     -lpthread
     -lz
     -lm
     -R$ORIGIN/../lib
     -lgcc_s
     -lc
     -lgcc_s
  /export/home/username/GCC/4.9.2/bin/../lib/gcc/i386-pc-solaris2.10/4.9.2/crtend.o
     /usr/lib/crtn.o


More information about the cfe-dev mailing list