-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
276 lines (234 loc) · 8.76 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
dnl Catch macros that are not expanded.
m4_pattern_forbid([^(AM|AX|LT|TC)_])
m4_define([TC_CLANG_PREREQ], [11.0])
m4_define([TC_GCC_PREREQ], [10.2])
m4_define([TC_HAVM_PREREQ], [0.28])
m4_define([TC_NOLIMIPS_PREREQ], [0.11])
AC_PREREQ([2.64])
## ---------------- ##
## Package set up. ##
## ---------------- ##
AC_INIT([LRDE Tiger Compiler], [1.91.e], [[email protected]], [tc],
[http://tiger.lrde.epita.fr])
# Auxiliary files.
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([build-aux/m4])
# Automake.
AM_INIT_AUTOMAKE([1.14.1 dist-bzip2 no-dist-gzip foreign
color-tests parallel-tests
nostdinc silent-rules -Wall])
# By default, let "make" hide the compilation command and display a
# "GEN ..." message, unless V=1 is passed to "make".
AM_SILENT_RULES([yes])
## --------------------- ##
## C++ Compiler Set up. ##
## --------------------- ##
# Look for a C++ compiler.
AC_LANG([C++])
AC_PROG_CXX
# Warn if the C++ compiler is not known to support the required
# features. Or course, we should rather check for features, not
# version numbers.
case $($CXX --version) in
(*clang*)
AS_VERSION_COMPARE([$($CXX -dumpversion)], [TC_CLANG_PREREQ],
[AC_MSG_ERROR([clang++ >= TC_CLANG_PREREQ is required, have $cxx_version])])
;;
(*g++*)
AS_VERSION_COMPARE([$($CXX -dumpfullversion)], [TC_GCC_PREREQ],
[AC_MSG_ERROR([g++ >= TC_GCC_PREREQ is required, have $cxx_version])])
;;
(*)
AC_MSG_ERROR([g++ >= TC_GCC_PREREQ or clang++ >= TC_CLANG_PREREQ is required, have none])
;;
esac
# Enable C++ 2014 support.
AC_CANONICAL_HOST
# Passing -stdlib=libc++ to clang++ is a requirement on OS X to enable
# full C++ 2011 support. For more information on this, see
# http://cplusplusmusings.wordpress.com/2012/07/05/clang-and-standard-libraries
# We don't try to enable it by default on other platforms, as libc++
# is principally supported by OS X.
case $host_os in
(darwin*)
AX_CHECK_COMPILE_FLAG([-std=c++20 -stdlib=libc++],
[CXXFLAGS="$CXXFLAGS -std=c++20 -stdlib=libc++"
stdpass=true])
;;
esac
if ! "${stdpass-false}"; then
AX_CHECK_COMPILE_FLAG([-std=c++20],
[CXXFLAGS="$CXXFLAGS -std=c++20"
stdpass=true])
fi
if ! "${stdpass-false}"; then
AC_ERROR([unable to turn on C++20 mode with this compiler])
fi
# Try to use pipes between compiler stages to speed the compilation up.
AX_CHECK_COMPILE_FLAG([-pipe], [CXXFLAGS="$CXXFLAGS -pipe"])
# Use good warnings.
TC_CXX_WARNINGS([[-Wall],
[-W],
[-Wcast-align],
[-Wcast-qual],
[-Wformat],
[-Wmissing-prototypes],
[-Wstrict-prototypes],
[-Wwrite-strings],
[-Wbad-function-cast],
[-Wmissing-declarations],
[-Wnested-externs],
[-Wunused-parameter],
[-Wunused-function],
[-Woverloaded-virtual],
])
# Pacify g++ on Boost Variants.
TC_CXX_WARNINGS([[-Wno-shadow]])
# This is so that ICC no longer complain that
#
# scantiger.ll(177): remark #111: statement is unreachable
# break;
# ^
#
# ./../ast/seqexp.hh(36): remark #193:
# zero used for undefined preprocessing identifier
# #if STUDENT
# ^
#
# scantiger.cc(924): remark #279: controlling expression is constant
# while ( 1 ) /* loops until end-of-file is reached */
# ^
#
# ../../src/task/task.hh(38): remark #383:
# value copied to temporary, reference to
# temporary used
# int key = 0, const std::string& deps = "");
# ^
# /intel/compiler70/ia32/include/xstring(41): remark #444:
# destructor for base class "std::_String_val<_Elem, _Ax>" is not virtual
# : public _String_val<_Elem, _Ax>
# ^
#
# ../../../src/type/types.hxx(64): remark #522:
# function "type::Named::type_set(const type::Type *)" redeclared "inline"
# after being called
# Named::type_set (const Type* type)
# ^
#
# ./../ast/print-visitor.hh(21): warning #654:
# overloaded virtual function "ast::GenVisitor<K>::visit
# [with K=ast::const_kind]"
# is only partially overridden in class "ast::PrettyPrinter"
# class PrettyPrinter : public DefaultVisitor<const_kind>
# ^
#
# /intel/compiler70/ia32/include/xlocale(1381): remark #810:
# conversion from "int" to "char" may lose significant bits
# return (widen((char)_Tolower((unsigned char)narrow(_Ch),
# ^
#
#
# ./../ast/print-visitor.hh(331): remark #981:
# operands are evaluated in unspecified order
# _ostr << "type " << e.name_get () << " = ";
# ^
#
# scantiger.cc(324): remark #1418:
# external definition with no prior declaration
# static char yy_hold_char;
# ^
#
TC_CXX_WARNINGS([[[-wd111,193,279,383,444,522,654,810,981,1418]]])
# GCC emits tons of warnings about src/parse/parsetiger.hh regarding
# broken strict aliasing rules:
#
# ../../src/parse/parsetiger.hh:
# In instantiation of 'T& parse::variant<S>::as()
# [with T = ast::ChunkList*; long unsigned int S = 16ul]':
# ../../src/parse/parsetiger.hh:146:7:
# required from 'void parse::variant<S>::swap(parse::variant<S>&)
# [with T = ast::ChunkList*; long unsigned int S = 16ul]'
# ../../src/parse/parsetiger.hh:156:7:
# required from 'void parse::variant<S>::build(parse::variant<S>&)
# [with T = ast::ChunkList*; long unsigned int S = 16ul]'
# ../../src/parse/parsetiger.hh:872:46: required from here
# ../../src/parse/parsetiger.hh:130:46:
# warning: dereferencing type-punned pointer will break strict-aliasing
# rules [-Wstrict-aliasing]
#
# ...
#
# Check whether the C++ compiler supports `-Wno-strict-aliasing' and
# if so, add it to NO_STRICT_ALIASING_CXXFLAGS and let Makefiles use
# it to compile code that include src/parse/parsetiger.hh.
TC_CXX_FLAGS([[-Wno-strict-aliasing]], [NO_STRICT_ALIASING_CXXFLAGS])
## -------------------- ##
## Auxiliary programs. ##
## -------------------- ##
TC_PROG([flex], [>= 2.5.35], [FLEX], [Flex scanner generator])
AX_CONFIG_SCRIPTS([build-aux/bin/flex++])
FLEX_VERSION
TC_PROG([bison], [>= 3.8.2], [BISON], [Bison parser generator])
AX_CONFIG_SCRIPTS([build-aux/bin/bison++])
# Compile Emacs files.
AM_PATH_LISPDIR
# Requested by Automake 1.12 for tcsh.
AM_PROG_AR
# We don't need shared libraries, speed the compilation up.
LT_INIT([disable-shared])
# Check for IA-32-GNU/Linux (and x86-64-GNU/Linux) to disable related
# parts on other platforms.
AM_CONDITIONAL([IA32_GNU_LINUX],
[echo "$host" | grep -q '^\(i.86\|x86_64\).*linux'])
# Check for IA-32-FreeBSD to disable related parts on other platforms.
AM_CONDITIONAL([IA32_FREEBSD],
[echo "$host" | grep -q '^\(i.86\|amd64\).*freebsd'])
# If one the previous IA-32 conditionals was true, enable SUPPORTED_IA32.
AM_CONDITIONAL([SUPPORTED_IA32],
[echo "$host" | grep -q '^\(i.86\|x86_64\).*linux\|^\(i.86\|amd64\).*freebsd'])
# Debian does not provide a llvm-config binary
TC_PROG([llvm-config-11 llvm-config], [>=TC_CLANG_PREREQ], [LLVM_CONFIG], [Print LLVM compilation options])
TC_PROG([clang clang-11], [>=TC_CLANG_PREREQ], [CLANG], [C language family frontend for LLVM])
# Add a configure option to link LLVM statically
AC_ARG_ENABLE([static-llvm],
[AS_HELP_STRING([--enable-static-llvm],
[enable the linking statically against the LLVM back-end @<:@no@:>@])])
# Set STATIC_LLVM when linking statically
AM_CONDITIONAL([STATIC_LLVM], [test x"$enable_static_llvm" = x"yes"])
# Clang-format.
AC_CHECK_PROGS([CLANG_FORMAT], [clang-format])
## ----------- ##
## Libraries. ##
## ----------- ##
BOOST_REQUIRE([1.61])
BOOST_CONVERSION # boost::lexical_cast
BOOST_GRAPH
BOOST_PROGRAM_OPTIONS
BOOST_STRING_ALGO
BOOST_SYSTEM
## ------ ##
## Tcsh. ##
## ------ ##
# Check for Darwin to help Libtool use the right dynamic module
# extension on this system.
AM_CONDITIONAL([DARWIN], [echo "$host_os" | grep -q '^darwin'])
TC_WITH_TCSH([with_tcsh=yes], [with_tcsh=no])
AM_CONDITIONAL([ENABLE_TCSH], [test x$with_tcsh = xyes])
AC_CONFIG_FILES([tcsh/Makefile])
AC_CONFIG_FILES([doc/Doxyfile])
AX_CONFIG_SCRIPTS([tcsh/run])
## ------- ##
## Tests. ##
## ------- ##
# Students should create their test suite in tests/. Add the needed
# configure options here.
AC_CONFIG_FILES([tests/Makefile])
## --------------- ##
## Configuration. ##
## --------------- ##
# Ask for the creation of config.h.
AC_CONFIG_HEADERS([config.h])
# Ask for the creation of the Makefiles.
AC_CONFIG_FILES([Makefile])
# Instantiate the output files.
AC_OUTPUT