[PATCH] D115818: Add LLVM_VERSION_SUFFIX to llvm-config.h.cmake

Chuck Atkins via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 17 08:18:39 PST 2021


chuckatkins added a comment.

The motivation for this patch btw is to allow a consumer to distinguish between release and development versions.  Since the LLVM version numbers are incremented as soon as development of that version starts then there's not currently a way in the consuming C++ code to depend on the actual release.  For example, in the Mesa llvmpipe driver the following can still fail when using a pre-release commit of llvm since `setOverrideStackAlignment` was added during the 13.0.0 development cycle and can't be guaranteed available until the 13.0.0 release:

  extern "C" void
  lp_set_module_stack_alignment_override(LLVMModuleRef MRef, unsigned align)
  {
  #if LLVM_VERSION_MAJOR >= 13
     llvm::Module *M = llvm::unwrap(MRef);
     M->setOverrideStackAlignment(align);
  #endif
  }

Using the `LLVM_VERSION_SUFFIX` to distinguish between release and development versions allows this to be changed to depend on the `13.0.0` release or newer via `if (LLVM_VERSION = 13.0.0 release) or (LLVM_VERSION > 13.0.0)`:

  extern "C" void
  lp_set_module_stack_alignment_override(LLVMModuleRef MRef, unsigned align)
  {
  #if (LLVM_VERSION_MAJOR == 13 && LLVM_VERSION_MINOR == 0 && LLVM_VERSION_PATCH == 0 && !defined(LLVM_VERSION_SUFFIX)) || \
      (LLVM_VERSION_MAJOR >= 13 && LLVM_VERSION_MINOR >= 0 && LLVM_VERSION_PATCH > 0)
     llvm::Module *M = llvm::unwrap(MRef);
     M->setOverrideStackAlignment(align);
  #endif
  }


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115818/new/

https://reviews.llvm.org/D115818



More information about the llvm-commits mailing list