Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advice on building newer version #49

Closed
sand7000 opened this issue Nov 3, 2024 · 10 comments
Closed

Advice on building newer version #49

sand7000 opened this issue Nov 3, 2024 · 10 comments

Comments

@sand7000
Copy link

sand7000 commented Nov 3, 2024

I am trying to build the newest commit on master but it is failing. I have been having trouble figuring out which versions of everything to use that won't result in errors. I found this guys blog that gave commits of the different tools that worked together for him:

https://forward-in-code.blogspot.com/2022/03/gnat-llvm.html

and with those commits I was able to build that rather old version by:

  • gnat-llvm at commit 053e755
  • using gnat-community 2012
  • using clang+llvm version 13.0.1 from llvm-project
  • compiling gcc myself and from an old commit f320197 and using the source for that commit in llvm-interface/gcc

this gives me confidence that if I have some guidance on which versions of the different dependencies I will be able to get a new version to compile. Perhaps you could tell me what version of everything you are using in development? Also which branch of llvm-gnat you would recommend using for production?

This is what I am seeing build with:

I used alire releases because gnat-community seems to be eol. I tried gnat-community 2012 but that also failed.

This configuration results in errors. The I overcame the first but it may be causing issues later:

/gnat-llvm/llvm-interface/llvm_wrapper.cc:26:10: fatal error: llvm/Support/AArch64TargetParser.h: No such file or directory
   26 | #include "llvm/Support/AArch64TargetParser.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

I just make a simlink to the correct location:

ln -s /opt/llvm-19/include/llvm/TargetParser/AArch64TargetParser.h /opt/llvm-19/include/llvm/Support/AArch64TargetParser.h

But then I get errors that I don't know how to resolve:

/opt/gcc-custom/bin/gcc -c -x ada -gnatA -g -gnatg -gnata -gnateE -gnatec=/tmp/GPR.228/GNAT-TEMP-000003.TMP -gnatec=/gnat-llvm/llvm-interface/gnat.adc -gnatem=/tmp/GPR.228/GNAT-TEMP-000010.TMP /gnat-llvm/llvm-interface/gnat_src/exp_ch7.adb
/gnat-llvm/llvm-interface/llvm_wrapper.cc: In function 'LLVMBool LLVM_Optimize_Module(llvm::Module*, llvm::TargetMachine*, int, int, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, const char*, const char*, const char*, char**)':
/gnat-llvm/llvm-interface/llvm_wrapper.cc:817:54: error: cannot convert 'bool' to 'llvm::ThinOrFullLTOPhase'
  817 |                                        PrepareForLTO || PrepareForThinLTO);
      |                                        ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
      |                                                      |
      |                                                      bool
In file included from /gnat-llvm/llvm-interface/llvm_wrapper.cc:24:
/opt/llvm-19/include/llvm/Passes/PassBuilder.h:302:45: note:   initializing argument 2 of 'llvm::ModulePassManager llvm::PassBuilder::buildO0DefaultPipeline(llvm::OptimizationLevel, llvm::ThinOrFullLTOPhase)'
  302 |                          ThinOrFullLTOPhase Phase = ThinOrFullLTOPhase::None);
      |                          ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/gnat-llvm/llvm-interface/llvm_wrapper.cc: In function 'llvm::Value* Get_Float_From_Words_And_Exp(llvm::LLVMContext*, llvm::Type*, int, unsigned int, const uint64_t*)':
/gnat-llvm/llvm-interface/llvm_wrapper.cc:843:34: error: 'getNullValue' is not a member of 'llvm::APInt'
  843 |                           APInt::getNullValue (T->getPrimitiveSizeInBits ()));
      |                                  ^~~~~~~~~~~~
/gnat-llvm/llvm-interface/llvm_wrapper.cc: In function 'llvm::AllocaInst* Insert_Alloca_Before(llvm::Type*, llvm::Instruction*)':
/gnat-llvm/llvm-interface/llvm_wrapper.cc:1087:41: warning: 'llvm::InsertPosition::InsertPosition(llvm::Instruction*)' is deprecated: Use BasicBlock::iterators for insertion instead [-Wdeprecated-declarations]
 1087 |  auto Inst = new AllocaInst (Ty, 0, "", Before);
      |                                         ^~~~~~
In file included from /opt/llvm-19/include/llvm/IR/DebugProgramInstruction.h:55,
                 from /opt/llvm-19/include/llvm/IR/BasicBlock.h:23,
                 from /opt/llvm-19/include/llvm/IR/Function.h:27,
                 from /opt/llvm-19/include/llvm/Analysis/AliasAnalysis.h:43,
                 from /gnat-llvm/llvm-interface/llvm_wrapper.cc:7:
/opt/llvm-19/include/llvm/IR/Instruction.h:57:3: note: declared here
   57 |   InsertPosition(Instruction *InsertBefore);
      |   ^~~~~~~~~~~~~~
/gnat-llvm/llvm-interface/llvm_wrapper.cc: In function 'llvm::LoadInst* Insert_Load_Before(llvm::Type*, llvm::Value*, llvm::Instruction*)':
/gnat-llvm/llvm-interface/llvm_wrapper.cc:1096:41: warning: 'llvm::InsertPosition::InsertPosition(llvm::Instruction*)' is deprecated: Use BasicBlock::iterators for insertion instead [-Wdeprecated-declarations]
 1096 |  auto Inst = new LoadInst (Ty, Ptr, "", Before);
      |                                         ^~~~~~
