From 2dea1fe38dccda7744bd6efdda4d4a163f057c25 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 19 Nov 2014 03:34:17 +0000 Subject: [PATCH] Expose LLVM version string via macro in llvm-config.h, and modify Go bindings to make use of it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222307 91177308-0d34-0410-b5e6-96231b3b80d8 --- autoconf/configure.ac | 1 + bindings/go/build.sh | 3 --- bindings/go/llvm/version.go | 20 +++++++++++++++++++- configure | 5 +++++ include/llvm/Config/config.h.in | 3 +++ include/llvm/Config/llvm-config.h.cmake | 3 +++ include/llvm/Config/llvm-config.h.in | 3 +++ 7 files changed, 34 insertions(+), 4 deletions(-) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 31d462b424d..ca6d710e7d9 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -42,6 +42,7 @@ LLVM_VERSION_SUFFIX=svn AC_DEFINE_UNQUOTED([LLVM_VERSION_MAJOR], $LLVM_VERSION_MAJOR, [Major version of the LLVM API]) AC_DEFINE_UNQUOTED([LLVM_VERSION_MINOR], $LLVM_VERSION_MINOR, [Minor version of the LLVM API]) AC_DEFINE_UNQUOTED([LLVM_VERSION_PATCH], $LLVM_VERSION_PATCH, [Patch version of the LLVM API]) +AC_DEFINE_UNQUOTED([LLVM_VERSION_STRING], "$PACKAGE_VERSION", [LLVM version string]) AC_SUBST([LLVM_VERSION_MAJOR]) AC_SUBST([LLVM_VERSION_MINOR]) diff --git a/bindings/go/build.sh b/bindings/go/build.sh index 3f0be00f808..3177852aeba 100755 --- a/bindings/go/build.sh +++ b/bindings/go/build.sh @@ -26,6 +26,3 @@ else fi $llvm_go print-config > $gollvmdir/llvm_config.go - -llvm_version="$($llvm_config --version)" -printf "package llvm\n\nconst Version = \"%s\"\n" "$llvm_version" > $gollvmdir/version.go diff --git a/bindings/go/llvm/version.go b/bindings/go/llvm/version.go index 59385838faa..d0623be97a9 100644 --- a/bindings/go/llvm/version.go +++ b/bindings/go/llvm/version.go @@ -1,3 +1,21 @@ +//===- version.go - LLVM version info -------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines LLVM version information. +// +//===----------------------------------------------------------------------===// + package llvm -const Version = "3.6.0svn" +/* +#include "llvm/Config/llvm-config.h" +*/ +import "C" + +const Version = C.LLVM_VERSION_STRING diff --git a/configure b/configure index 597d119c2a2..4bfc2e595d3 100755 --- a/configure +++ b/configure @@ -1941,6 +1941,11 @@ cat >>confdefs.h <<_ACEOF _ACEOF +cat >>confdefs.h <<_ACEOF +#define LLVM_VERSION_STRING "$PACKAGE_VERSION" +_ACEOF + + diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in index beed1182c3f..8fcf14548f8 100644 --- a/include/llvm/Config/config.h.in +++ b/include/llvm/Config/config.h.in @@ -543,6 +543,9 @@ /* Patch version of the LLVM API */ #undef LLVM_VERSION_PATCH +/* LLVM version string */ +#undef LLVM_VERSION_STRING + /* The shared library extension */ #undef LTDL_SHLIB_EXT diff --git a/include/llvm/Config/llvm-config.h.cmake b/include/llvm/Config/llvm-config.h.cmake index 58111644ffa..77201e6330b 100644 --- a/include/llvm/Config/llvm-config.h.cmake +++ b/include/llvm/Config/llvm-config.h.cmake @@ -92,6 +92,9 @@ /* Minor version of the LLVM API */ #cmakedefine LLVM_VERSION_MINOR ${LLVM_VERSION_MINOR} +/* LLVM version string */ +#define LLVM_VERSION_STRING "${PACKAGE_VERSION}" + /* Define if we link Polly to the tools */ #cmakedefine LINK_POLLY_INTO_TOOLS diff --git a/include/llvm/Config/llvm-config.h.in b/include/llvm/Config/llvm-config.h.in index 5656240eb12..2d6add71a4e 100644 --- a/include/llvm/Config/llvm-config.h.in +++ b/include/llvm/Config/llvm-config.h.in @@ -92,4 +92,7 @@ /* Minor version of the LLVM API */ #undef LLVM_VERSION_MINOR +/* LLVM version string */ +#undef LLVM_VERSION_STRING + #endif