Skip to content

Commit 408d071

Browse files
authored
Merge pull request #1178 from jimklimov/gcc-49
Ensure at least GCC-4.9 if a project needs real C++11 support
2 parents c13ee7b + 1474e6f commit 408d071

File tree

7 files changed

+138
-17
lines changed

7 files changed

+138
-17
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -803,12 +803,13 @@ Model is described in `zproject_known_projects.xml` file:
803803

804804
### Optional : Class filename configuration
805805

806-
Exemple:
806+
Example:
807807
```classfilename
808-
<classfilename use-cxx = "true" pkgincludedir = "false" keep-tree = "true" pretty-print = "no" source-extension = "cpp" header-extension = "hpp" />
808+
<classfilename use-cxx = "true" use-cxx-gcc-4-9 = "true" pkgincludedir = "false" keep-tree = "true" pretty-print = "no" source-extension = "cpp" header-extension = "hpp" />
809809
```
810810

811811
* use-cxx will force usage (or not) of c++.
812+
* use-cxx-gcc-4-9 will enable "use-cxx" AND enforce the use of gcc-4.9 on Travis CI for nearly complete C++11 language support that is lacking in default gcc-4.8 there.
812813
* keep-tree will keep the include tree structure on the install (as opposed to flat delivery of include files basenames into the single-level target directory), must be used with a conservative name format (ex: pretty-print = "no"). Currently only supported with autotool.
813814
* pkgincludedir option chooses whether headers of this project should be dumped into the common system includedir (legacy default), or into an includedir/projname subdirectory?. Currently only supported with autotool.
814815
* pretty-print define the type of class name format change in order to generate the filename. It uses the pretty-print option of gsl (see Substituting Symbols and Expressions on https://github.com/zeromq/gsl#expressions for more information).
@@ -819,7 +820,8 @@ Default value :
819820
* pretty-print : substitute_non_alpha_to_make_c_identifier (c option)
820821
* header-extension : h
821822
* source-extension : c (unless a cc file is present, then cc)
822-
* use-cxx : true if a cc file is present false otherwhise
823+
* use-cxx : true if a cc file is present, false otherwhise
824+
* use-cxx-gcc-4-9 : false by default, older GCC versions still suffice for many C++11 features
823825

824826
### Targets
825827

README.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,13 @@ Model is described in `zproject_known_projects.xml` file:
142142

143143
### Optional : Class filename configuration
144144

145-
Exemple:
145+
Example:
146146
```classfilename
147-
<classfilename use-cxx = "true" pkgincludedir = "false" keep-tree = "true" pretty-print = "no" source-extension = "cpp" header-extension = "hpp" />
147+
<classfilename use-cxx = "true" use-cxx-gcc-4-9 = "true" pkgincludedir = "false" keep-tree = "true" pretty-print = "no" source-extension = "cpp" header-extension = "hpp" />
148148
```
149149

150150
* use-cxx will force usage (or not) of c++.
151+
* use-cxx-gcc-4-9 will enable "use-cxx" AND enforce the use of gcc-4.9 on Travis CI for nearly complete C++11 language support that is lacking in default gcc-4.8 there.
151152
* keep-tree will keep the include tree structure on the install (as opposed to flat delivery of include files basenames into the single-level target directory), must be used with a conservative name format (ex: pretty-print = "no"). Currently only supported with autotool.
152153
* pkgincludedir option chooses whether headers of this project should be dumped into the common system includedir (legacy default), or into an includedir/projname subdirectory?. Currently only supported with autotool.
153154
* pretty-print define the type of class name format change in order to generate the filename. It uses the pretty-print option of gsl (see Substituting Symbols and Expressions on https://github.com/zeromq/gsl#expressions for more information).
@@ -158,7 +159,8 @@ Default value :
158159
* pretty-print : substitute_non_alpha_to_make_c_identifier (c option)
159160
* header-extension : h
160161
* source-extension : c (unless a cc file is present, then cc)
161-
* use-cxx : true if a cc file is present false otherwhise
162+
* use-cxx : true if a cc file is present, false otherwhise
163+
* use-cxx-gcc-4-9 : false by default, older GCC versions still suffice for many C++11 features
162164

163165
### Targets
164166

zproject.gsl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ function resolve_classfilename_option()
6868
endif
6969
endif
7070

71+
# Some but not all C++ projects require the fuller scope of C++11
72+
# and do not compile under gcc-4.8 which is Travis default in "trusty".
73+
# This optional toggle allows to require a newer gcc-4.9 for them.
74+
# Note that with current implementation, it effectively hardcodes
75+
# the use of specifically 4.9, not allowing for "4.9 or newer".
76+
if defined (classfilename.use\-cxx\-gcc\-4\-9)
77+
if classfilename.use\-cxx\-gcc\-4\-9 ?= "true"
78+
use_cxx_gcc_4_9 = 1
79+
use_cxx = 1
80+
elsif classfilename.use\-cxx\-gcc\-4\-9 ?= "false"
81+
use_cxx_gcc_4_9 = 0
82+
endif
83+
endif
7184

7285
if defined (classfilename.keep\-tree)
7386
if classfilename.keep\-tree ?= "true"
@@ -93,6 +106,7 @@ project.filename_prettyprint = "c"
93106
project.header_ext = "h"
94107
project.source_ext = "c"
95108
project.use_cxx = project_use_cxx ()
109+
project.use_cxx_gcc_4_9 = 0
96110
project.keep_tree = 0
97111
project.pkgincludedir = 0
98112
resolve_classfilename_option()

zproject_autotools.gsl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,47 @@ AS_IF([test "x$enable_Werror" = "xyes" || test "x$enable_Werror" = "xauto"],
12201220
])])
12211221
])
12221222

