diff options
author | Mike Frysinger <vapier@gentoo.org> | 2021-01-08 02:24:51 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2021-01-08 15:45:42 -0500 |
commit | 46f900c065f65013ae58a97f3b991a7e0c5ab669 (patch) | |
tree | bfa940b2425bdeb5444cec377eb84ebd15109ba4 /sim/common | |
parent | 8fc48b79618af335d6cea1d1d149668340298b81 (diff) | |
download | gdb-46f900c065f65013ae58a97f3b991a7e0c5ab669.zip gdb-46f900c065f65013ae58a97f3b991a7e0c5ab669.tar.gz gdb-46f900c065f65013ae58a97f3b991a7e0c5ab669.tar.bz2 |
sim: require a C11 compiler
With GDB requiring a C++11 compiler now, this hopefully shouldn't
be a big deal. It's been 10 years since C11 came out, so should
be plenty of time to upgrade.
This will allow us to start cleaning up random header logic and
many of our non-standard custom types.
Diffstat (limited to 'sim/common')
-rw-r--r-- | sim/common/ChangeLog | 6 | ||||
-rw-r--r-- | sim/common/Make-common.in | 3 | ||||
-rw-r--r-- | sim/common/acinclude.m4 | 26 |
3 files changed, 34 insertions, 1 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index 05948f2..df78108 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,9 @@ +2021-01-08 Mike Frysinger <vapier@gentoo.org> + + * Make-common.in (C_DIALECT): Define. + (COMPILE.pre): Append $(C_DIALECT). + * acinclude.m4 (SIM_AC_COMMON): Probe C11 to define C_DIALECT. + 2021-01-07 Mike Frysinger <vapier@gentoo.org> * sim-core.c (sim_memory_map): Define. diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in index 21e1d99..6e71930 100644 --- a/sim/common/Make-common.in +++ b/sim/common/Make-common.in @@ -70,6 +70,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ CC = @CC@ +C_DIALECT = @C_DIALECT@ CC_FOR_BUILD = @CC_FOR_BUILD@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ @@ -107,7 +108,7 @@ depcomp = $(SHELL) $(srcroot)/depcomp # Note that these are overridden by GNU make-specific code below if # GNU make is used. The overrides implement dependency tracking. -COMPILE.pre = $(CC) +COMPILE.pre = $(CC) $(C_DIALECT) COMPILE.post = -c -o $@ COMPILE = $(COMPILE.pre) $(ALL_CFLAGS) $(COMPILE.post) POSTCOMPILE = @true diff --git a/sim/common/acinclude.m4 b/sim/common/acinclude.m4 index ff7e1ac..49d56b9 100644 --- a/sim/common/acinclude.m4 +++ b/sim/common/acinclude.m4 @@ -56,6 +56,32 @@ AR=${AR-ar} AC_SUBST(AR) AC_PROG_RANLIB +# Require C11 or newer. Autoconf-2.70 provides ac_cv_prog_cc_c11 when using +# AC_PROG_CC, but we're still using Autoconf-2.69, and the newest it understands +# is C99. So handle it ourselves. +m4_version_prereq([2.70], [AC_MSG_ERROR([clean this up!])], [:]) +C_DIALECT= +AC_MSG_CHECKING([whether C11 is supported by default]) +AC_COMPILE_IFELSE([AC_LANG_SOURCE([ +#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L +# error "C11 support not found" +#endif +])], [AC_MSG_RESULT([yes])], [ + AC_MSG_RESULT([no]) + AC_MSG_CHECKING([for -std=c11 support]) + ac_save_CC="$CC" + CC="$CC -std=c11" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ +#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L +# error "C11 support not found" +#endif +])], [ + AC_MSG_RESULT([yes]) + CC="$ac_save_CC" + C_DIALECT="-std=c11" +], [AC_MSG_ERROR([C11 is required])])]) +AC_SUBST(C_DIALECT) + # Some of the common include files depend on bfd.h, and bfd.h checks # that config.h is included first by testing that the PACKAGE macro # is defined. |