AdaCore / AdaCore/gnat-llvm

Failure to build against LLVM-21

Open
#63 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ada
Stars
239
Forks
32
PR merge metrics
No merged PRs in 30d

Description

I saw that LLLVM-21 support had been added, so I tried building against it. I used the built in script to build LLVM 21 with all targets enabled, this is the diff of what I modified

diff --git a/llvm/Makefile b/llvm/Makefile
index f05c33b..e69d957 100644
--- a/llvm/Makefile
+++ b/llvm/Makefile
@@ -4,14 +4,14 @@
 # PATH.
 
 PWD:=$(shell pwd)
-LLVM_RELEASE=19.1.7
+LLVM_RELEASE=21.1.8
 LLVM_INSTALL_DIR=$(PWD)/install
 LLVM_SRC_DIR=llvm-project-$(LLVM_RELEASE).src
 DL=wget
 LLVM_SRC_FNAME=$(LLVM_SRC_DIR).tar.xz
 LLVM_RELEASE_URL=https://github.com/llvm/llvm-project/releases/download/llvmorg-$(LLVM_RELEASE)
 LLVM_SRC_LINK=$(LLVM_RELEASE_URL)/$(LLVM_SRC_FNAME)
-LLVM_TARGETS=X86
+LLVM_TARGETS=all
 # Linking LLVM libraries and binaries requires lots of RAM and is a common cause
 # for out-of-memory errors. Restricting the build system to a single link job at
 # a time doesn't affect the build time significantly but protects us from those

I followed the build instructions and I cloned the llvm-bindings as indicated but used the llvm-21 branch. LLVM built just fine. However, GNAT-LLVM fails at the very end with the following issue:

⦗OSS CAD Suite⦘ 📦[fernando@tumbleweed gnat-llvm21]$ make -j1
make -C llvm-interface build gnatlib-automated
make[1]: Entering directory '/home/fernando/Build/gnat-llvm21/llvm-interface'
mkdir -p obj obj-tools/libgnat bin gnat_src/vast
for f in `cd /home/fernando/Build/gnat-llvm21/llvm-interface/gnat_src; ls gen_il*.ad? xutil.ad? *-tmpl xoscons.adb xsnamest.adb`; \
do \
  cp -p /home/fernando/Build/gnat-llvm21/llvm-interface/gnat_src/$f obj-tools; \
done
cd obj-tools && gnatmake -q -j0 xoscons xsnamest && ./xsnamest && \
mv -f snames.ns ../obj/snames.ads && mv -f snames.nb ../obj/snames.adb && \
gnatmake -g -q -j0 gen_il-main.adb -I../obj -Ilibgnat && ./gen_il-main && \
mv -f nmake.adb nmake.ads seinfo.ads sinfo-nodes.ads sinfo-nodes.adb einfo-entities.ads einfo-entities.adb ../obj
for f in ../link.c s-pehage.adb s-pehage.ads s-rident.ads s-utf_32.adb s-utf_32.ads gnat.ads g-byorma.adb g-casuti.adb g-casuti.ads g-comlin.adb g-comlin.ads g-ctrl_c.adb g-ctrl_c.ads g-dirope.adb g-dynhta.adb g-dynhta.ads g-graphs.adb g-graphs.ads g-hesora.adb g-htable.adb g-io.adb g-io_aux.adb g-io_aux.ads g-lists.adb g-lists.ads g-os_lib.adb g-os_lib.ads g-regexp.ads g-sets.adb g-sets.ads g-spchge.adb g-speche.adb g-string.ads g-u3spch.adb; do \
  ln -sf /home/fernando/Build/gnat-llvm21/llvm-interface/gnat_src/libgnat/$f obj; \
