Building gnat-llvm

Greetings,

I am following the steps in the GitHub - AdaCore/gnat-llvm: LLVM based GNAT compiler page and trying to build gnat-llvm in Linux but I keep running into errors during the “make” step.

Error: “compilation of llvm_wrapper.cc failed”

I am wondering if I need to use a particular version combination of LLVM, gcc, and gnat-llvm to be able to build successfully.

I am currently using the following versions:

  • llvm-14
  • gcc 11.4.0
  • gnat-llvm 25.1

Does anybody know of a combination that works? Or suggestions for building this project?

Thanks,
N

The repo’s README says to use LLVM/Clang 16.0.x.

The last time I tried was in 2022.

As Simon says, you need the right versions of the different components in order to build GNAT-LLVM. There is little likelihood that you will get it to build without using the versions indicated in the README.

You can always roll-back and user a checkout that supports your tech stack. However, I would not recommend you do this as there are several improvements in the newer versions of GNAT-LLVM.

Best,
Fer

Last time I’ve built it with llvm_wrapper2.patch from adawebpack/patches at master · godunko/adawebpack · GitHub. I used gcc 14.1.0 and gnat-llvm 66e36d9. For AdaWebPack you need also gnat-llvm.patch.

1 Like

I am also trying to build gnat-llvm on MacOS 15.1.1 with clang+llvm-16.0.5-arm64-apple-darwin22.0. I get the following error; what is wrong here?

Undefined symbols for architecture arm64:
  "_LLVMCreateTargetMachineWithABI", referenced from:
      _llvm__target_machine__create_target_machine_with_abi in llvm-target_machine.o
  "std::__1::error_code::message() const", referenced from:
      _LLVMTargetMachineEmitToFile in libLLVMTarget.a[6](TargetMachineC.cpp.o)
      llvm::sampleprof::SampleProfileReaderBinary::readString() in libLLVMProfileData.a[10](SampleProfReader.cpp.o)
      llvm::ErrorOr<unsigned long long> llvm::sampleprof::SampleProfileReaderBinary::readUnencodedNumber<unsigned long long>() in libLLVMProfileData.a[10](SampleProfReader.cpp.o)

After applying the llvm_wrapper2.patch from Max, I get the following error:

Undefined symbols for architecture arm64:
  "std::__1::error_code::message() const", referenced from:
      _LLVMTargetMachineEmitToFile in libLLVMTarget.a[6](TargetMachineC.cpp.o)
      llvm::sampleprof::SampleProfileReaderBinary::readString() in libLLVMProfileData.a[10](SampleProfReader.cpp.o)
      llvm::ErrorOr<unsigned long long> llvm::sampleprof::SampleProfileReaderBinary::readUnencodedNumber<unsigned long long>() in libLLVMProfileData.a[10](SampleProfReader.cpp.o)
      llvm::ErrorOr<unsigned long long> llvm::sampleprof::SampleProfileReaderBinary::readNumber<unsigned long long>() in libLLVMProfileData.a[10](SampleProfReader.cpp.o)
...

or

Undefined symbols for architecture arm64:
  "llvm::PassPlugin::Load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)", referenced from:
      _LLVM_Optimize_Module in libgnat_llvm.a[4](llvm_wrapper.o)
  "llvm::PassBuilder::PassBuilder(llvm::TargetMachine*, llvm::PipelineTuningOptions, std::optional<llvm::PGOOptions>, llvm::PassInstrumentationCallbacks*)", referenced from:
      _LLVM_Optimize_Module in libgnat_llvm.a[4](llvm_wrapper.o)
...

I needed to build GNAT-LLVM recently. After I worked my way through the process, I created a Github Workflow to build GNAT-LLVM for Ubuntu 22.04 and Ubuntu 24.04. Hopefully that will provide the additional breadcrumbs you need to successfully build it. Checkout the GitHub Actions tab in the repo for the build logs, if desired.

1 Like