'Building rust with LLVM Fork

Following the instructions here, I have tried building rust with a fork of LLVM which has a back-end for a new target.

I have:

  1. Recursively cloned the Rust repository
  2. Edited config.toml to add the new target,
  3. Replaced with custom LLVM Fork by:
    cd src/llvm-project
    git remote add custom-fork [link to custom fork]
    git checkout custom-fork/branch
    
    then committing these changes.
  4. Build rust with x.py build.

The LLVM fork has been rebased onto LLVM 13.0

cargo:warning=llvm-wrapper/PassWrapper.cpp: In function ‘void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef)’:
  cargo:warning=llvm-wrapper/PassWrapper.cpp:502:57: error: ‘const class llvm::MCSubtargetInfo’ has no member named ‘getCPUTable’
  cargo:warning=  502 |   const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getCPUTable();
  cargo:warning=      |                                                         ^~~~~~~~~~~
  cargo:warning=llvm-wrapper/PassWrapper.cpp: In function ‘size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef)’:
  cargo:warning=llvm-wrapper/PassWrapper.cpp:519:58: error: ‘const class llvm::MCSubtargetInfo’ has no member named ‘getFeatureTable’; did you mean ‘getFeatureBits’?
  cargo:warning=  519 |   const ArrayRef<SubtargetFeatureKV> FeatTable = MCInfo->getFeatureTable();
  cargo:warning=      |                                                          ^~~~~~~~~~~~~~~
  cargo:warning=      |                                                          getFeatureBits

  cargo:warning=llvm-wrapper/PassWrapper.cpp: In function ‘void LLVMRustGetTargetFeature(LLVMTargetMachineRef, size_t, const char**, const char**)’:
  cargo:warning=llvm-wrapper/PassWrapper.cpp:527:58: error: ‘const class llvm::MCSubtargetInfo’ has no member named ‘getFeatureTable’; did you mean ‘getFeatureBits’?
  cargo:warning=  527 |   const ArrayRef<SubtargetFeatureKV> FeatTable = MCInfo->getFeatureTable();
  cargo:warning=      |                                                          ^~~~~~~~~~~~~~~
  cargo:warning=      |                                                          getFeatureBits
  exit status: 1

  --- stderr

This same error occurs when using the upstream LLVM; I'm unsure whether this is due to a patch that has been applied to the rust LLVM fork that needs to be ported over, or if I just need to change something in the llvm-wrapper.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source