1223+
.if project.use_cxx_gcc_4_9
1224+
# One of big missing features in gcc-4.8 was std::regex support fixed in 4.9
1225+
# Testing code from https://stackoverflow.com/a/41186162/4715872
1226+
# caveats apply (use of unguaranteed private macros)
1227+
AS_IF([test -n "$CXX"],[AS_IF([$CXX --version 2>&1 | grep 'Free Software Foundation' > /dev/null && test "x$GCC" = "xyes"],
1228+
[AC_MSG_CHECKING([for GNU C++11 support level expected by gcc-4.9 release or newer])
1229+
CXXFLAGS="$CXXFLAGS --std=c++11"
1230+
AC_LANG_PUSH([C++])
1231+
AC_TRY_RUN([/* Note: private macros in use, test can break over time */
1232+
#include <regex>
1233+
1234+
#if __cplusplus >= 201103L && \\
1235+
(!defined(__GLIBCXX__) || (__cplusplus >= 201402L) || \\
1236+
(defined(_GLIBCXX_REGEX_DFS_QUANTIFIERS_LIMIT) || \\
1237+
defined(_GLIBCXX_REGEX_STATE_LIMIT) || \\
1238+
(defined(_GLIBCXX_RELEASE) && \\
1239+
_GLIBCXX_RELEASE > 4)))
1240+
#define HAVE_WORKING_REGEX 1
1241+
#else
1242+
#define HAVE_WORKING_REGEX 0
1243+
#endif
1244+
1245+
#include <iostream>
1246+
1247+
int main() {
1248+
const std::regex regex(".*");
1249+
const std::string string = "This should match!";
1250+
const auto result = std::regex_search(string, regex);
1251+
#if HAVE_WORKING_REGEX
1252+
std::cerr << "<regex> works, look: " << std::boolalpha << result << std::endl;
1253+
#else
1254+
std::cerr << "<regex> doesn't work, look: " << std::boolalpha << result << std::endl;
1255+
#endif
1256+
return result ? EXIT_SUCCESS : EXIT_FAILURE;
1257+
}
1258+
], AC_MSG_RESULT([ok]), AC_MSG_ERROR([test for std::regex failed]) )
1259+
AC_LANG_POP([C++])
1260+
]
1261+
)])
1262+
1263+
.endif
12231264
.if file.exists ("acinclude.m4")
12241265
# Optional project-local hook to (re-)define some variables that can be used
12251266
# in your project files generated from .in templates - in your acinclude.m4,

zproject_debian.gsl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ Build-Depends: debhelper (>= 9),
6060
. endif
6161
,
6262
.endfor
63+
.if defined(use_cxx_gcc_4_9) & !(use_cxx_gcc_4_9 ?= 0)
64+
gcc (>= 4.9.0), g++ (>= 4.9.0),
65+
.endif
6366
.if systemd ?= 1
6467
.# necessary for systemd.pc to get unit install path
6568
systemd,

zproject_redhat.gsl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,15 @@ BuildRequires: systemd
8484
.endif
8585
BuildRequires: xmlto
8686
.if project.use_cxx
87+
. if defined(project.use_cxx_gcc_4_9) & !(project.use_cxx_gcc_4_9 ?= 0)
88+
# Note that with current implementation of zproject use-cxx-gcc-4-9 option,
89+
# this effectively hardcodes the use of specifically 4.9, not allowing for
90+
# "4.9 or newer".
91+
BuildRequires: devtoolset-3-gcc devtoolset-3-gcc-c++
92+
BuildRequires: gcc-c++ >= 4.9.0
93+
. else
8794
BuildRequires: gcc-c++
95+
. endif
8896
.endif
8997
.for project.use
9098
.if defined(use.redhat_name)

zproject_travis.gsl

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -212,18 +212,35 @@ pkg_src_zeromq_ubuntu16: &pkg_src_zeromq_ubuntu16
212212
- sourceline: 'deb http://download.opensuse.org/repositories/network:/messaging:/zeromq:/git-draft/xUbuntu_16.04/ ./'
213213
key_url: 'http://download.opensuse.org/repositories/network:/messaging:/zeromq:/git-draft/xUbuntu_16.04/Release.key'
214214

215+
pkg_deps_common: &pkg_deps_common
216+
- *pkg_deps_devtools
217+
- *pkg_deps_prereqs
218+
215219
# Also note that as of early 2017, either dist==trusty or services==docker
216220
# is needed for some C++11 support; docker envs are usually faster to start up
217221
# A newer dist==xenial completes the C++11 support with gcc-5+
222+
.if defined(use_cxx) & defined(use_cxx_gcc_4_9)
223+
# Note that with current implementation of zproject use-cxx-gcc-4-9 option,
224+
# this effectively hardcodes the use of specifically 4.9, not allowing for
225+
# "4.9 or newer".
226+
.endif
218227
addons:
219228
apt:
220-
.if (pkg_src_zeromq_dist ?<> "")
229+
.if (pkg_src_zeromq_dist ?<> "") | (defined(use_cxx) & defined(use_cxx_gcc_4_9) & !(use_cxx ?= 0) & !(use_cxx_gcc_4_9 ?= 0))
221230
sources:
231+
.endif
232+
.if (pkg_src_zeromq_dist ?<> "")
222233
- *$(pkg_src_zeromq_dist)
223234
.endif
224-
packages: &pkg_deps_common
225-
- *pkg_deps_devtools
226-
- *pkg_deps_prereqs
235+
.if defined(use_cxx) & defined(use_cxx_gcc_4_9) & !(use_cxx ?= 0) & !(use_cxx_gcc_4_9 ?= 0)
236+
- ubuntu-toolchain-r-test
237+
.endif
238+
packages:
239+
- *pkg_deps_common
240+
.if defined(use_cxx) & defined(use_cxx_gcc_4_9) & !(use_cxx ?= 0) & !(use_cxx_gcc_4_9 ?= 0)
241+
- gcc-4.9
242+
- g++-4.9
243+
.endif
227244

228245
matrix:
229246
include:
@@ -234,40 +251,67 @@ matrix:
234251
.endif
235252
addons:
236253
apt:
237-
.if (pkg_src_zeromq_dist ?<> "")
254+
.if (pkg_src_zeromq_dist ?<> "") | (defined(use_cxx) & defined(use_cxx_gcc_4_9) & !(use_cxx ?= 0) & !(use_cxx_gcc_4_9 ?= 0))
238255
sources:
256+
.endif
257+
.if (pkg_src_zeromq_dist ?<> "")
239258
- *$(pkg_src_zeromq_dist)
259+
.endif
260+
.if defined(use_cxx) & defined(use_cxx_gcc_4_9) & !(use_cxx ?= 0) & !(use_cxx_gcc_4_9 ?= 0)
261+
- ubuntu-toolchain-r-test
240262
.endif
241263
packages:
242264
- *pkg_deps_common
243265
- *pkg_deps_doctools
266+
.if defined(use_cxx) & defined(use_cxx_gcc_4_9) & !(use_cxx ?= 0) & !(use_cxx_gcc_4_9 ?= 0)
267+
- gcc-4.9
268+
- g++-4.9
269+
.endif
244270
- env: BUILD_TYPE=valgrind
245271
os: linux
246272
.if (project.travis_dist ?<> "")
247273
dist: $(project.travis_dist)
248274
.endif
249275
addons:
250276
apt:
251-
.if (pkg_src_zeromq_dist ?<> "")
277+
.if (pkg_src_zeromq_dist ?<> "") | (defined(use_cxx) & defined(use_cxx_gcc_4_9) & !(use_cxx ?= 0) & !(use_cxx_gcc_4_9 ?= 0))
252278
sources:
279+
.endif
280+
.if (pkg_src_zeromq_dist ?<> "")
253281
- *$(pkg_src_zeromq_dist)
282+
.endif
283+
.if defined(use_cxx) & defined(use_cxx_gcc_4_9) & !(use_cxx ?= 0) & !(use_cxx_gcc_4_9 ?= 0)
284+
- ubuntu-toolchain-r-test
254285
.endif
255286
packages:
256287
- valgrind
257288
- *pkg_deps_common
289+
.if defined(use_cxx) & defined(use_cxx_gcc_4_9) & !(use_cxx ?= 0) & !(use_cxx_gcc_4_9 ?= 0)
290+
- gcc-4.9
291+
- g++-4.9
292+
.endif
258293
- env: BUILD_TYPE=default ADDRESS_SANITIZER=enabled
259294
os: linux
260295
.if (project.travis_dist ?<> "")
261296
dist: $(project.travis_dist)
262297
.endif
263298
addons:
264299
apt:
265-
.if (pkg_src_zeromq_dist ?<> "")
300+
.if (pkg_src_zeromq_dist ?<> "") | (defined(use_cxx) & defined(use_cxx_gcc_4_9) & !(use_cxx ?= 0) & !(use_cxx_gcc_4_9 ?= 0))
266301
sources:
302+
.endif
303+
.if (pkg_src_zeromq_dist ?<> "")
267304
- *$(pkg_src_zeromq_dist)
305+
.endif
306+
.if defined(use_cxx) & defined(use_cxx_gcc_4_9) & !(use_cxx ?= 0) & !(use_cxx_gcc_4_9 ?= 0)
307+
- ubuntu-toolchain-r-test
268308
.endif
269309
packages:
270310
- *pkg_deps_common
311+
.if defined(use_cxx) & defined(use_cxx_gcc_4_9) & !(use_cxx ?= 0) & !(use_cxx_gcc_4_9 ?= 0)
312+
- gcc-4.9
313+
- g++-4.9
314+
.endif
271315
.if defined(project.travis_check_zproject) & !(project.travis_check_zproject ?= 0)
272316
- env: BUILD_TYPE=check_zproject
273317
os: linux
@@ -350,22 +394,24 @@ matrix:
350394
- clang-3.8
351395
.endif
352396
.if defined (project.travis_shadow_gcc) & !(project.travis_shadow_gcc ?= 0)
397+
. if !(defined(use_cxx_gcc_4_9)) | !(use_cxx_gcc_4_9 ?= 1)
353398
- env: BUILD_TYPE=default-Werror MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
354399
os: linux
355-
.if (project.travis_dist ?<> "")
400+
. if (project.travis_dist ?<> "")
356401
dist: $(project.travis_dist)
357-
.endif
402+
. endif
358403
addons:
359404
apt:
360405
sources:
361406
- ubuntu-toolchain-r-test
362-
.if (pkg_src_zeromq_dist ?<> "")
407+
. if (pkg_src_zeromq_dist ?<> "")
363408
- *$(pkg_src_zeromq_dist)
364-
.endif
409+
. endif
365410
packages:
366411
- *pkg_deps_common
367412
- g++-4.9
368413
- gcc-4.9
414+
. endif
369415
- env: BUILD_TYPE=default-Werror MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
370416
os: linux
371417
.if (project.travis_dist ?<> "")
@@ -456,7 +502,9 @@ matrix:
456502
. endif
457503
. if project.travis_shadow_gcc ?= 2
458504
. echo "TRAVIS: Shadow GCC versions: allow-fail: true"
505+
. if !(use_cxx_gcc_4_9 ?= 1)
459506
- env: BUILD_TYPE=default-Werror MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
507+
. endif
460508
- env: BUILD_TYPE=default-Werror MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
461509
- env: BUILD_TYPE=default-Werror MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
462510
- env: BUILD_TYPE=default-Werror MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
@@ -506,6 +554,9 @@ before_install:
506554
- if [ "$TRAVIS_OS_NAME" == "osx" -a "$BUILD_TYPE" == "android" ] ; then brew install binutils ; fi
507555
- if [ "$TRAVIS_OS_NAME" == "osx" -a "$BUILD_TYPE" == "valgrind" ] ; then brew install valgrind ; fi
508556
- if [ -n "\${MATRIX_EVAL}" ] ; then eval \${MATRIX_EVAL} ; fi
557+
.if defined(use_cxx) & defined(use_cxx_gcc_4_9) & !(use_cxx ?= 0) & !(use_cxx_gcc_4_9 ?= 0)
558+
- if [ "$CXX" == "g++" ] ; then export CXX="g++-4.9" CC="gcc-4.9" ; fi
559+
.endif
509560

510561
# Hand off to generated script for each BUILD_TYPE
511562
script: ./ci_build.sh

0 commit comments

Comments
 (0)