[Asterisk-code-review] Added the ability to build in the standard C11, C14 (asterisk[master])

Badalian Vyacheslav asteriskteam at digium.com
Sun Oct 30 16:03:29 CDT 2016


Badalian Vyacheslav has uploaded a new change for review. ( https://gerrit.asterisk.org/4238 )

Change subject: Added the ability to build in the standard C11, C14
......................................................................

Added the ability to build in the standard C11, C14

- Fixed a small bug in the ASAN, TSAN
- Added the ability to build a GNU C11, C14 support for compatibility testing

 Please enter the commit message for your changes. Lines starting

Change-Id: I72024509180c6d95f5e7e8935bd856b6f33d00aa
---
M Makefile.rules
M build_tools/cflags.xml
M build_tools/menuselect-deps.in
M configure.ac
4 files changed, 62 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/38/4238/1

diff --git a/Makefile.rules b/Makefile.rules
index 45989d6..8f33e41 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -31,6 +31,14 @@
 # extra cflags to build dependencies. Recursively expanded.
 MAKE_DEPS=-MD -MT $@ -MF .$(subst /,_,$@).d -MP
 
+ifeq ($(findstring COMPILE_C_C11,$(MENUSELECT_CFLAGS)),COMPILE_C_C11)
+    _ASTCFLAGS+=-std=gnu11
+endif
+
+ifeq ($(findstring COMPILE_C_C14,$(MENUSELECT_CFLAGS)),COMPILE_C_C14)
+    _ASTCFLAGS+=-std=gnu14
+endif
+
 ifeq ($(findstring ADDRESS_SANITIZER,$(MENUSELECT_CFLAGS)),ADDRESS_SANITIZER)
     _ASTLDFLAGS+=-fsanitize=address
     _ASTCFLAGS+=-fno-omit-frame-pointer -fsanitize=address
diff --git a/build_tools/cflags.xml b/build_tools/cflags.xml
index a06d515..b2572a8 100644
--- a/build_tools/cflags.xml
+++ b/build_tools/cflags.xml
@@ -1,4 +1,22 @@
 <category name="MENUSELECT_CFLAGS" displayname="Compiler Flags" positive_output="yes" remove_on_change=".lastclean">
+		<member name="COMPILE_C_DEFAULT" displayname="Compile using Default (C99) standart">
+			<defaultenabled>yes</defaultenabled>
+			<support_level>extended</support_level>
+			<conflict>COMPILE_C_C11</conflict>
+			<conflict>COMPILE_C_C14</conflict>
+		</member>
+		<member name="COMPILE_C_C11" displayname="Compile using GNU C11 standart">
+			<depend>HAVE_C_C11</depend>
+			<support_level>extended</support_level>
+			<conflict>COMPILE_C_DEFAULT</conflict>
+			<conflict>COMPILE_C_C14</conflict>
+		</member>
+		<member name="COMPILE_C_C14" displayname="Compile using GNU C14 standart">
+			<depend>HAVE_C_C14</depend>
+			<support_level>extended</support_level>
+			<conflict>COMPILE_C_DEFAULT</conflict>
+			<conflict>COMPILE_C_C11</conflict>
+		</member>
 		<member name="DONT_OPTIMIZE" displayname="Disable Optimizations by the Compiler">
 			<use autoselect="yes">COMPILE_DOUBLE</use>
 			<support_level>core</support_level>
diff --git a/build_tools/menuselect-deps.in b/build_tools/menuselect-deps.in
index 9f1aa70..c016b24 100644
--- a/build_tools/menuselect-deps.in
+++ b/build_tools/menuselect-deps.in
@@ -81,3 +81,5 @@
 HAVE_LEAK_SANITIZER=@AST_LEAK_SANITIZER@
 HAVE_THREAD_SANITIZER=@AST_THREAD_SANITIZER@
 HAVE_UNDEFINED_SANITIZER=@AST_UNDEFINED_SANITIZER@
+HAVE_C_C11=@AST_HAVE_C_C11@
+HAVE_C_C14=@AST_HAVE_C_C14@
diff --git a/configure.ac b/configure.ac
index 0f2148b..6c10128 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1106,6 +1106,38 @@
 AST_GCC_ATTRIBUTE(destructor)
 AST_GCC_ATTRIBUTE(noreturn,noreturn)
 
+AC_MSG_CHECKING(for --std=c11 support)
+saved_c_c11_CFLAGS="${CFLAGS}"
+saved_c_c11_LDFLAGS="${LDFLAGS}"
+CFLAGS="--std=c11"
+LDFLAGS=""
+AC_COMPILE_IFELSE(
+	[AC_LANG_PROGRAM([], [int x = 1;])],
+	AC_MSG_RESULT(yes)
+	[AST_HAVE_C_C11=1],
+	[AST_HAVE_C_C11=0]
+	AC_MSG_RESULT(no)
+)
+CFLAGS="${saved_c_c11_CFLAGS}"
+LDFLAGS="${saved_c_c11_LDFLAGS}"
+AC_SUBST(AST_HAVE_C_C11)
+
+AC_MSG_CHECKING(for --std=c14 support)
+saved_c_c14_CFLAGS="${CFLAGS}"
+saved_c_c14_LDFLAGS="${LDFLAGS}"
+CFLAGS="--std=c14"
+LDFLAGS=""
+AC_COMPILE_IFELSE(
+	[AC_LANG_PROGRAM([], [int x = 1;])],
+	AC_MSG_RESULT(yes)
+	[AST_HAVE_C_C14=1],
+	[AST_HAVE_C_C14=0]
+	AC_MSG_RESULT(no)
+)
+CFLAGS="${saved_c_c14_CFLAGS}"
+LDFLAGS="${saved_c_c14_LDFLAGS}"
+AC_SUBST(AST_HAVE_C_C14)
+
 AC_MSG_CHECKING(for -fsanitize=address support)
 saved_sanitize_CFLAGS="${CFLAGS}"
 saved_sanitize_LDFLAGS="${LDFLAGS}"
@@ -1115,7 +1147,7 @@
 	[AC_LANG_PROGRAM([], [int x = 1;])],
 	AC_MSG_RESULT(yes)
 	[AST_ADDRESS_SANITIZER=1],
-	[AST_ADDRESS_SANITIZER=]
+	[AST_ADDRESS_SANITIZER=0]
 	AC_MSG_RESULT(no)
 )
 CFLAGS="${saved_sanitize_CFLAGS}"
@@ -1131,7 +1163,7 @@
 	[AC_LANG_PROGRAM([], [int x = 1;])],
 	AC_MSG_RESULT(yes)
 	[AST_THREAD_SANITIZER=1],
-	[AST_THREAD_SANITIZER=]
+	[AST_THREAD_SANITIZER=0]
 	AC_MSG_RESULT(no)
 )
 CFLAGS="${saved_sanitize_CFLAGS}"

-- 
To view, visit https://gerrit.asterisk.org/4238
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I72024509180c6d95f5e7e8935bd856b6f33d00aa
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Badalian Vyacheslav <v.badalyan at open-bs.ru>



More information about the asterisk-code-review mailing list