conda-forge / llvmdev-feedstock

A conda-smithy repository for llvmdev.
BSD 3-Clause "New" or "Revised" License
8 stars 41 forks source link

Issues building ZIG on windows #273

Closed MementoRC closed 3 months ago

MementoRC commented 3 months ago

Solution to issue cannot be found in the documentation.

Issue

When trying to build ZIG on windows I see these failures: LLVMWindowsManifest.lib(WindowsManifestMerger.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in zigcpp.lib(zig_llvm.cpp.obj) Would you think this an isue with how LLVM is linked ro a setup issue with how I compile ZIG? On windows it requires a static build

Installed packages

llvmdev, clangdev

Environment info

conda-forge environment for recipe: https://github.com/conda-forge/zig-feedstock/pull/23
isuruf commented 3 months ago

We require all packages across conda-forge (and downstream users) to use /MD instead of /MT

MementoRC commented 3 months ago

Thanks for the quick reply, I will investigate further. llvmdev for windows is not a static library? I thought you mentioned this in a different Issue

isuruf commented 3 months ago

Yes

MementoRC commented 3 months ago

ZIG requires a static LLVM, does that mean that it cannot be added to conda-forge? - (bear with my lack of expertise in windows env) So actually, ZIG recipe typically includes building LLVM, clang and lld from source, could that be acceptable? Meaning, creating the executable with statically linked libraries (but not releasing and library, just the exec)

isuruf commented 3 months ago

We do have a static LLVM, but it uses the dynamic VC runtime (/MD) instead of the static VC runtime (/MT). I think you just have to patch sig to use /MD.

MementoRC commented 3 months ago

Ok, I will look into this, it's been quite a journey of blindness with an elephant ... :\ - Thank you for the nudge

MementoRC commented 3 months ago

The build progressed passed the MD issue. It required more patching to link zstd, zlib and xml2. However, now in the link phase there is no longer the previous errors, but the build just seem to hang on the linkage phase till the 360mns window. Do you think this could be a memory issue? Would you suggest to investigate trying on a 2xlarge?

isuruf commented 3 months ago

I'm not sure. Try using clang and lld to compile zig?

MementoRC commented 3 months ago

Ok, will try thanks - btw, is Uwe still part of conda-forge? I tired to ping him on those without feedback, so I tried bugging you.

I also saw a recipe cross-compiling linux-64 -> win-64, but is there a qemu for this? ZIG needs to run pieces of code on the target, though the ppc64le doesn't cross-build so far

MementoRC commented 3 months ago

Any chances you'd know why I keep getting this: error: ld.lld: cannot open /usr/lib64/libmvec_nonshared.a: No such file or directory It seems hard-coded somewhere, I do have libmvec_nonshared.a from sysroot, but there seems to be no way to point ld.lld to it. It is nowhere to be found in the zig source folder and it is not on the command line:

/home/conda/feedstock_root/build_artifacts/zig_1718997879896/work/zig-bootstrap/zig build-exe --stack 33554432 -cflags -std=c++17 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D_GNU_SOURCE -fno-exceptions -fno-rtti -fno-stack-protector -fvisibility-inlines-hidden -Wno-type-limits -Wno-missing-braces -Wno-comment -DNDEBUG=1 -- /home/conda/feedstock_root/build_artifacts/zig_1718997879896/work/conda-zig-source/src/zig_llvm.cpp /home/conda/feedstock_root/build_artifacts/zig_1718997879896/work/conda-zig-source/src/zig_clang.cpp /home/conda/feedstock_root/build_artifacts/zig_1718997879896/work/conda-zig-source/src/zig_llvm-ar.cpp /home/conda/feedstock_root/build_artifacts/zig_1718997879896/work/conda-zig-source/src/zig_clang_driver.cpp /home/conda/feedstock_root/build_artifacts/zig_1718997879896/work/conda-zig-source/src/zig_clang_cc1_main.cpp /home/conda/feedstock_root/build_artifacts/zig_1718997879896/work/conda-zig-source/src/zig_clang_cc1as_main.cpp -lclangFrontendTool -lclangCodeGen -lclangFrontend -lclangDriver -lclangSerialization -lclangSema -lclangStaticAnalyzerFrontend -lclangStaticAnalyzerCheckers -lclangStaticAnalyzerCore -lclangAnalysis -lclangASTMatchers -lclangAST -lclangParse -lclangAPINotes -lclangBasic -lclangEdit -lclangLex -lclangARCMigrate -lclangRewriteFrontend -lclangRewrite -lclangCrossTU -lclangIndex -lclangToolingCore -lclangExtractAPI -lclangSupport -llldMinGW -llldELF -llldCOFF -llldWasm -llldMachO -llldCommon -lLLVMWindowsManifest -lLLVMXRay -lLLVMLibDriver -lLLVMDlltoolDriver -lLLVMTextAPIBinaryReader -lLLVMCoverage -lLLVMLineEditor -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMX86TargetMCA -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Info -lLLVMWebAssemblyDisassembler -lLLVMWebAssemblyAsmParser -lLLVMWebAssemblyCodeGen -lLLVMWebAssemblyUtils -lLLVMWebAssemblyDesc -lLLVMWebAssemblyInfo -lLLVMVEDisassembler -lLLVMVEAsmParser -lLLVMVECodeGen -lLLVMVEDesc -lLLVMVEInfo -lLLVMSystemZDisassembler -lLLVMSystemZAsmParser -lLLVMSystemZCodeGen -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSparcDisassembler -lLLVMSparcAsmParser -lLLVMSparcCodeGen -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMRISCVTargetMCA -lLLVMRISCVDisassembler -lLLVMRISCVAsmParser -lLLVMRISCVCodeGen -lLLVMRISCVDesc -lLLVMRISCVInfo -lLLVMPowerPCDisassembler -lLLVMPowerPCAsmParser -lLLVMPowerPCCodeGen -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMMSP430Disassembler -lLLVMMSP430AsmParser -lLLVMMSP430CodeGen -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMipsDisassembler -lLLVMMipsAsmParser -lLLVMMipsCodeGen -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMLoongArchDisassembler -lLLVMLoongArchAsmParser -lLLVMLoongArchCodeGen -lLLVMLoongArchDesc -lLLVMLoongArchInfo -lLLVMLanaiDisassembler -lLLVMLanaiCodeGen -lLLVMLanaiAsmParser -lLLVMLanaiDesc -lLLVMLanaiInfo -lLLVMHexagonDisassembler -lLLVMHexagonCodeGen -lLLVMHexagonAsmParser -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMBPFDisassembler -lLLVMBPFAsmParser -lLLVMBPFCodeGen -lLLVMBPFDesc -lLLVMBPFInfo -lLLVMAVRDisassembler -lLLVMAVRAsmParser -lLLVMAVRCodeGen -lLLVMAVRDesc -lLLVMAVRInfo -lLLVMARMDisassembler -lLLVMARMAsmParser -lLLVMARMCodeGen -lLLVMARMDesc -lLLVMARMUtils -lLLVMARMInfo -lLLVMAMDGPUTargetMCA -lLLVMAMDGPUDisassembler -lLLVMAMDGPUAsmParser -lLLVMAMDGPUCodeGen -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMAMDGPUInfo -lLLVMAArch64Disassembler -lLLVMAArch64AsmParser -lLLVMAArch64CodeGen -lLLVMAArch64Desc -lLLVMAArch64Utils -lLLVMAArch64Info -lLLVMOrcDebugging -lLLVMOrcJIT -lLLVMWindowsDriver -lLLVMMCJIT -lLLVMJITLink -lLLVMInterpreter -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMOrcTargetProcess -lLLVMOrcShared -lLLVMDWP -lLLVMDebugInfoLogicalView -lLLVMDebugInfoGSYM -lLLVMOption -lLLVMObjectYAML -lLLVMObjCopy -lLLVMMCA -lLLVMMCDisassembler -lLLVMLTO -lLLVMPasses -lLLVMHipStdPar -lLLVMCFGuard -lLLVMCoroutines -lLLVMipo -lLLVMVectorize -lLLVMLinker -lLLVMInstrumentation -lLLVMFrontendOpenMP -lLLVMFrontendOffloading -lLLVMFrontendOpenACC -lLLVMFrontendHLSL -lLLVMFrontendDriver -lLLVMExtensions -lLLVMDWARFLinkerParallel -lLLVMDWARFLinkerClassic -lLLVMDWARFLinker -lLLVMGlobalISel -lLLVMMIRParser -lLLVMAsmPrinter -lLLVMSelectionDAG -lLLVMCodeGen -lLLVMTarget -lLLVMObjCARCOpts -lLLVMCodeGenTypes -lLLVMIRPrinter -lLLVMInterfaceStub -lLLVMFileCheck -lLLVMFuzzMutate -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMSymbolize -lLLVMDebugInfoBTF -lLLVMDebugInfoPDB -lLLVMDebugInfoMSF -lLLVMDebugInfoDWARF -lLLVMObject -lLLVMTextAPI -lLLVMMCParser -lLLVMIRReader -lLLVMAsmParser -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMBitReader -lLLVMFuzzerCLI -lLLVMCore -lLLVMRemarks -lLLVMBitstreamReader -lLLVMBinaryFormat -lLLVMTargetParser -lLLVMSupport -lLLVMDemangle -lz -lzstd -fstrip -fno-sanitize-thread -OReleaseSafe --dep aro --dep aro_translate_c --dep build_options -Mroot=/home/conda/feedstock_root/build_artifacts/zig_1718997879896/work/conda-zig-source/src/main.zig -Maro=/home/conda/feedstock_root/build_artifacts/zig_1718997879896/work/conda-zig-source/lib/compiler/aro/aro.zig --dep aro -Maro_translate_c=/home/conda/feedstock_root/build_artifacts/zig_1718997879896/work/conda-zig-source/lib/compiler/aro_translate_c.zig -Mbuild_options=/home/conda/feedstock_root/build_artifacts/zig_1718997879896/work/zig-local-cache/c/7050268745eda2764b314241cd6b4167/options.zig -lc++ -lc --cache-dir /home/conda/feedstock_root/build_artifacts/zig_1718997879896/work/zig-local-cache --global-cache-dir /home/conda/feedstock_root/build_artifacts/zig_1718997879896/work/zig-global-cache --name zig -L /home/conda/feedstock_root/build_artifacts/zig_1718997879896/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/lib -I /home/conda/feedstock_root/build_artifacts/zig_1718997879896/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/include -L /home/conda/feedstock_root/build_artifacts/zig_1718997879896/_build_env/lib -I /home/conda/feedstock_root/build_artifacts/zig_1718997879896/_build_env/include --listen=- 

I tried to touch it, but it is not permitted

I use GLIBC 2.28, but install it in both build and target

MementoRC commented 3 months ago

As I was posting this, with desperation, I decided to search in the whole zig_xxxx directory and eventually found it:

build_artifacts/zig_1718999174269/_build_env/x86_64-conda-linux-gnu/sysroot/usr/lib64/libm.so:GROUP ( /lib64/libm.so.6  AS_NEEDED ( /usr/lib64/libmvec_nonshared.a /lib64/libmvec.so.1 ) )
build_artifacts/zig_1718999174269/_build_env/x86_64-conda-linux-gnu/sysroot/usr/lib/libm.so:GROUP ( /lib64/libm.so.6  AS_NEEDED ( /usr/lib64/libmvec_nonshared.a /lib64/libmvec.so.1 ) )
build_artifacts/zig_1718999174269/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/x86_64-conda-linux-gnu/sysroot/usr/lib64/libm.so:GROUP ( /lib64/libm.so.6  AS_NEEDED ( /usr/lib64/libmvec_nonshared.a /lib64/libmvec.so.1 ) )
build_artifacts/zig_1718999174269/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/x86_64-conda-linux-gnu/sysroot/usr/lib/libm.so:GROUP ( /lib64/libm.so.6  AS_NEEDED ( /usr/lib64/libmvec_nonshared.a /lib64/libmvec.so.1 ) )

I don't understand it