done
./check_for_LLVM_aliasing_bug.sh
using LLVM with the aliasing bug, will pessimize slightly the optimized code
obj/gnatllvm-aliasing-params.ads is unchanged
./check_for_llvm_apis.sh "/home/fernando/Build/gnat-llvm21/llvm-interface/../llvm/llvm-obj/bin/llvm-config"
obj/gnat-llvm-config.h is unchanged
./configure_default_target.sh "x86_64-suse-linux"
obj/options-target.ads is unchanged
gprbuild -v -n -XLLVM_Version=21 -x -Pgnat_llvm -j0 \
  -largs -L/home/fernando/Build/gnat-llvm21/llvm/llvm-obj/lib  -lLLVMWindowsManifest -lLLVMXRay -lLLVMLibDriver -lLLVMDlltoolDriver -lLLVMTelemetry -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 -lLLVMSPIRVCodeGen -lLLVMSPIRVDesc -lLLVMSPIRVInfo -lLLVMSPIRVAnalysis -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 -lLLVMDWARFCFIChecker -lLLVMDebugInfoLogicalView -lLLVMOption -lLLVMObjCopy -lLLVMMCA -lLLVMMCDisassembler -lLLVMLTO -lLLVMPasses -lLLVMHipStdPar -lLLVMCFGuard -lLLVMCoroutines -lLLVMipo -lLLVMVectorize -lLLVMSandboxIR -lLLVMLinker -lLLVMFrontendOpenMP -lLLVMFrontendOffloading -lLLVMObjectYAML -lLLVMFrontendOpenACC -lLLVMFrontendHLSL -lLLVMFrontendDriver -lLLVMInstrumentation -lLLVMFrontendDirective -lLLVMFrontendAtomic -lLLVMExtensions -lLLVMDWARFLinkerParallel -lLLVMDWARFLinkerClassic -lLLVMDWARFLinker -lLLVMGlobalISel -lLLVMMIRParser -lLLVMAsmPrinter -lLLVMSelectionDAG -lLLVMCodeGen -lLLVMTarget -lLLVMObjCARCOpts -lLLVMCodeGenTypes -lLLVMCGData -lLLVMIRPrinter -lLLVMInterfaceStub -lLLVMFileCheck -lLLVMFuzzMutate -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMSymbolize -lLLVMDebugInfoBTF -lLLVMDebugInfoPDB -lLLVMDebugInfoMSF -lLLVMDebugInfoCodeView -lLLVMDebugInfoGSYM -lLLVMDebugInfoDWARF -lLLVMDebugInfoDWARFLowLevel -lLLVMObject -lLLVMTextAPI -lLLVMMCParser -lLLVMIRReader -lLLVMAsmParser -lLLVMMC -lLLVMBitReader -lLLVMFuzzerCLI -lLLVMCore -lLLVMRemarks -lLLVMBitstreamReader -lLLVMBinaryFormat -lLLVMTargetParser -lLLVMTableGen -lLLVMSupport -lLLVMDemangle -rdynamic -cargs:c++ -I/home/fernando/Build/gnat-llvm21/llvm/llvm-project-21.1.8.src/llvm/include -I/home/fernando/Build/gnat-llvm21/llvm/llvm-obj/include -std=c++17   -fno-exceptions -funwind-tables -fno-rtti -D_GNU_SOURCE -D_DEBUG -D_GLIBCXX_ASSERTIONS -DEXPERIMENTAL_KEY_INSTRUCTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS  -I/home/fernando/Build/gnat-llvm21/llvm-interface/../llvm/llvm-obj/tools/clang/include -I/home/fernando/Build/gnat-llvm21/llvm/llvm-project-21.1.8.src/clang/include -I.
