[LLVMdev] [PATCH] llvm-config: add svn revision to --version

Török Edwin edwintorok at gmail.com
Mon May 18 10:13:27 PDT 2009


On 2009-05-18 20:06, Frits van Bommel wrote:
> Xerxes Rånby wrote:
>   
>> Frits van Bommel skrev:
>>     
>>> Benjamin Kramer wrote:
>>>       
>>>> The attached patch modifies the llvm build system (both autotools and 
>>>> cmake) to write the revision into PACKAGE_VERSION:
>>>>
>>>> $ llvm-config --version
>>>> 2.6-71981
>>>>     
>>>>         
>>> I don't think that's enough for LDC; we want to be able to compare the version 
>>> with #if, so we need it to produce something like '#define LLVM_REV 71981' (i.e. 
>>> a raw integer, not a string).
>>>   
>>>       
>> When we build Icedtea shark JIT we use the llvm-config version to make 
>> the icedtea code compatible with api changes in llvm.
>> I belive you are trying to do something similarwith LDC. This can be 
>> done without changing the llvm codebase.
>>
>> I suggest the following:
>> add to the LDC configure.
>>
>> LLVM_CFLAGS="$LLVM_CFLAGS -DLLVM_VERSION=`$LLVM_CONFIG --version | sed 's/\.//;s/svn.*//'`"
>>
>> this will take the llvm-config --version output and truncates the versionnumber from
>>
>> 2.6svn to 26
>>
>> now the LLVM_VERSION can be used in your source code like this:
>>
>> #if LLVM_VERSION >= 26
>> /*llvm 2.6 and above compatible code*/
>> #endif
>>
>> #if LLVM_VERSION >= 25
>> // etc...
>> #endif
>>     
>
> That's not precise enough. API changes are introduced in svn all the time, and 
> bugs are fixed (obsoleting workarounds). We currently test for 5 different trunk 
> revisions after 2.5.
>
> Though I suppose a similar technique could be used with the original version of 
> the patch, sed'ing out the revision nr. It'd certainly be less error-prone than 
> the current approach.

I think you don't need to support all trunk revisions.
People using trunk could be told to either update to a certain revision,
or stick to a released version.

This should suffice:

#if LLVM_VERSION >= 25
....
#endif

#if LLVM_VERSION == 26
#if LLVM_REVISION < MINIMUM_THAT_CONTAINS_ALLYOUNEED
#error "Please update to SVN rXYZ"
#else
//code for SVN API
#endif

Best regards,
--Edwin










More information about the llvm-dev mailing list