Thread overview
determine ldc version in static if or version?
Apr 01, 2020
Adam D. Ruppe
Apr 02, 2020
Nicholas Wilson
Apr 02, 2020
Adam D. Ruppe
Apr 02, 2020
Arine
April 01, 2020
I want to do like

static if(__LDC_VERSION == 1.19) {
  // declaration
}


All the tricks I know that I have tried so far give the dmd numbers. Perhaps I could use that to identify a particular version as a hack, but I specifically am curious about the ldc version because of a change they made there independently of D.

Is there something I don't know about?
April 02, 2020
On Wednesday, 1 April 2020 at 21:19:54 UTC, Adam D. Ruppe wrote:
> I want to do like
>
> static if(__LDC_VERSION == 1.19) {
>   // declaration
> }
>
>
> All the tricks I know that I have tried so far give the dmd numbers. Perhaps I could use that to identify a particular version as a hack, but I specifically am curious about the ldc version because of a change they made there independently of D.
>
> Is there something I don't know about?

https://github.com/ldc-developers/druntime/blob/ldc/src/ldc/intrinsics.di#L22-L34

     version (LDC_LLVM_309)  enum LLVM_version =  309;
else version (LDC_LLVM_400)  enum LLVM_version =  400;
else version (LDC_LLVM_500)  enum LLVM_version =  500;
else version (LDC_LLVM_600)  enum LLVM_version =  600;
else version (LDC_LLVM_700)  enum LLVM_version =  700;
else version (LDC_LLVM_701)  enum LLVM_version =  701;
else version (LDC_LLVM_800)  enum LLVM_version =  800;
else version (LDC_LLVM_900)  enum LLVM_version =  900;
else version (LDC_LLVM_1000) enum LLVM_version = 1000;
else version (LDC_LLVM_1100) enum LLVM_version = 1100;
else static assert(false, "LDC LLVM version not supported");

enum LLVM_atleast(int major) = (LLVM_version >= major * 100);
April 02, 2020
On Thursday, 2 April 2020 at 01:27:26 UTC, Nicholas Wilson wrote:
> https://github.com/ldc-developers/druntime/blob/ldc/src/ldc/intrinsics.di#L22-L34

ah excellent that will do. thanks!

April 02, 2020
On Thursday, 2 April 2020 at 01:35:42 UTC, Adam D. Ruppe wrote:
> On Thursday, 2 April 2020 at 01:27:26 UTC, Nicholas Wilson wrote:
>> https://github.com/ldc-developers/druntime/blob/ldc/src/ldc/intrinsics.di#L22-L34
>
> ah excellent that will do. thanks!

Not sure if that is what you are looking for. You can build the latest LDC with LLVM 6.0, which would have the version be 600. So for different distros they might just the version of LLVM that's already installed.

Unless the change you trying to detect is caused by a specific version of LLVM?