Changing to object directory of "Gnat_LLVM": "/home/fernando/Build/gnat-llvm21/llvm-interface/obj/"
/home/fernando/bin/gnat-x86_64-linux-15.2.0-1/bin/g++ gnat1drv.o /tmp/GPR.41311/GNAT-TEMP-000003.TMP libgnat_llvm.a -static-libstdc++ -lclangBasic -L/home/fernando/Build/gnat-llvm21/llvm/llvm-obj/lib -lLLVMWindowsManifest -lLLVMXRay -lLLVMLibDriver -lLLVMDlltoolDriver -lLLVMTelemetry -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 -lLLVMSPIRVCodeGen -lLLVMSPIRVDesc -lLLVMSPIRVInfo -lLLVMSPIRVAnalysis -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 -lLLVMDWARFCFIChecker -lLLVMDebugInfoLogicalView -lLLVMOption -lLLVMObjCopy -lLLVMMCA -lLLVMMCDisassembler -lLLVMLTO -lLLVMPasses -lLLVMHipStdPar -lLLVMCFGuard -lLLVMCoroutines -lLLVMipo -lLLVMVectorize -lLLVMSandboxIR -lLLVMLinker -lLLVMFrontendOpenMP -lLLVMFrontendOffloading -lLLVMObjectYAML -lLLVMFrontendOpenACC -lLLVMFrontendHLSL -lLLVMFrontendDriver -lLLVMInstrumentation -lLLVMFrontendDirective -lLLVMFrontendAtomic -lLLVMExtensions -lLLVMDWARFLinkerParallel -lLLVMDWARFLinkerClassic -lLLVMDWARFLinker -lLLVMGlobalISel -lLLVMMIRParser -lLLVMAsmPrinter -lLLVMSelectionDAG -lLLVMCodeGen -lLLVMTarget -lLLVMObjCARCOpts -lLLVMCodeGenTypes -lLLVMCGData -lLLVMIRPrinter -lLLVMInterfaceStub -lLLVMFileCheck -lLLVMFuzzMutate -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMSymbolize -lLLVMDebugInfoBTF -lLLVMDebugInfoPDB -lLLVMDebugInfoMSF -lLLVMDebugInfoCodeView -lLLVMDebugInfoGSYM -lLLVMDebugInfoDWARF -lLLVMDebugInfoDWARFLowLevel -lLLVMObject -lLLVMTextAPI -lLLVMMCParser -lLLVMIRReader -lLLVMAsmParser -lLLVMMC -lLLVMBitReader -lLLVMFuzzerCLI -lLLVMCore -lLLVMRemarks -lLLVMBitstreamReader -lLLVMBinaryFormat -lLLVMTargetParser -lLLVMTableGen -lLLVMSupport -lLLVMDemangle -rdynamic -L/home/fernando/Build/gnat-llvm21/llvm-interface/obj/ -L/home/fernando/Build/gnat-llvm21/llvm-interface/obj/ -L/home/fernando/bin/gnat-x86_64-linux-15.2.0-1/lib/gcc/x86_64-pc-linux-gnu/15.2.0/adalib/ /home/fernando/bin/gnat-x86_64-linux-15.2.0-1/lib/gcc/x86_64-pc-linux-gnu/15.2.0/adalib/libgnat.a -ldl -Wl,-rpath-link,/home/fernando/bin/gnat-x86_64-linux-15.2.0-1/lib/gcc/x86_64-pc-linux-gnu/15.2.0//adalib -static-libgcc -Wl,-z,origin,-rpath,$ORIGIN/../..//llvm/llvm-obj/lib:$ORIGIN/..//obj:$ORIGIN/../../../..//bin/gnat-x86_64-linux-15.2.0-1/lib/gcc/x86_64-pc-linux-gnu/15.2.0/adalib -o /home/fernando/Build/gnat-llvm21/llvm-interface/bin//llvm-gnat1
gprbuild: "llvm-gcc" up to date
/home/fernando/bin/gnat-x86_64-linux-15.2.0-1/bin/../lib/gcc/x86_64-pc-linux-gnu/15.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /home/fernando/Build/gnat-llvm21/llvm-interface/obj/osint-c.o: warning: relocation against `osint__B86s' in read-only section `.text'
/home/fernando/bin/gnat-x86_64-linux-15.2.0-1/bin/../lib/gcc/x86_64-pc-linux-gnu/15.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /home/fernando/Build/gnat-llvm21/llvm-interface/obj/osint-c.o: in function `osint__c__set_output_object_file_name':
/home/fernando/Build/gnat-llvm21/llvm-interface/gnat_src/osint-c.adb:474:(.text+0x29bc): undefined reference to `osint__B86s'
/home/fernando/bin/gnat-x86_64-linux-15.2.0-1/bin/../lib/gcc/x86_64-pc-linux-gnu/15.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
gprbuild: link of gnat1drv.adb failed
make[1]: *** [Makefile:93: build] Error 4
make[1]: Leaving directory '/home/fernando/Build/gnat-llvm21/llvm-interface'
make: *** [Makefile:2: all] Error 2

I am using the Alire provided compilers and GPRbuild. There seems to be an issue with PIE and osint which sound that either GCC/GNAT sources may have an issue or the bindings are not fully working...

I have no solution for this, so I am reporting the issue with hopes that it may help you, the developers, to maybe find something that is not working as intended.

Best regards,
Fer

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with llvm/Makefile and the LLVM-21 build instructions, then reproduce the failure with the shown make command and inspect the final linker output. Done means the GNAT-LLVM build completes successfully against LLVM 21 with the configured targets.

Written by the indexing model from the issue text.

Assessment

Domain
build-system, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.