/opt/llvm-19/include/llvm/IR/Instruction.h:57:3: note: declared here
   57 |   InsertPosition(Instruction *InsertBefore);
      |   ^~~~~~~~~~~~~~
/gnat-llvm/llvm-interface/llvm_wrapper.cc: In function 'void Insert_Store_Before(llvm::Value*, llvm::Value*, llvm::Instruction*)':
/gnat-llvm/llvm-interface/llvm_wrapper.cc:1105:39: warning: 'llvm::InsertPosition::InsertPosition(llvm::Instruction*)' is deprecated: Use BasicBlock::iterators for insertion instead [-Wdeprecated-declarations]
 1105 |  auto Inst = new StoreInst (Val, Ptr, Before);
      |                                       ^~~~~~
/opt/llvm-19/include/llvm/IR/Instruction.h:57:3: note: declared here
   57 |   InsertPosition(Instruction *InsertBefore);
      |   ^~~~~~~~~~~~~~
/gnat-llvm/llvm-interface/llvm_wrapper.cc: In function 'char* Get_Features(const char*, const char*, const char*)':
/gnat-llvm/llvm-interface/llvm_wrapper.cc:1270:30: error: 'INVALID' is not a member of 'llvm::AArch64'
 1270 |     if (ArchInfo == AArch64::INVALID) {
      |                              ^~~~~~~
/gnat-llvm/llvm-interface/llvm_wrapper.cc:1275:33: error: request for member 'ArchFeature' in 'ArchInfo', which is of pointer type 'const llvm::AArch64::ArchInfo* const' (maybe you meant to use '->' ?)
 1275 |     Features.push_back(ArchInfo.ArchFeature);
      |                                 ^~~~~~~~~~~
@ArnaudCharlet
Copy link
Member

As explained in README.md, current GNAT LLVM requires LLVM 16, the errors you are seeing are caused by using a too recent LLVM.

@sand7000
Copy link
Author

sand7000 commented Nov 5, 2024

I have tried all versions of llvm from 13 to 19 and none allow the head the master branch to compile for me. Here is the status of my attempts with 16:

Prebuilt llvm 16 from llvm-project was built for ubuntu 18 so I attempted to build in ubuntu 18 docker. Gprbuild 24.0.0-2 won't work because ubuntu 18 has too old glibc:

Makefile:89: recipe for target 'build' failed
make[1]: Leaving directory '/gnat-llvm/llvm-interface'
gprbuild: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by gprbuild)
make[1]: *** [build] Error 1
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 2
The command '/bin/sh -c make' returned a non-zero code: 2

Using gprbuild from ubuntu 18 repos results in a different error:

/usr/bin/gnatgcc -c -x ada -gnatA -g -gnatg -gnata -gnateE -gnatec=/tmp/GNAT-TEMP-000003.TMP -gnatec=/gnat-llvm/llvm-interface/gnat.adc -gnatem=/tmp/GNAT-TEMP-000005.TMP /gnat-llvm/llvm-interface/gnat_src/sinfo.adb
set_targ.adb:925:20: warning: unrecognized pragma "Gnat_Annotate"

   compilation of set_targ.adb failed

gprbuild: *** compilation phase failed

At this point I decided to give up on the prebuilt llvm-pject, switch to ubuntu22 and build llvm-project at version 16 myself (commit 08d094a). I was able to do so and I was able to build gcc but building llvm-gnat fails.

/opt/gnat/bin/ld: /gnat-llvm/llvm-interface/obj/llvm-target_machine.o: in function `llvm__target_machine__create_target_machine_with_abi':
/gnat-llvm/llvm/adainclude/llvm-target_machine.adb:219:(.text+0xd9e): undefined reference to `LLVMCreateTargetMachineWithABI'
collect2: error: ld returned 1 exit status
/opt/gnat/bin/ld: /gnat-llvm/llvm-interface/obj/llvm-target_machine.o: in function `llvm__target_machine__create_target_machine_with_abi':
/gnat-llvm/llvm/adainclude/llvm-target_machine.adb:219:(.text+0xd9e): undefined reference to `LLVMCreateTargetMachineWithABI'
collect2: error: ld returned 1 exit status
   link of gcc_wrapper.adb failed
   link of gnat1drv.adb failed
gprbuild: *** link phase failed
make[1]: *** [Makefile:89: build] Error 4

@ArnaudCharlet
Copy link
Member

ArnaudCharlet commented Nov 6, 2024 via email

@sand7000
Copy link
Author

sand7000 commented Nov 8, 2024

That was the missing piece. I have the HEAD of master building now, thanks!

@ArnaudCharlet
Copy link
Member

ArnaudCharlet commented Nov 8, 2024 via email

@ArnaudCharlet
Copy link
Member

By the way, what version of GNAT/GCC are you using?

@sand7000
Copy link
Author

sand7000 commented Nov 8, 2024

I used:

My build pipeline completed successfully last night. This morning, I tested a sample .adb file using my built llvm-gcc, and assembling it into bitcode with my built llvm-as.

@aytey
Copy link

aytey commented Nov 8, 2024

  • llvm-project commit: 08d094a

Interesting, GitHub doesn't like the short SHA in this case.

The full SHA is:

@aytey
Copy link

aytey commented Nov 8, 2024

@sand7000 : can you give the commit of this repo you used as well?

@sand7000
Copy link
Author

sand7000 commented Nov 9, 2024

@sand7000 : can you give the commit of this repo you used as well?

1515dee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants