Uh oh!
There was an error while loading. Please reload this page.
CMake: Improve usage of llvm-config (esp. for consistent static/shared linking) - #12136
Conversation
topolarity
commented
Jul 16, 2022
IIUC, |
de26be4 to
bc1c5e2Comparetopolarity
commented
Jul 16, 2022
Any extra steps I need to take to make sure this doesn't break zig-bootstrap? Or will the CI already cover that? |
I have only shared libraries, and before bc1c5e2 it worked fine. --TheCcompileridentificationisGNU11.3.0--TheCXXcompileridentificationisGNU11.3.0--DetectingCcompilerABIinfo--DetectingCcompilerABIinfo-done--CheckforworkingCcompiler:/usr/bin/cc-skipped--DetectingCcompilefeatures--DetectingCcompilefeatures-done--DetectingCXXcompilerABIinfo--DetectingCXXcompilerABIinfo-done--CheckforworkingCXXcompiler:/usr/bin/c++-skipped--DetectingCXXcompilefeatures--DetectingCXXcompilefeatures-done--Configuringzigversion0.10.0-dev.3013+e867127a6llvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMBinaryFormat.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMBitstreamReader.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMRemarks.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMCore.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMBitReader.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMDebugInfoCodeView.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMMC.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMMCParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMTextAPI.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMObject.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMDebugInfoDWARF.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMProfileData.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAnalysis.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMBitWriter.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMTransformUtils.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAggressiveInstCombine.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMInstCombine.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMScalarOpts.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMTarget.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMFuzzMutate.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMFileCheck.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMInterfaceStub.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMIRReader.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMCodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMSelectionDAG.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMDebugInfoMSF.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAsmPrinter.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMMIRParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMGlobalISel.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMDWARFLinker.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMExtensions.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMFrontendOpenACC.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMFrontendOpenMP.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMInstrumentation.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMLinker.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMVectorize.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMipo.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMObjCARCOpts.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMCoroutines.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMCFGuard.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMPasses.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMLTO.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMMCDisassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMMCA.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMObjectYAML.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMOption.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMDebugInfoGSYM.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMDebugInfoPDB.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMSymbolize.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMDWP.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMOrcShared.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMOrcTargetProcess.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMRuntimeDyld.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMExecutionEngine.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMInterpreter.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMJITLink.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMMCJIT.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMOrcJIT.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMXCoreInfo.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMXCoreDesc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMXCoreCodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMXCoreDisassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAVRInfo.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAVRDesc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAVRCodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAVRAsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAVRDisassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMWebAssemblyInfo.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMWebAssemblyUtils.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMWebAssemblyDesc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMWebAssemblyCodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMWebAssemblyAsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMWebAssemblyDisassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMSystemZInfo.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMSystemZDesc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMSystemZCodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMSystemZAsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMSystemZDisassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMRISCVInfo.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMRISCVDesc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMRISCVCodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMRISCVAsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMRISCVDisassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMSparcInfo.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMSparcDesc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMSparcCodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMSparcAsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMSparcDisassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAArch64Info.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAArch64Utils.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAArch64Desc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAArch64CodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAArch64AsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAArch64Disassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMMSP430Info.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMMSP430Desc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMMSP430CodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMMSP430AsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMMSP430Disassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMHexagonInfo.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMHexagonDesc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMHexagonAsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMHexagonCodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMHexagonDisassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMLanaiInfo.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMLanaiDesc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMLanaiAsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMLanaiCodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMLanaiDisassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMVEInfo.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMVEDesc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMVECodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMVEAsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMVEDisassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMMipsInfo.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMMipsDesc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMMipsCodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMMipsAsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMMipsDisassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMNVPTXInfo.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMNVPTXDesc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMNVPTXCodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMPowerPCInfo.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMPowerPCDesc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMPowerPCCodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMPowerPCAsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMPowerPCDisassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMBPFInfo.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMBPFDesc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMBPFCodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMBPFAsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMBPFDisassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMX86Info.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMX86Desc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMX86CodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMX86AsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMX86Disassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMX86TargetMCA.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMARMInfo.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMARMUtils.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMARMDesc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMARMCodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMARMAsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMARMDisassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAMDGPUInfo.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAMDGPUUtils.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAMDGPUDesc.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAMDGPUCodeGen.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAMDGPUAsmParser.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAMDGPUDisassembler.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMAMDGPUTargetMCA.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMLineEditor.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMCoverage.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMDlltoolDriver.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMLibDriver.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMXRay.allvm-config:error:missing:/usr/lib/llvm/14/lib64/libLLVMWindowsManifest.a--Foundllvm:/usr/lib/llvm/14/lib64/libLLVM-14.so (Requiredisatleastversion"14") --Foundclang:/usr/lib/llvm/14/lib64/libclang-cpp.so.14 (Requiredisatleastversion"14") --CouldNOTfindlld (missing:LLD_LIBRARIESLLD_INCLUDE_DIRS) (Requiredisatleastversion"14")
--Lookingforpthread.h--Lookingforpthread.h-found--PerformingTestCMAKE_HAVE_LIBC_PTHREAD--PerformingTestCMAKE_HAVE_LIBC_PTHREAD-Success--FoundThreads:TRUE--ConfiguringdoneCMakeError:Thefollowingvariablesareusedinthisproject,buttheyaresettoNOTFOUND.PleasesetthemormakesuretheyaresetandtestedcorrectlyintheCMakefiles:LLD_INCLUDE_DIRS (ADVANCED)
usedasincludedirectoryindirectory/home/bratishkaerik/zigusedasincludedirectoryindirectory/home/bratishkaerik/zigusedasincludedirectoryindirectory/home/bratishkaerik/zigusedasincludedirectoryindirectory/home/bratishkaerik/zigusedasincludedirectoryindirectory/home/bratishkaerik/zigusedasincludedirectoryindirectory/home/bratishkaerik/zigusedasincludedirectoryindirectory/home/bratishkaerik/zigusedasincludedirectoryindirectory/home/bratishkaerik/zigusedasincludedirectoryindirectory/home/bratishkaerik/zigusedasincludedirectoryindirectory/home/bratishkaerik/zigusedasincludedirectoryindirectory/home/bratishkaerik/zigusedasincludedirectoryindirectory/home/bratishkaerik/zigCMakeErrorinCMakeLists.txt:Foundrelativepathwhileevaluatingincludedirectoriesof"embedded_softfloat":"LLD_INCLUDE_DIRS-NOTFOUND"CMakeErrorinCMakeLists.txt:Foundrelativepathwhileevaluatingincludedirectoriesof"zigcpp":"LLD_INCLUDE_DIRS-NOTFOUND"CMakeErrorinCMakeLists.txt:Foundrelativepathwhileevaluatingincludedirectoriesof"opt_c_util":"LLD_INCLUDE_DIRS-NOTFOUND"CMakeErrorinCMakeLists.txt:Foundrelativepathwhileevaluatingincludedirectoriesof"zigstage1":"LLD_INCLUDE_DIRS-NOTFOUND"CMakeErrorinCMakeLists.txt:Foundrelativepathwhileevaluatingincludedirectoriesof"zig0":"LLD_INCLUDE_DIRS-NOTFOUND"CMakeErrorinCMakeLists.txt:Foundrelativepathwhileevaluatingincludedirectoriesof"zig":"LLD_INCLUDE_DIRS-NOTFOUND"--GeneratingdoneCMakeGeneratestepfailed.Buildfilescannotberegeneratedcorrectly. |
topolarity
commented
Jul 16, 2022
Thanks for the report. I'll look into it. Can you also share the output before this change, for comparison? |
--TheCcompileridentificationisGNU11.3.0--TheCXXcompileridentificationisGNU11.3.0--DetectingCcompilerABIinfo--DetectingCcompilerABIinfo-done--CheckforworkingCcompiler:/usr/bin/cc-skipped--DetectingCcompilefeatures--DetectingCcompilefeatures-done--DetectingCXXcompilerABIinfo--DetectingCXXcompilerABIinfo-done--CheckforworkingCXXcompiler:/usr/bin/c++-skipped--DetectingCXXcompilefeatures--DetectingCXXcompilefeatures-done--Configuringzigversion0.10.0-dev.3013+e867127a6--Foundllvm:/usr/lib/llvm/14/lib64/libLLVM-14.so (Requiredisatleastversion"14")
--Foundclang:/usr/lib/llvm/14/lib64/libclang-cpp.so (Requiredisatleastversion"14")
--Foundlld:/usr/lib64/liblldMinGW.so;/usr/lib64/liblldELF.so;/usr/lib64/liblldCOFF.so;/usr/lib64/liblldWasm.so;/usr/lib64/liblldMachO.so;/usr/lib64/liblldCommon.so (Requiredisatleastversion"14")
--Lookingforpthread.h--Lookingforpthread.h-found--PerformingTestCMAKE_HAVE_LIBC_PTHREAD--PerformingTestCMAKE_HAVE_LIBC_PTHREAD-Success--FoundThreads:TRUE--Configuringdone--Generatingdone--Buildfileshavebeenwrittento:/home/bratishkaerik/zig/build |
I tried this on M1 Mac and successfully built stage1 and stage2 without the zlib-workaround. Behaviour tests worked as well. However, building stage3 currently crashes. This started to happen on master too, today. So it may be unrelated. |
BratishkaErik
commented
Jul 16, 2022
Do you mean #12069? IDK how but I can build stage1 without this workaround (both static and shared zlib installed) (IIUC llvm-config can't choose between static and shared form on affected systems?) |
kamidev
commented
Jul 16, 2022
Yes, #12069. Interesting! I had this problem on ARM Mac and Intel Mac, other people reported it on Arch Linux and NixOS. What are you running? |
Gentoo Linux, tried https://packages.gentoo.org/packages/sys-libs/zlib (shared library) with |
topolarity
commented
Jul 16, 2022
The stage 3 problems may be related to #12133. I have to rework that PR a bit, but it'd be helpful to know if it makes any difference for you as-is |
bc1c5e2 to
1079cb7Compare
Notice:
But it surely does. It's a bit confusing. Besides this, thank you so much! |
topolarity
commented
Jul 16, 2022
Thanks for the helpful reports! Can you share the output of |
Empty line. Maybe |
The commit just pushed should report the error received from llvm-config. Would you mind trying it once more? |
BratishkaErik
commented
Jul 16, 2022
|
topolarity
commented
Jul 16, 2022
That error message should have said "LLVM 14.x found at /usr/lib/llvm/14/bin/llvm-config does not support linking as a static library". Fixed now Regarding the failure itself: Are the files reported missing present elsewhere in If not, then CMake might just be correctly informing you that there is no static version of LLVM that it can find to link against. |
BratishkaErik
commented
Jul 16, 2022
Oh! Now I can sleep in peace :)
Only shared. #12136 (comment) |
b4216d7 to
3371470Comparetopolarity
commented
Jul 17, 2022
Pushed a change to build This is the first time we'll be building and installing a shared library as part of the Zig build process, so hopefully I got all of the details right (especially |
warning: FileNotFound: /home/bratishkaerik/zig/build/zigcpp/libzigcpp.athread25859panic: attempttounwraperror: FileNotFound/home/bratishkaerik/zig/lib/std/process.zig:373:46: 0x5654b62bed41instd.process.getEnvVarOwned (zig1)
constresult=os.getenv(key) orelsereturnerror.EnvironmentVariableNotFound;
^/home/bratishkaerik/zig/lib/std/process.zig:373:46: 0x5654b62bed41instd.process.getEnvVarOwned (zig1)
constresult=os.getenv(key) orelsereturnerror.EnvironmentVariableNotFound;
^/home/bratishkaerik/zig/lib/std/process.zig:373:46: 0x5654b62bed41instd.process.getEnvVarOwned (zig1)
constresult=os.getenv(key) orelsereturnerror.EnvironmentVariableNotFound;
^/home/bratishkaerik/zig/lib/std/os.zig:3068:19: 0x5654b62d5019instd.os.readlinkZ (zig1)
.INVAL=>returnerror.NotLink,
^/home/bratishkaerik/zig/lib/std/zig/system/NativeTargetInfo.zig:419:26: 0x5654b655d5d8instd.zig.system.NativeTargetInfo.glibcVerFromSO (zig1)
error.NotLink=>returnerror.GnuLibCVersionUnavailable,
^/home/bratishkaerik/zig/lib/std/os.zig:2749:19: 0x5654b62463c0instd.os.mkdiratZ (zig1)
.EXIST=>returnerror.PathAlreadyExists,
^/home/bratishkaerik/zig/lib/std/os.zig:2709:9: 0x5654b6246276instd.os.mkdirat (zig1)
returnmkdiratZ(dir_fd, &sub_dir_path_c, mode);
^/home/bratishkaerik/zig/lib/std/fs.zig:1327:9: 0x5654b6246186instd.fs.Dir.makeDir (zig1)
tryos.mkdirat(self.fd, sub_path, default_new_dir_mode);
^/home/bratishkaerik/zig/lib/std/os.zig:2749:19: 0x5654b62463c0instd.os.mkdiratZ (zig1)
.EXIST=>returnerror.PathAlreadyExists,
^/home/bratishkaerik/zig/lib/std/os.zig:2709:9: 0x5654b6246276instd.os.mkdirat (zig1)
returnmkdiratZ(dir_fd, &sub_dir_path_c, mode);
^/home/bratishkaerik/zig/lib/std/fs.zig:1327:9: 0x5654b6246186instd.fs.Dir.makeDir (zig1)
tryos.mkdirat(self.fd, sub_path, default_new_dir_mode);
^/home/bratishkaerik/zig/lib/std/os.zig:2749:19: 0x5654b62463c0instd.os.mkdiratZ (zig1)
.EXIST=>returnerror.PathAlreadyExists,
^/home/bratishkaerik/zig/lib/std/os.zig:2709:9: 0x5654b6246276instd.os.mkdirat (zig1)
returnmkdiratZ(dir_fd, &sub_dir_path_c, mode);
^/home/bratishkaerik/zig/lib/std/fs.zig:1327:9: 0x5654b6246186instd.fs.Dir.makeDir (zig1)
tryos.mkdirat(self.fd, sub_path, default_new_dir_mode);
^/home/bratishkaerik/zig/lib/std/os.zig:2749:19: 0x5654b62463c0instd.os.mkdiratZ (zig1)
.EXIST=>returnerror.PathAlreadyExists,
^/home/bratishkaerik/zig/lib/std/os.zig:2709:9: 0x5654b6246276instd.os.mkdirat (zig1)
returnmkdiratZ(dir_fd, &sub_dir_path_c, mode);
^/home/bratishkaerik/zig/lib/std/fs.zig:1327:9: 0x5654b6246186instd.fs.Dir.makeDir (zig1)
tryos.mkdirat(self.fd, sub_path, default_new_dir_mode);
^/home/bratishkaerik/zig/lib/std/os.zig:2749:19: 0x5654b62463c0instd.os.mkdiratZ (zig1)
.EXIST=>returnerror.PathAlreadyExists,
^/home/bratishkaerik/zig/lib/std/os.zig:2709:9: 0x5654b6246276instd.os.mkdirat (zig1)
returnmkdiratZ(dir_fd, &sub_dir_path_c, mode);
^/home/bratishkaerik/zig/lib/std/fs.zig:1327:9: 0x5654b6246186instd.fs.Dir.makeDir (zig1)
tryos.mkdirat(self.fd, sub_path, default_new_dir_mode);
^/home/bratishkaerik/zig/lib/std/os.zig:1680:23: 0x5654b6535810instd.os.openatZ (zig1)
.NOENT=>returnerror.FileNotFound,
^/home/bratishkaerik/zig/lib/std/fs.zig:1076:13: 0x5654b623f8b6instd.fs.Dir.openFileZ (zig1)
tryos.openatZ(self.fd, sub_path, os_flags, 0);
^/home/bratishkaerik/zig/lib/std/fs.zig:1003:9: 0x5654b623bd0einstd.fs.Dir.openFile (zig1)
returnself.openFileZ(&path_c, flags);
^/home/bratishkaerik/zig/src/Cache.zig:539:22: 0x5654b623d6dainCache.Manifest.populateFileHash (zig1)
constfile=tryfs.cwd().openFile(ch_file.path.?, .{});
^/home/bratishkaerik/zig/src/Cache.zig:476:21: 0x5654b622940dinCache.Manifest.hit (zig1)
returnerr;
^/home/bratishkaerik/zig/src/Compilation.zig:2130:13: 0x5654b6321549inCompilation.update (zig1)
returnerr;
^/home/bratishkaerik/zig/src/main.zig:3294:5: 0x5654b62b13edinmain.updateModule (zig1)
trycomp.update();
^/home/bratishkaerik/zig/src/main.zig:2985:21: 0x5654b620c84binmain.buildOutputType (zig1)
else=>|e|returne,
^/home/bratishkaerik/zig/src/main.zig:219:9: 0x5654b61b8e23inmain.mainArgs (zig1)
returnbuildOutputType(gpa, arena, args, .{ .build=.Exe });
^???:?:?: 0x5654b61ba7abin??? (/home/bratishkaerik/zig/src/stage1/stage1.cpp)
/home/bratishkaerik/zig/src/stage1.zig:48:43: 0x5654b61b8938inmain (zig1)
stage2.mainArgs(gpa, arena, args) catchunreachable;
^error: zig...error: Thefollowingcommandterminatedunexpectedly:
/home/bratishkaerik/zig/build/zigbuild-exe/home/bratishkaerik/zig/src/main.zig-lc/home/bratishkaerik/zig/build/zigcpp/libzigcpp.a/usr/lib/llvm/14/lib64/libclang-cpp.so.14 /usr/lib64/liblldMinGW.so/usr/lib64/liblldELF.so/usr/lib64/liblldCOFF.so/usr/lib64/liblldWasm.so/usr/lib64/liblldMachO.so/usr/lib64/liblldCommon.so/usr/lib/llvm/14/lib64/libLLVM-14.so/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/libstdc++.a-lunwind--cache-dir/home/bratishkaerik/zig/zig-cache--global-cache-dir/home/bratishkaerik/.cache/zig--namezig--pkg-beginbuild_options/home/bratishkaerik/zig/zig-cache/options/0ghZFRJv5yPSIQOmN7jArYzqIPaxipxNPztZSGsd95d9FUsuBk1sFGWFiIl23teH --pkg-end-I/usr/include-fno-build-id--enable-cacheerror: thefollowingbuildcommandfailedwithexitcode6:
/home/bratishkaerik/zig/zig-cache/o/9e99760733e35b737bbb023007fc4485/build/home/bratishkaerik/zig/build/zig/home/bratishkaerik/zig/home/bratishkaerik/zig/zig-cache/home/bratishkaerik/.cache/zig-pstage2-Dstatic-llvm=false-Denable-llvm=true |
diff --git a/build.zig b/build.zig
index 31347f8e7..27c3931ac 100644
--- a/build.zig+++ b/build.zig@@ -59,6 +59,7 @@ pub fn build(b: *Builder) !void {
const skip_run_translated_c = b.option(bool, "skip-run-translated-c", "Main test suite skips run-translated-c tests") orelse false;
const skip_stage2_tests = b.option(bool, "skip-stage2-tests", "Main test suite skips self-hosted compiler tests") orelse false;
const skip_install_lib_files = b.option(bool, "skip-install-lib-files", "Do not copy lib/ files to installation prefix") orelse false;
+ const skip_rpath = b.option(bool, "skip-rpath", "Do not set DT_RUNPATH (useful for package maintainers)") orelse false;
const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;
@@ -331,8 +332,23 @@ pub fn build(b: *Builder) !void {
b.addSearchPrefix(cfg.cmake_prefix_path);
}
+ const zig_cpp_lib_name = b.fmt("{s}zigcpp{s}", .{ exe.target.libPrefix(), exe.target.dynamicLibSuffix() });++ const zig_cpp_lib_location = fs.path.join(b.allocator, &[_][]const u8{ cfg.cmake_binary_dir, "zigcpp", zig_cpp_lib_name }) catch unreachable;++ exe.addObjectFile(zig_cpp_lib_location);+ test_cases.addObjectFile(zig_cpp_lib_location);++ if (!skip_rpath) {+ switch (exe.target.getOsTag()) {+ .macos => exe.addRPath("@loader_path/../lib"),+ else => exe.addRPath("$ORIGIN/../lib"),+ }+ }+
try addCmakeCfgOptionsToExe(b, cfg, exe, use_zig_libcxx);
try addCmakeCfgOptionsToExe(b, cfg, test_cases, use_zig_libcxx);
+ b.installLibFile(zig_cpp_lib_location, zig_cpp_lib_name);
} else {
// Here we are -Denable-llvm but no cmake integration.
try addStaticLlvmOptionsToExe(exe);
@@ -534,11 +550,6 @@ fn addCmakeCfgOptionsToExe(
exe: *std.build.LibExeObjStep,
use_zig_libcxx: bool,
) !void {
- exe.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{- cfg.cmake_binary_dir,- "zigcpp",- b.fmt("{s}{s}{s}", .{ exe.target.libPrefix(), "zigcpp", exe.target.staticLibSuffix() }),- }) catch unreachable);
assert(cfg.lld_include_dir.len != 0);
exe.addIncludePath(cfg.lld_include_dir);
addCMakeLibraryList(exe, cfg.clang_libraries);You can pass |
Everything from https://github.com/ziglang/zig/wiki/Building-Zig-From-Source builds and works fine: stage1Option B
$ stage1/bin/zig build -p stage1-from-prebuilt -Dstage1 -Domit-stage2 --zig-lib-dir /home/bratishkaerik/zig/lib/ --search-prefix /usr/lib/llvm/14/ -Dstatic-llvm=false -Dskip-rpath=true -Drelease=true && strip stage1-from-prebuilt/bin/zig
LLD Link... warning(link): unexpected LLD stderr:
ld.lld: warning: linking module flags 'Dwarf Version': IDs have conflicting values ('i32 5' from /home/bratishkaerik/zig/zig-cache/o/310992a639b0dffe65c963fb2461b00e/analyze.o with 'i32 4' from ld-temp.o)
$ stage1-from-prebuilt/bin/zig version
0.10.0-dev.3024+47c58cba5
$ stage1-from-prebuilt/bin/zig build --help
[1] 11387 segmentation fault stage1-from-prebuilt/bin/zig build --helpComparing sizes (all in release modes, without rpath and stripped)stage1Option AOption Bstage2stage3Comparing sizes (all in debug modes, without rpath and not stripped)stage1Option AOption Bstage2stage3Oh, I also noticed that with this pull request we can build stage2/stage3 without patch (IIUC only when using new shared library) from #11137 (but bug still persist) |
3371470 to
9d2e1b0Compare@BratishkaErik Thanks for all of the thorough testing, I really appreciate it. Pushed support for stage2 (+3) Most important difference w.r.t. your change is that I did not make RPATH configurable. |
BratishkaErik
commented
Jul 18, 2022
scanelf: rpath_security_checks(): Security problem NULL DT_RUNPATH in zigcpp/libzigcpp.soI guess libzigcpp.so doesn't need RPATH? diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2ae8e3d18..6dcd76d6c 100644
--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -907,6 +907,7 @@ endif()
set_target_properties(zigcpp PROPERTIES
COMPILE_FLAGS ${EXE_CFLAGS}
+ SKIP_BUILD_RPATH On
)
target_link_libraries(zigcpp LINK_PUBLIC |
9d2e1b0 to
7b3c870Comparetopolarity
commented
Jul 18, 2022
Good catch! Updated now, thank you. |
topolarity
commented
Jul 19, 2022
I haven't quite managed to grok the common recommendation not to "mix" static/shared libraries, to be honest - At the end of the day, static libraries are just (collections of) object files, and saying not to mix them with shared libraries would suggest it's also wrong to mix object files with shared libraries - But that's a linker's entire job. The concrete problem I've seen is not C++ UB - It's that this part of the C standard (http://port70.net/~nsz/c/c11/n1570.html#6.2.2p2) no longer holds up when statically linking the same objects (e.g. I'm also no expert in C++ or linkers. There's a high chance there's more complexity I'm missing here, so I'm all ears if any of the above is wrong.
Tell me about it 😰 |
topolarity
commented
Jul 20, 2022
Same as the LLD situation basically - There are concerns about mixing shared/static stepping on C++ UB, but I don't personally have a specific bug/standard I can point to that says why this would have to be shared Happy to revert, if you'd prefer. My priority is that we don't statically link |
andrewrk
commented
Jul 21, 2022
This is indeed the concrete problem that I am thinking of (which you have addressed in #12085), and that is my mistake for confusing things by saying "C++ UB". I think that I have gotten this problem mixed up with the Static Initialization Order Fiasco.
I am firmly convinced that making these files dynamically linked is the wrong way to go, and would indeed request a revert on that particular change.
I share this priority with you. |
topolarity
commented
Jul 21, 2022
Great, sounds like a plan. Thanks for the input - I needed a Core Team POV on this one. |
This commit reworks the LLVM/Clang/LLD discovery process for CMake. The
biggest changes are that:
1. We search for LLVM from most preferred directory to least, skipping
any `llvm-config` that is the wrong version, or that doesn't
support the requested link mode ("static" or "shared").
2. `ZIG_PREFER_CLANG_CPP_DYLIB` has been renamed to `ZIG_SHARED_LLVM`,
to better align with `ZIG_STATIC_LLVM`.
3. We only search for LLVM in the same directory alongside LLVM.
4. LLVM's link mode is forwarded to Clang, so that we can look for the
appropriate shared/static libraries.
5. We use `--link-static` when querying `--system-libs` from llvm-config,
so that this will include libz and other dependencies for
statically linking LLDThis change relaxes the restriction added in the prior commit that LLD should be alongside LLVM. This also leaves unresolved the issue of making sure the link mode (static or shared) of LLD matches that of LLVM/Clang. That would be an unfortunate restriction, since LLD seems to be provided only as a static lib on some distros.
This is currently unused, but it will be needed soon so that we can avoid linking static libc++ if LLVM/Clang is configured as a shared library.
7b3c870 to
5337934Comparevoroskoi
commented
Jul 24, 2022
Sorry for coming late to the party, but unlike master this branch does not work with guix, does not find the clang include dir and libs. They have different hash than llvm include dirs, so I have no idea how to handle this. Does it work with nixos? |
… CMAKE_FRAMEWORK_PATH On some systems (esp. systems that use unique hashed file-paths for library-versions like Nix), we can't expect LLVM and Clang to share lib/bin directories. The best we can do is find the matching clang libraries in the CMAKE_LIBRARY_PATH provided by the environment
62487e3 to
abc1ae5Compare
Thanks for the heads up - I've relaxed the way we look for Clang so that it respects I think this is enough to get things operational on Nix-like OS's again (tested on a local install of NixOS) |
voroskoi
commented
Jul 26, 2022
This one works indeed, thanks. Only #12153 left, but as far as I understand Andrew that stays this way for a while. |
andrewrk
commented
Jul 26, 2022
Thank you @topolarity, this looks like it was an ordeal in order to implement. I think this is the best we can do with what we've got. That Really appreciate your diligence on this one. |
-DZIG_SHARED_LLVM See ziglang/zig#12136 Signed-off-by: BratishkaErik <bratishkaerik@getgoogleoff.me>
…stage2, minor fix stage1 installation (cmake_src_install) already does this -DZIG_PREFER_CLANG_CPP_DYLIB has been renamed to -DZIG_SHARED_LLVM, see ziglang/zig#12136 Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
…stage2, minor fix stage1 installation (cmake_src_install) already does this -DZIG_PREFER_CLANG_CPP_DYLIB has been renamed to -DZIG_SHARED_LLVM, see ziglang/zig#12136 Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
…stage2, critical fix stage1 installation (cmake_src_install) already does this -DZIG_PREFER_CLANG_CPP_DYLIB has been renamed to -DZIG_SHARED_LLVM, see ziglang/zig#12136 Closes: https://bugs.gentoo.org/864247 Co-authored-by: Rahim Usubov <the.guard@mail.ru> Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
…stage2, critical fix stage1 installation (cmake_src_install) already does this -DZIG_PREFER_CLANG_CPP_DYLIB has been renamed to -DZIG_SHARED_LLVM, see ziglang/zig#12136 Closes: https://bugs.gentoo.org/864247 Co-authored-by: Rahim Usubov <the.guard@mail.ru> Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
cmake_src_install already installs lib/, so we should skip this in stage2 -DZIG_PREFER_CLANG_CPP_DYLIB has been renamed to -DZIG_SHARED_LLVM, see ziglang/zig#12136 Closes: https://bugs.gentoo.org/864247Closes: gentoo#26779 Co-authored-by: Rahim Usubov <the.guard@mail.ru> Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
cmake_src_install already installs lib/, so we should skip this in stage2 -DZIG_PREFER_CLANG_CPP_DYLIB has been renamed to -DZIG_SHARED_LLVM, see ziglang/zig#12136 Closes: https://bugs.gentoo.org/864247Closes: gentoo#26779 Co-authored-by: Rahim Usubov <the.guard@mail.ru> Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
cmake_src_install already installs lib/, so we should skip this in stage2 -DZIG_PREFER_CLANG_CPP_DYLIB has been renamed to -DZIG_SHARED_LLVM, see ziglang/zig#12136 Closes: https://bugs.gentoo.org/864247Closes: #26779 Co-authored-by: Rahim Usubov <the.guard@mail.ru> Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me> Signed-off-by: Jakov Smolić <jsmolic@gentoo.org>
| ) | ||
| if(ZIG_USE_LLVM_CONFIG) | ||
| while(1) | ||
| unset(LLVM_CONFIG_EXE CACHE) |
There was a problem hiding this comment.
What's the goal here, why unset LLVM_CONFIG_EXE, what if we want to -DLLVM_CONFIG_EXE=<some/path/to/llvm-config> ?
This commit reworks the LLVM/Clang/LLD discovery process for CMake.
llvm-configreally wraps two sets of libraries that exist in parallel in an installation: shared and static. Building LLVM according to the wiki gives you only static libs. However, building with-DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ONmeans that your LLVM/Clang installation with have both sets of libraries (which is usually the case for system-provided LLVM/Clang).In that case, llvm-config reports entirely different libraries and dependencies for
--link-staticversus--link-sharedThis include several changes to handle this better:
llvm-configfrom most preferred directory to least, skipping any candidate that is the wrong version or doesn't support the requested link mode ("static" or "shared")-DZIG_PREFER_CLANG_CPP_DYLIBhas been renamed to-DZIG_SHARED_LLVM, to better align with-DZIG_STATIC_LLVM.CMAKE_LIBRARY_PATH)llvm-configto find include directories