annotate revisions.pl.in @ 1650:40bd4a0d4870

Update to work with LLVM 2.7. Removed use of dyn_cast, llvm no compiles without exceptions and rtti by default. We do need exceptions for the libconfig stuff, but rtti isn't necessary (anymore). Debug info needs to be rewritten, as in LLVM 2.7 the format has completely changed. To have something to look at while rewriting, the old code has been wrapped inside #ifndef DISABLE_DEBUG_INFO , this means that you have to define this to compile at the moment. Updated tango 0.99.9 patch to include updated EH runtime code, which is needed for LLVM 2.7 as well.
author Tomas Lindquist Olsen
date Wed, 19 May 2010 12:42:32 +0200
parents 230765fc82f4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
853
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
1 #!/usr/bin/perl
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
2
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
3 use strict;
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
4 use warnings;
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
5 use File::stat;
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
6 use Time::localtime;
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
7
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
8 my $llvm_src = `perl @LLVM_CONFIG@ --src-root`;
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
9
1290
c86a629f24dd Force SVN to C locale
Benjamin Kramer <benny.kra@gmail.com>
parents: 1123
diff changeset
10 my $svn_info = `LC_ALL=C svn info $llvm_src 2>/dev/null`;
1112
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
11
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
12 my $extra_includes = "";
1064
f0b6549055ab Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Frits van Bommel <fvbommel wxs.nl>
parents: 972
diff changeset
13 my $llvm_rev_str;
f0b6549055ab Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Frits van Bommel <fvbommel wxs.nl>
parents: 972
diff changeset
14 my $llvm_rev_nr;
1112
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
15 my $llvm_date = "";
853
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
16
1112
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
17 if ($svn_info =~ /^URL:.*\/trunk\s*$/m && $svn_info =~ /^Last Changed Rev:\s*(\d+)\s*/m) {
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
18 $llvm_rev_str = qq!"LLVM trunk rev. $1"!;
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
19 $llvm_rev_nr = $1;
853
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
20 } else {
1112
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
21 # Either non-trunk or 'svn info' didn't report "Last Changed Rev".
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
22 $extra_includes = qq!#include "llvm/Config/config.h"!;
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
23 $llvm_rev_str = "PACKAGE_STRING";
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
24 # Assume latest release, so < any version we should be testing for.
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
25 $llvm_rev_nr = 0;
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
26 }
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
27
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
28 # Use SVN date even if non-trunk:
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
29 if ($svn_info =~ /^Last Changed Date: ([^(]*?)\s*(\(|$)/m) {
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
30 $llvm_date = qq!" ($1)"!;
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
31 } else {
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
32 # Otherwise, try to get it from the libdir
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
33 my $llvm_lib = `perl @LLVM_CONFIG@ --libdir`;
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
34 $llvm_lib =~ s/\s+$//;
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
35 if (-d $llvm_lib) {
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
36 my $mod_time = ctime(stat($llvm_lib)->mtime);
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
37 $llvm_date = qq!" ($mod_time)"!;
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
38 }
853
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
39 }
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
40
972
d66ab756c75b Change the way the version is printed (more verbose, with short hash)
Frits van Bommel <fvbommel wxs.nl>
parents: 873
diff changeset
41 my $ldc_rev = `hg -R@PROJECT_SOURCE_DIR@ log -r qparent --template '{rev}:{node|short} ({date|isodate})' 2>/dev/null || hg -R@PROJECT_SOURCE_DIR@ tip --template '{rev}:{node|short} ({date|isodate})'`;
853
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
42
873
a331ce9bc749 fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents: 853
diff changeset
43 my $out = qq!#ifndef LDC_VERSIONS_H
853
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
44 #define LDC_VERSIONS_H
1112
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
45 $extra_includes
853
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
46
1064
f0b6549055ab Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Frits van Bommel <fvbommel wxs.nl>
parents: 972
diff changeset
47 // LLVM version string, for use in -version output
1112
829ac3f30103 Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents: 1065
diff changeset
48 #define LLVM_REV_STR $llvm_rev_str$llvm_date
1064
f0b6549055ab Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Frits van Bommel <fvbommel wxs.nl>
parents: 972
diff changeset
49 // LDC version string, for use in -version output
972
d66ab756c75b Change the way the version is printed (more verbose, with short hash)
Frits van Bommel <fvbommel wxs.nl>
parents: 873
diff changeset
50 #define LDC_REV "rev. $ldc_rev"
853
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
51
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
52 #endif // LDC_VERSIONS_H\n!;
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
53
873
a331ce9bc749 fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents: 853
diff changeset
54 my $revh;
a331ce9bc749 fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents: 853
diff changeset
55 my $old = "";
a331ce9bc749 fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents: 853
diff changeset
56 open $revh, "revisions.h" and $old = join "", <$revh>;
a331ce9bc749 fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents: 853
diff changeset
57
a331ce9bc749 fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents: 853
diff changeset
58 if ($old ne $out) {
a331ce9bc749 fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents: 853
diff changeset
59 open $revh, ">revisions.h" or die "cannot create revisions.h: $!";
a331ce9bc749 fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents: 853
diff changeset
60 print $revh $out;
a331ce9bc749 fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents: 853
diff changeset
61 close $revh;
a331ce9bc749 fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents: 853
diff changeset
62 }
1113
123812e02bc8 Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents: 1112
diff changeset
63
1123
165a920f4e88 Don't set LLVM_REV if it's set on the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 1113
diff changeset
64 # Allow the user to manually define it on the command line...
1471
230765fc82f4 Emit nicer error messages when the user didn't set LLVM_REV and autodetection
Frits van Bommel <fvbommel wxs.nl>
parents: 1290
diff changeset
65 $out = qq@#ifndef LLVM_REV
1113
123812e02bc8 Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents: 1112
diff changeset
66
123812e02bc8 Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents: 1112
diff changeset
67 // LLVM svn revision number, used to adapt to changes in LLVM
123812e02bc8 Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents: 1112
diff changeset
68 // (Is 0 if LLVM is not an SVN trunk version)
123812e02bc8 Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents: 1112
diff changeset
69 #define LLVM_REV $llvm_rev_nr
123812e02bc8 Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents: 1112
diff changeset
70
1471
230765fc82f4 Emit nicer error messages when the user didn't set LLVM_REV and autodetection
Frits van Bommel <fvbommel wxs.nl>
parents: 1290
diff changeset
71 #endif // LLVM_REV
230765fc82f4 Emit nicer error messages when the user didn't set LLVM_REV and autodetection
Frits van Bommel <fvbommel wxs.nl>
parents: 1290
diff changeset
72
230765fc82f4 Emit nicer error messages when the user didn't set LLVM_REV and autodetection
Frits van Bommel <fvbommel wxs.nl>
parents: 1290
diff changeset
73 #if !LLVM_REV
230765fc82f4 Emit nicer error messages when the user didn't set LLVM_REV and autodetection
Frits van Bommel <fvbommel wxs.nl>
parents: 1290
diff changeset
74 #error "You need to add '-DLLVM_REV=<your-llvm-rev>' to CMAKE_CXX_FLAGS in the cmake configuration"
230765fc82f4 Emit nicer error messages when the user didn't set LLVM_REV and autodetection
Frits van Bommel <fvbommel wxs.nl>
parents: 1290
diff changeset
75 #elif LLVM_REV < 67588
230765fc82f4 Emit nicer error messages when the user didn't set LLVM_REV and autodetection
Frits van Bommel <fvbommel wxs.nl>
parents: 1290
diff changeset
76 #error "Please update to a more recent LLVM version"
230765fc82f4 Emit nicer error messages when the user didn't set LLVM_REV and autodetection
Frits van Bommel <fvbommel wxs.nl>
parents: 1290
diff changeset
77 #endif\n@;
1113
123812e02bc8 Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents: 1112
diff changeset
78
123812e02bc8 Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents: 1112
diff changeset
79 $old = "";
123812e02bc8 Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents: 1112
diff changeset
80 open $revh, "llvm-version.h" and $old = join "", <$revh>;
123812e02bc8 Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents: 1112
diff changeset
81
123812e02bc8 Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents: 1112
diff changeset
82 if ($old ne $out) {
123812e02bc8 Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents: 1112
diff changeset
83 open $revh, ">llvm-version.h" or die "cannot create llvm-version.h: $!";
123812e02bc8 Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents: 1112
diff changeset
84 print $revh $out;
123812e02bc8 Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents: 1112
diff changeset
85 close $revh;
123812e02bc8 Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents: 1112
diff changeset
86 }