Benjamin Kramer
2009-May-18 12:56 UTC
[LLVMdev] [PATCH] llvm-config: add svn revision to --version
At the moment llvm-config outputs "2.6svn" if llvm is build from trunk $ llvm-config --version 2.6svn Some external projects (built out-of-tree) need to know which revision of llvm is installed. LDC currently asks llvm-config --src-root for the source directory and then parses svn info's output to get the revision number. This requires the user to keep the llvm source tree around even if it is not needed to build ldc. 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 or, if it couldn't find svn during the build: $ llvm-config --version 2.6-svn -------------- next part -------------- A non-text attachment was scrubbed... Name: revversion.patch Type: application/octet-stream Size: 1846 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090518/ebd8d507/attachment.obj> -------------- next part --------------
Frits van Bommel
2009-May-18 14:05 UTC
[LLVMdev] [PATCH] llvm-config: add svn revision to --version
Benjamin Kramer wrote:> At the moment llvm-config outputs "2.6svn" if llvm is build from trunk > > $ llvm-config --version > 2.6svn > > Some external projects (built out-of-tree) need to know which revision > of llvm is installed. LDC currently asks llvm-config --src-root for the > source directory and then parses svn info's output to get the revision > number. This requires the user to keep the llvm source tree around even > if it is not needed to build ldc.Not technically true; it's not *required*. However, if this isn't done you need to set it manually in the cmake configuration...> The attached patch modifies the llvm build system (both autotools and > cmake) to write the revision into PACKAGE_VERSION: > > $ llvm-config --version > 2.6-71981I 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).
Anton Korobeynikov
2009-May-18 14:51 UTC
[LLVMdev] [PATCH] llvm-config: add svn revision to --version
> 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).Why don't introduce some another option for it? E.g. llvm-config --revision ? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
Benjamin Kramer
2009-May-18 14:56 UTC
[LLVMdev] [PATCH] llvm-config: add svn revision to --version
Frits van Bommel wrote:> 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).Here is another patch which adds a new option to llvm-config: $ llvm-config --revision or, if the build script couldn't find svn: $ llvm-config --revision 0 I think this is also a safer approach, it won't break anything that relies on the current llvm-config behavior. -------------- next part -------------- A non-text attachment was scrubbed... Name: revv2.patch Type: application/octet-stream Size: 2959 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090518/dd604bf2/attachment.obj> -------------- next part --------------
Xerxes RĂ„nby
2009-May-18 15:03 UTC
[LLVMdev] [PATCH] llvm-config: add svn revision to --version
Frits van Bommel skrev:> Benjamin Kramer wrote: > >> At the moment llvm-config outputs "2.6svn" if llvm is build from trunk >> >> $ llvm-config --version >> 2.6svn >> >> Some external projects (built out-of-tree) need to know which revision >> of llvm is installed. LDC currently asks llvm-config --src-root for the >> source directory and then parses svn info's output to get the revision >> number. This requires the user to keep the llvm source tree around even >> if it is not needed to build ldc. >> > > Not technically true; it's not *required*. However, if this isn't done you need > to set it manually in the cmake configuration... > > >> 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 cheers Xerxes
Maybe Matching Threads
- [LLVMdev] [PATCH] llvm-config: add svn revision to --version
- [LLVMdev] [PATCH] llvm-config: add svn revision to --version
- [LLVMdev] [PATCH] llvm-config: add svn revision to --version
- [LLVMdev] [PATCH] llvm-config: add svn revision to --version
- [LLVMdev] Please update LDC references on LLVM website