Adding new build target (XCore)

I want to add a new target to the Rust Compiler, XCore (xcore-unknown-unknown).

The LLVM backend for this has not yet been upstreamed, so I’ve followed the instructions here to build using my own fork of LLVM (rebased onto LLVM 13.0) Adding a new target - Guide to Rustc Development

However, the build fails with this error:

  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

I saw some forum posts from people who got this error due to an out-of-date LLVM, but I tried building it with the latest release of the upstream LLVM and got the same error.

Is this a case of needing to patch my LLVM fork with the same changes which were made to the rust fork, or is this something in llvm-wrapper that needs to be changed?