Drop gnu89/c89 support, switch to c99
PATCH 1/1 Drop gnu89/c89 support, switch to c99
Previously, we would use the compiler's default C version, which defaults to gnu89 for GCC < 5, gnu11 for GCC > 5, and c11 for clang, but might even differ per distro.
One of the reasons to accept the gnu89 default of GCC < 4.9, was that MSVC didn't support c99. But in MSVC 2015, MS finanally fixed that.
Having to support c89 in the codebase occasionally forces us to write less readable code, for example by forcing all declaration to be at the starting of a block (which includes 'for loop initial declarations').
Let's be clear about what standard we obey, and stop punishing ourselves with c89/gnu89. Let's switch the master branch to c99.
--- configure.ac | 1 + 1 file changed, 1 insertion(+)
configure.ac +1 -0
@@ -1125,6 +1125,7 @@ if test "${enable_pkcs11}" = "yes"; then ) fi +CFLAGS="${CFLAGS} -std=c99" if test "${enable_pedantic}" = "yes"; then enable_strict="yes" CFLAGS="${CFLAGS} -pedantic"
Signature · 1 line
2.7.4
Quoted 7 lines · Steffan Karger
Previously, we would use the compiler's default C version, which defaults to gnu89 for GCC < 5, gnu11 for GCC > 5, and c11 for clang, but might even differ per distro.
One of the reasons to accept the gnu89 default of GCC < 4.9, was that MSVC didn't support c99. But in MSVC 2015, MS finanally fixed that.
Quoted 6 lines
Having to support c89 in the codebase occasionally forces us to write less readable code, for example by forcing all declaration to be at the starting of a block (which includes 'for loop initial declarations').
Let's be clear about what standard we obey, and stop punishing ourselves with c89/gnu89. Let's switch the master branch to c99.
To be clear: I'm aware we never really decided to switch to c99, so this patch is partly meant to start discussion. Anyone who cares for gnu89 support, please speak up :)
-Steffan
Quoted 14 lines · Steffan Karger
Quoted 2 lines · Steffan Karger
Previously, we would use the compiler's default C version, which defaults to gnu89 for GCC < 5, gnu11 for GCC > 5, and c11 for clang, but might
even
Quoted 3 lines
differ per distro.
One of the reasons to accept the gnu89 default of GCC < 4.9, was that
MSVC
Quoted 3 lines
didn't support c99. But in MSVC 2015, MS finanally fixed that.
Having to support c89 in the codebase occasionally forces us to write
less
Quoted 1 line
readable code, for example by forcing all declaration to be at the
starting
Quoted 8 lines
Quoted 4 lines
of a block (which includes 'for loop initial declarations').
Let's be clear about what standard we obey, and stop punishing ourselves with c89/gnu89. Let's switch the master branch to c99.
To be clear: I'm aware we never really decided to switch to c99, so this patch is partly meant to start discussion. Anyone who cares for gnu89 support, please speak up :)
I have been all along wishing for this switch to C99 and the demise of dated MSVC support. But we also have to keep in mind that mingw-w64 (and mingw) targets a least common denominator of Windows runtime (runtime version 6.0 ?). That is not going to change as the very spirit of mingw is to make executables that run with stock windows libraries. That means features of C99 requiring run-time support (stdio is an example) cannot be supported by mingw by default as it requires statically linking in additional code.
For example, __USE_MINGW_ANSI_STDIO has to be defined to support some of the printf format specs and that adds about 50K to the binary. That also invalidates windows-specific format specifiers such as %I64u which is used in a couple places in the code. Last time I suggested this Gert was opposed to it on grounds of the extra define, need for code changes, increased binary size etc..
My personal preference: go for -std=c99, add the above define for mingw and get rid of %I64.. (a only a couple of instances). That said, I do not know how complete is the C99 support in mingw-w64, and whether there are other issues that need work around. I suppose we can handle them, if any, as they come..
Selva
Quoted 35 lines · Selva Nair
Quoted 18 lines · Steffan Karger
Quoted 16 lines · Steffan Karger
Previously, we would use the compiler's default C version, which defaults
to gnu89 for GCC < 5, gnu11 for GCC > 5, and c11 for clang, but might even
differ per distro.One of the reasons to accept the gnu89 default of GCC < 4.9, was that MSVC
didn't support c99. But in MSVC 2015, MS finanally fixed that.Having to support c89 in the codebase occasionally forces us to write less
readable code, for example by forcing all declaration to be at the starting
of a block (which includes 'for loop initial declarations').Quoted 6 lines
Quoted 2 lines
Let's be clear about what standard we obey, and stop punishing ourselves with c89/gnu89. Let's switch the master branch to c99.
To be clear: I'm aware we never really decided to switch to c99, so this patch is partly meant to start discussion. Anyone who cares for gnu89 support, please speak up :)
I have been all along wishing for this switch to C99 and the demise of dated MSVC support. But we also have to keep in mind that mingw-w64 (and mingw) targets a least common denominator of Windows runtime (runtime version 6.0 ?). That is not going to change as the very spirit of mingw is to make executables that run with stock windows libraries. That means features of C99 requiring run-time support (stdio is an example) cannot be supported by mingw by default as it requires statically linking in additional code.
Quoted 6 lines
For example,
__USE_MINGW_ANSI_STDIOhas to be defined to support some of the printf format specs and that adds about 50K to the binary. That also invalidates windows-specific format specifiers such as %I64u which is used in a couple places in the code. Last time I suggested this Gert was opposed to it on grounds of the extra define, need for code changes, increased binary size etc..
Yes I'm aware of this. Even so, just compile-time c99 support is valuable in itself.
Quoted 5 lines
My personal preference: go for -std=c99, add the above define for mingw and get rid of %I64.. (a only a couple of instances). That said, I do not know how complete is the C99 support in mingw-w64, and whether there are other issues that need work around. I suppose we can handle them, if any, as they come..
That would be my preference too. Definitely c99, maybe __USE_MINGW_ANSI_STDIO__ too. I don't care too much for 50 kB extra in Windows binaries. I'd be much more worried about 50 kB in linux binaries, as that would hurt quite some embedded platforms.
-Steffan
Quoted 50 lines · Selva Nair
Quoted 18 lines · Steffan Karger
Quoted 16 lines · Steffan Karger
Previously, we would use the compiler's default C version, which defaults
to gnu89 for GCC < 5, gnu11 for GCC > 5, and c11 for clang, but might even
differ per distro.One of the reasons to accept the gnu89 default of GCC < 4.9, was that MSVC
didn't support c99. But in MSVC 2015, MS finanally fixed that.Having to support c89 in the codebase occasionally forces us to write less
readable code, for example by forcing all declaration to be at the starting
of a block (which includes 'for loop initial declarations').Quoted 6 lines
Quoted 2 lines
Let's be clear about what standard we obey, and stop punishing ourselves with c89/gnu89. Let's switch the master branch to c99.
To be clear: I'm aware we never really decided to switch to c99, so this patch is partly meant to start discussion. Anyone who cares for gnu89 support, please speak up :)
I have been all along wishing for this switch to C99 and the demise of dated MSVC support. But we also have to keep in mind that mingw-w64 (and mingw) targets a least common denominator of Windows runtime (runtime version 6.0 ?). That is not going to change as the very spirit of mingw is to make executables that run with stock windows libraries. That means features of C99 requiring run-time support (stdio is an example) cannot be supported by mingw by default as it requires statically linking in additional code.
For example,
__USE_MINGW_ANSI_STDIOhas to be defined to support some of the printf format specs and that adds about 50K to the binary. That also invalidates windows-specific format specifiers such as %I64u which is used in a couple places in the code. Last time I suggested this Gert was opposed to it on grounds of the extra define, need for code changes, increased binary size etc..My personal preference: go for -std=c99, add the above define for mingw and get rid of %I64.. (a only a couple of instances). That said, I do not know how complete is the C99 support in mingw-w64, and whether there are other issues that need work around. I suppose we can handle them, if any, as they come..
Selva
PATCH v2 1/1 Drop gnu89/c89 support, switch to c99
In reply to Steffan KargerPreviously, we would use the compiler's default C version, which defaults to gnu89 for GCC < 5, gnu11 for GCC > 5, and c11 for clang, but might even differ per distro.
One of the reasons to accept the gnu89 default of GCC < 4.9, was that MSVC didn't support c99. But in MSVC 2015, MS finanally fixed that.
Having to support c89 in the codebase occasionally forces us to write less readable code, for example by forcing all declaration to be at the starting of a block (which includes 'for loop initial declarations').
Let's be clear about what standard we obey, and stop punishing ourselves with c89/gnu89. Let's switch the master branch to c99.
v2: don't try to detect pedantic mode based on __STRICT_ANSI__, since that
will be defined when using -std=c99. (We might want to remove this cripple-binary-if-pedantic all together later on, but I'm not pulling that into this patch.)
--- configure.ac | 3 ++- src/openvpn/syshead.h | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-)
configure.ac +2 -1
@@ -1125,10 +1125,11 @@ if test "${enable_pkcs11}" = "yes"; then ) fi +CFLAGS="${CFLAGS} -std=c99" if test "${enable_pedantic}" = "yes"; then enable_strict="yes" CFLAGS="${CFLAGS} -pedantic" - test "${WIN32}" != "yes" && CFLAGS="${CFLAGS} -std=c99" + AC_DEFINE([PEDANTIC], [1], [Enable pedantic mode]) fi if test "${enable_strict}" = "yes"; then CFLAGS="${CFLAGS} -Wall -Wno-unused-parameter -Wno-unused-function"
src/openvpn/syshead.h +1 -4
@@ -384,16 +384,13 @@* Pedantic mode is meant to accomplish lint-style program checking, * not to build a working executable. */ -#ifdef __STRICT_ANSI__ -# define PEDANTIC 1 +#ifdef PEDANTIC # undef HAVE_CPP_VARARG_MACRO_GCC# undef HAVE_CPP_VARARG_MACRO_ISO# undef EMPTY_ARRAY_SIZE# define EMPTY_ARRAY_SIZE 1# undef inline# define inline -#else -# define PEDANTIC 0#endif /*
Signature · 1 line
2.7.4
PATCH v3 1/1 Drop gnu89/c89 support, switch to c99
Previously, we would use the compiler's default C version, which defaults to gnu89 for GCC < 5, gnu11 for GCC > 5, and c11 for clang, but might even differ per distro.
One of the reasons to accept the gnu89 default of GCC < 4.9, was that MSVC didn't support c99. But in MSVC 2015, MS finanally fixed that.
Having to support c89 in the codebase occasionally forces us to write less readable code, for example by forcing all declaration to be at the starting of a block (which includes 'for loop initial declarations').
Let's be clear about what standard we obey, and stop punishing ourselves with c89/gnu89. Let's switch the master branch to c99.
v2: don't try to detect pedantic mode based on __STRICT_ANSI__, since that
will be defined when using -std=c99.
v3: only set -std=c99 if there is no -std= already present in CFLAGS
--- configure.ac | 8 +++++++- src/openvpn/syshead.h | 5 +---- 2 files changed, 8 insertions(+), 5 deletions(-)
configure.ac +7 -1
@@ -1125,10 +1125,16 @@ if test "${enable_pkcs11}" = "yes"; then ) fi +# Set -std=c99 unless user already specified a -std= +case "$CFLAGS" in + *-std=*) ;; + *) CFLAGS="$CFLAGS -std=c99" ;; +esac + if test "${enable_pedantic}" = "yes"; then enable_strict="yes" CFLAGS="${CFLAGS} -pedantic" - test "${WIN32}" != "yes" && CFLAGS="${CFLAGS} -std=c99" + AC_DEFINE([PEDANTIC], [1], [Enable pedantic mode]) fi if test "${enable_strict}" = "yes"; then CFLAGS="${CFLAGS} -Wall -Wno-unused-parameter -Wno-unused-function"
src/openvpn/syshead.h +1 -4
@@ -384,16 +384,13 @@* Pedantic mode is meant to accomplish lint-style program checking, * not to build a working executable. */ -#ifdef __STRICT_ANSI__ -# define PEDANTIC 1 +#ifdef PEDANTIC # undef HAVE_CPP_VARARG_MACRO_GCC# undef HAVE_CPP_VARARG_MACRO_ISO# undef EMPTY_ARRAY_SIZE# define EMPTY_ARRAY_SIZE 1# undef inline# define inline -#else -# define PEDANTIC 0#endif /*
Signature · 1 line
2.7.4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Your patch has been applied to the master branch
commit 058f0efdec63aba911addee9ab205382c4762d06
Author: Steffan Karger Date: Thu Sep 1 22:14:30 2016 +0200
Drop gnu89/c89 support, switch to c99
Signed-off-by: Steffan Karger <[email protected]...>
Acked-by: David Sommerseth <[email protected]...>
Message-Id: [email protected]...
URL: https://www.mail-archive.com/[email protected]/msg00194.html
Signed-off-by: David Sommerseth <[email protected]...>- --
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQIcBAEBAgAGBQJX3AjWAAoJEIbPlEyWcf3yW+QQAJcDpem8lt1RF7nd4y8IGGbz 3eFoRgt3q8OG2caZi7YrvpfwfTe2D1gQlh4usjGLkKyRN8zGFTnKi1mp+JG1wznZ QED9UdxeHjnU+dM+3a7MSOsmwsWqruANCT6Riqr2rYX/M3zjc30SUHF7AEXA1KzQ RnGzB9jQfznkU2ew3av1OF6ZskY0kJlb2lxqkadzrncUDVwcElfjk4pWuh/cAt3z Sa1mCzT5jjMRgoM8g9gJVojVOKWui6wCF4yzesRuIIt9ALAryZD/5teSKmGhoHsC Tb4dH6+2bBVXNJYhwtl6kxN3GGxytrUHbLatAN56aq21zw2NYz2O3l4JuVVK8p2I Ty9oG63xdiys45WanyuX79tSXzEzcDwqfbt0goYVHN/sD1UJcIygpa1Wd/PuQgYy qGn3VGisWCON0kxDlqDc0Uly6+GVyDRREprA335LKv/VOGtu8hbL/9gvoV5uuKZK fOdmC6E90VFTe+aGuDgVsqPKH3m3ra87nn3IbdSl4JXrvaAQ+XzNXXTqkeNWFtTk qs5oPZyb9UMUU3pMwdEw2vaz8wvE/qhfB/9grlWrwoIozXMQUdRfNtFw+6BArfYF DRpQcYxv3vHZKU3E29IpXb4H3hyTWQfPxWbho7itSm51xemI9EdmzhhIprVT3iH3 MG+lHSnsO4tRQXZx760g
=qUYx
-----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 23 lines · Steffan Karger
Previously, we would use the compiler's default C version, which defaults to gnu89 for GCC < 5, gnu11 for GCC > 5, and c11 for clang, but might even differ per distro.
One of the reasons to accept the gnu89 default of GCC < 4.9, was that MSVC didn't support c99. But in MSVC 2015, MS finanally fixed that.
Having to support c89 in the codebase occasionally forces us to write less readable code, for example by forcing all declaration to be at the starting of a block (which includes 'for loop initial declarations').
Let's be clear about what standard we obey, and stop punishing ourselves with c89/gnu89. Let's switch the master branch to c99.
Signed-off-by Steffan Karger <[email protected]...> --- configure.ac| 1 + 1 file changed, 1 insertion(+)
configure.ac index 9189c94..16cab19 renamed from configure.ac +0
-0100644 --- a/configure.ac +++ b/configure.ac @@ -1125,6 +1125,7 @@ if test "${enable_pkcs11}" = "yes"; then ) fi
Quoted 3 lines
+CFLAGS="${CFLAGS} -std=c99" if test "${enable_pedantic}" = "yes"; then enable_strict="yes" CFLAGS="${CFLAGS} -pedantic"
I so much wants to give this an ACK. But this breaks CentOS 5 builds very badly. The glibc-headers isn't prepared for C99 on that distro.
I took the latest git master where I could do a successful build. Then I applied just this patch, and here is the explosion:
<http://paste.fedoraproject.org/417049/14725031/>
To move towards C99, we need to add some tricks which makes this not requiring users to overwrite C99 with C89. That should happen automatically.
Some CentOS 5.11 details:
glibc-2.5-123.el5_11.3
glibc-headers-2.5-123.el5_11.3
gcc-4.1.2-55.el5
openssl-0.9.8e-40.el5_11
lzo-2.02-2.el5.1
- --
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQIcBAEBAgAGBQJXxJ8AAAoJEIbPlEyWcf3y9/AP/2ArG2hclq5B48K7/c5pddg5 TC9QY2fgI/NoUGTTzOz7K3Pmzqo98pRAJPlItHZuQGnMsI4mUUoGz5AJxY31faSk GqrXsJw87IMiPT1ZVSiUeNOLgA7drUHjQo9fe4uzZKfY+pIQcP09cOjWyyjPdiWm 1I4AqSuqawrva7cPVdIMQ/mxQA6SPFqCOF4y9wL2u6he1G7w9D3loomq5SP4zTQ9 wkarGmJ5x7bzLH/5C5Wl/s0yD0lWKG0FSaAelPw5+h4qxIXSMKhVNhapohJ7zUfX YW+yVH5+pROAvGg/VgGdvdthPPqlodJSi4hIgkgRqtBnyhp+zzGjbvmCE2aL0DtN XXx2FZppAbZzUgdvfCBjjElmtz0y4v2cewgTO/5f9Aumj/JDSpwbOgrCfSiwrqvh OWsDPhnliYWacELUvEmK3M/tQHAfIVP307fy8ZgUtkwh/H4hLI+m7AaTOyzo7a73 PmcjtBVe1VLKBq1PDM9IORO7dAz7ApecuLoTe3BrhXF+lDe4DLaUxQhWHocl+Gwr YhFPny4PyV7kAUNrsReZHxYC04cHvKxG4lh5LJg+jqXnF5obuRM6jBjPKdyo4HW5 qwyD6osMV9DK9BByQY8ClypufBa0ABVJYKUDtUgVl/Rl05mhsLJLlFi2AP4FQMcr +5rF+M2E5JyR7mysH6cA
=VCb4
-----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 37 lines · David Sommerseth
Quoted 24 lines · Steffan Karger
Previously, we would use the compiler's default C version, which defaults to gnu89 for GCC < 5, gnu11 for GCC > 5, and c11 for clang, but might even differ per distro.
One of the reasons to accept the gnu89 default of GCC < 4.9, was that MSVC didn't support c99. But in MSVC 2015, MS finanally fixed that.
Having to support c89 in the codebase occasionally forces us to write less readable code, for example by forcing all declaration to be at the starting of a block (which includes 'for loop initial declarations').
Let's be clear about what standard we obey, and stop punishing ourselves with c89/gnu89. Let's switch the master branch to c99.
Signed-off-by Steffan Karger <[email protected]...> ---configure.ac | 1 + 1 file changed, 1 insertion(+)
configure.ac index 9189c94..16cab19 renamed from configure.ac +0
-0100644 --- a/configure.ac +++ b/configure.ac @@ -1125,6 +1125,7 @@ if test "${enable_pkcs11}" = "yes"; then ) fi
Quoted 2 lines
+CFLAGS="${CFLAGS} -std=c99" if test "${enable_pedantic}" = "yes"; then enable_strict="yes" CFLAGS="${CFLAGS} -pedantic"
I so much wants to give this an ACK. But this breaks CentOS 5 builds very badly. The glibc-headers isn't prepared for C99 on that distro.
I took the latest git master where I could do a successful build. Then I applied just this patch, and here is the explosion:
<http://paste.fedoraproject.org/417049/14725031/>
Quoted 7 lines
To move towards C99, we need to add some tricks which makes this not requiring users to overwrite C99 with C89. That should happen automatically.
Some CentOS 5.11 details: glibc-2.5-123.el5_11.3
glibc-headers-2.5-123.el5_11.3 gcc-4.1.2-55.el5
openssl-0.9.8e-40.el5_11 lzo-2.02-2.el5.1
Did a bit more testing.
-std=gnu89, -std=gnu99
Works very fine (compiles without errors).
-std=c99
Makes glibc-headers explode, as already described
-std=c89
Makes the LZ4 library we're shipping explode.
- --
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQIcBAEBAgAGBQJXxKMEAAoJEIbPlEyWcf3yG4cP/j9rDswKAtpOELBmULCxMng4 Y/y+zFgPNb6u8GMtyWRbeAruNMn06XLXIt0mjPx00NUmN3zhxXXp24mXQZEQu7zO MaPM6gEYV/PbIueGHfZl0hBys0rAVYFR3NJCmP7jn4VC7jll5BKDpSdpLGYXDXrc jBqyRBoKq0O1nJXV1KykmzGUkKtBJGPUSpDHoTN3b1ylKbdL9KU9iowyYgzWHYGZ e1PKXiDLEpOBZHaoOn3JqiHlAAJ7LnfFHh3lY9Dy3UDtOj2xwJtuTuBoisf27rNm M3Bjfdguq3+dSmSA7JKy5bv1IXU5zPVt3tx2vjplg8XHGF4ppISYR0lwI/WpZSTf Lm9tb6f9AZGrOhUy1Z4uxUw2ECM5XlgDq+t8QnQ5TeN8BalC1qI/FtIOUWEHFuzF H3jdMAa/j0Zp/cmnc3gpbh6/hdMuvmlxbn0/rTNiqPpVPYFICnokk7hoa2SbOT0p chsQGaA6Kj5MBTtqcWuMx7i+sdij9LhF1rTq1cB2AitGMfKgk+ehjttF6aLyZsvu sZTCQS7s7eP001bhUI6fennTNnbFaUMH6S/Y3mT9IFOElGybfemabXIfzUNOAAH3 BfwTln4+lFC37lnHEcIA8jvLCc4Svz0cGwc/HV7DDbvMt14kmk9peA03qv03NwaC 66fxkZDeTqso4q93Eav5
=cmOG
-----END PGP SIGNATURE-----
HI,
Quoted 48 lines · David Sommerseth
Quoted 37 lines · David Sommerseth
Quoted 24 lines · Steffan Karger
Previously, we would use the compiler's default C version, which defaults to gnu89 for GCC < 5, gnu11 for GCC > 5, and c11 for clang, but might even differ per distro.
One of the reasons to accept the gnu89 default of GCC < 4.9, was that MSVC didn't support c99. But in MSVC 2015, MS finanally fixed that.
Having to support c89 in the codebase occasionally forces us to write less readable code, for example by forcing all declaration to be at the starting of a block (which includes 'for loop initial declarations').
Let's be clear about what standard we obey, and stop punishing ourselves with c89/gnu89. Let's switch the master branch to c99.
Signed-off-by Steffan Karger <[email protected]...> ---configure.ac | 1 + 1 file changed, 1 insertion(+)
configure.ac index 9189c94..16cab19 renamed from configure.ac +0
-0100644 --- a/configure.ac +++ b/configure.ac @@ -1125,6 +1125,7 @@ if test "${enable_pkcs11}" = "yes"; then ) fi
Quoted 2 lines
+CFLAGS="${CFLAGS} -std=c99" if test "${enable_pedantic}" = "yes"; then enable_strict="yes" CFLAGS="${CFLAGS} -pedantic"
I so much wants to give this an ACK. But this breaks CentOS 5 builds very badly. The glibc-headers isn't prepared for C99 on that distro.
I took the latest git master where I could do a successful build. Then I applied just this patch, and here is the explosion:
<http://paste.fedoraproject.org/417049/14725031/>Quoted 7 lines
To move towards C99, we need to add some tricks which makes this not requiring users to overwrite C99 with C89. That should happen automatically.
Some CentOS 5.11 details: glibc-2.5-123.el5_11.3
glibc-headers-2.5-123.el5_11.3 gcc-4.1.2-55.el5
openssl-0.9.8e-40.el5_11 lzo-2.02-2.el5.1Did a bit more testing.
Quoted 8 lines
-std=gnu89, -std=gnu99
Works very fine (compiles without errors).-std=c99
Makes glibc-headers explode, as already described-std=c89
Makes the LZ4 library we're shipping explode.
Hm, that's too bad. But I think we should still go for c99, rather than gnu99. That should actually result in *more* portable code on our side. The CentOS package maintainer can then easily patch configure.ac (or configure) to use gnu99 for arcane platforms.
-Steffan
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 58 lines · Steffan Karger
HI,
Quoted 54 lines · David Sommerseth
Quoted 38 lines · David Sommerseth
Quoted 25 lines · Steffan Karger
Previously, we would use the compiler's default C version, which defaults to gnu89 for GCC < 5, gnu11 for GCC > 5, and c11 for clang, but might even differ per distro.
One of the reasons to accept the gnu89 default of GCC < 4.9, was that MSVC didn't support c99. But in MSVC 2015, MS finanally fixed that.
Having to support c89 in the codebase occasionally forces us to write less readable code, for example by forcing all declaration to be at the starting of a block (which includes 'for loop initial declarations').
Let's be clear about what standard we obey, and stop punishing ourselves with c89/gnu89. Let's switch the master branch to c99.
Signed-off-by Steffan Karger <[email protected]...> ---configure.ac | 1 + 1 file changed, 1 insertion(+)
configure.ac index renamed from configure.ac +0
-09189c94..16cab19 100644 --- a/configure.ac +++ b/configure.ac
configure.ac index renamed from configure.ac +0
-0@@ -1125,6 +1125,7 @@ if test "${enable_pkcs11}" = "yes";then ) fi
Quoted 2 lines
+CFLAGS="${CFLAGS} -std=c99" if test "${enable_pedantic}" = "yes"; then enable_strict="yes" CFLAGS="${CFLAGS} -pedantic"
I so much wants to give this an ACK. But this breaks CentOS 5 builds very badly. The glibc-headers isn't prepared for C99 on that distro.
I took the latest git master where I could do a successful build. Then I applied just this patch, and here is the
explosion: <http://paste.fedoraproject.org/417049/14725031/>Quoted 7 lines
To move towards C99, we need to add some tricks which makes this not requiring users to overwrite C99 with C89. That should happen automatically.
Some CentOS 5.11 details: glibc-2.5-123.el5_11.3
glibc-headers-2.5-123.el5_11.3 gcc-4.1.2-55.el5
openssl-0.9.8e-40.el5_11 lzo-2.02-2.el5.1Did a bit more testing.
-std=gnu89, -std=gnu99 Works very fine (compiles without errors).
-std=c99 Makes glibc-headers explode, as already described
Quoted 7 lines
Quoted 1 line
-std=c89 Makes the LZ4 library we're shipping explode.
Hm, that's too bad. But I think we should still go for c99, rather than gnu99. That should actually result in *more* portable code on our side. The CentOS package maintainer can then easily patch configure.ac (or configure) to use gnu99 for arcane platforms.
For the stock CentOS 5 package, it probably won't matter. That's indirectly maintained by Red Hat doing all kind of backports whenever needed.
For the Fedora EPEL releases (which keeps our release cycles fairly tight), I'm adding Jon to this discussion directly as the main Fedora package maintainer for OpenVPN.
Any thoughts on this, Jon?
- --
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQIcBAEBAgAGBQJXxLU9AAoJEIbPlEyWcf3y+AQP/iuVPJOsfilHtPPa9UP/MHe3 gPf+LrWBQ5YhkvW06MC9dfWRaDSf2PILj6dKG5kj83hdfhv/CcyJZCLYZLlhiaqS ONxcndskI3geIbAxsx/QCSQ1GghTsc/jwFKcYlrDBq8RA34s0KQBmquKtUyoMX7E /YldciIuK5hCEr/6+Kx5ekyszceGV6i6RG4+Mevkf6CEHvOgS8NUFhcw2zY++Ook E1FkSLcrw/yc8HnChIR8z4qvFpvKmQyTQ9mN7/noqSC4rc/ESrWx0sAj48g7be+l PMfQ94O8au4QYysb9AWFPhX2b23hNJPavMGYbZW07d2ZFs6kRs7I5bPSSkp/Vnxf 3rq27Hmo6pKFxIR/52w9ysNU4vrUVshim9Al2UytgI6+T3ClxWJSGfjaYMd5tCL4 sPyNnQHhjXo2WIxeCIbTTkIUEtVVQit67ZvyU6+aL+S5gB56Nvw+/UORyQfr7hx/ 5q7RUvNo65XLVXHXNhoXKSHsSEwiSCQ5oQI71Lvh8omKLcDlKF6LTBIt7p8CBTk1 vD4foQSF8ZW/0FEFIpY9eXEpbLcIZk8wiFHaXS9X6etocw0JXuG+0PHlHxz++0wg SIX/ql3xAwdEmYo3gK0LzPVy7gjgd4mwSSvudKCQSz1XPVJt0XTn0OitxCA/9IJt mL5G75qaB4WjsLT4Ot7T
=LInq
-----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 72 lines · David Sommerseth
Quoted 59 lines · Steffan Karger
HI,
Quoted 55 lines · David Sommerseth
Quoted 39 lines · David Sommerseth
Quoted 25 lines · Steffan Karger
Previously, we would use the compiler's default C version, which defaults to gnu89 for GCC < 5, gnu11 for GCC > 5, and c11 for clang, but might even differ per distro.
One of the reasons to accept the gnu89 default of GCC < 4.9, was that MSVC didn't support c99. But in MSVC 2015, MS finanally fixed that.
Having to support c89 in the codebase occasionally forces us to write less readable code, for example by forcing all declaration to be at the starting of a block (which includes 'for loop initial declarations').
Let's be clear about what standard we obey, and stop punishing ourselves with c89/gnu89. Let's switch the master branch to c99.
Signed-off-by Steffan Karger <[email protected]...> ---configure.ac | 1 + 1 file changed, 1 insertion(+)
configure.ac index renamed from configure.ac +0
-09189c94..16cab19 100644 --- a/configure.ac +++ b/configure.ac @@ -1125,6 +1125,7 @@ if test "${enable_pkcs11}" = "yes"; then ) fi
configure.ac index
Quoted 3 lines
configure.ac index renamed from configure.ac +1
-1+CFLAGS="${CFLAGS} -std=c99" if test "${enable_pedantic}" = "yes"; then enable_strict="yes" CFLAGS="${CFLAGS} -pedantic"I so much wants to give this an ACK. But this breaks CentOS 5 builds very badly. The glibc-headers isn't prepared for C99 on that distro.
I took the latest git master where I could do a successful build. Then I applied just this patch, and here is the
explosion: <http://paste.fedoraproject.org/417049/14725031/>Quoted 7 lines
To move towards C99, we need to add some tricks which makes this not requiring users to overwrite C99 with C89. That should happen automatically.
Some CentOS 5.11 details: glibc-2.5-123.el5_11.3 glibc-headers-2.5-123.el5_11.3 gcc-4.1.2-55.el5 openssl-0.9.8e-40.el5_11 lzo-2.02-2.el5.1
Did a bit more testing.
-std=gnu89, -std=gnu99 Works very fine (compiles without errors).
-std=c99 Makes glibc-headers explode, as already described
Quoted 7 lines
Quoted 1 line
-std=c89 Makes the LZ4 library we're shipping explode.
Hm, that's too bad. But I think we should still go for c99, rather than gnu99. That should actually result in *more* portable code on our side. The CentOS package maintainer can then easily patch configure.ac (or configure) to use gnu99 for arcane platforms.
For the stock CentOS 5 package, it probably won't matter. That's indirectly maintained by Red Hat doing all kind of backports whenever needed.
Quoted 5 lines
For the Fedora EPEL releases (which keeps our release cycles fairly tight), I'm adding Jon to this discussion directly as the main Fedora package maintainer for OpenVPN.
Any thoughts on this, Jon?
Just some more benchmarks. I just compiled successfully with -std=c99 on an old Scientific Linux 6.5 (RHEL 6.5 clone) I found. Another important detail, RHEL5 will reach the "End of Production" phase March 2017, OpenVPN have generally stopped supporting the oldest RHEL releases once it hits EOL. RHEL 5 subscribers may purchase an extended life cycle, but we have not cared too much about that so far.
There is one detail though regarding the patch itself. Your patch adds -std=c99 to the CFLAGS quite early. The compile line gets quite interesting if you try to swap this setting by using the recommended approach:
./configure CFLAGS="$CFLAGS -std=gnu89"
Doing this results in the command line being run during compilation to be be: gcc -std=gnu89 .... -std=c99 ...
So the -std argument appears twice. This should probably be avoided.
- --
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQIcBAEBAgAGBQJXxLn8AAoJEIbPlEyWcf3yX3MP/32L01BOFDWYh9xfi0veAoFY 6E+H8cn3HrtLDCfc+Um8k1osd/lCcJFhBQeaaolBD1RBlG9sEf0rjAqUXQnFCge2 m+26AyZ9IDDuT0b1QsMRo9z1fuAtigOKcrHrYRAtUZ/4Q7KiWp32wdzQ52S2NsMQ er9yd1MwpZ11uevfyYE9i0uRUPIFyCQ3JCYo695MS/q1iHaWjsbS33Wwb6+3uy2p QibLSJdgH1NmLwPIaHZwRYX1TTdRNSdqt/5IGjUk5QgixFQuKQlCILKJ9Ps5HVVL gohF/cugP19/31FCmmWMtJ0l+i9D8QI04aNvEbxqYbi5LWth0thvr41jh4KPMF+i TnUinfeYfJG1MqvXAc2cbOfQIWQV4HuXZaSqSOqkTNNYnq296cUkLOnV3wN5v/d+ dfQDeVjEex2Zy+w3SaWNA4fIs02PfwTKbK76M8zTIteyGYCOoe3JS1dMmDxg8wrx 5s2uAG9idjXFsG1rLaIn6XMiaZSPaPy1evsEet64FIodTREhqVaSD2x0zCQc1wyY GdAgVmNp3bRnahXleVU6XbkfueHZYS/C1rPejP0iJAXM/P3r376Stcm9b/uFI/uV o55SY2A+gsYDDGa+T/b0O82K4CVAJrSeA6VIWa5bRf9WoQXjdSUtkXQ0W0A2ZpAy HOBruoR1qGfk9e3iMp1F
=CoFe
-----END PGP SIGNATURE-----
Hi all,
hopefully this message is not completely garbled by Apple Mail ...
Quoted 5 lines
[…]
Quoted 8 lines
Just some more benchmarks. I just compiled successfully with -std=c99 on an old Scientific Linux 6.5 (RHEL 6.5 clone) I found. Another important detail, RHEL5 will reach the "End of Production" phase March 2017, OpenVPN have generally stopped supporting the oldest RHEL releases once it hits EOL. RHEL 5 subscribers may purchase an extended life cycle, but we have not cared too much about that so far.
[…]
I just checked. Extended Support is basically “you can download the old files, and maybe we help you” [1], so yes indeed, we can totally ignore RHEL5:
For versions of products in the Extended Life Phase, Red Hat will provide limited ongoing technical support. No bug fixes, security fixes, hardware enablement or root-cause analysis will be available during this phase, and support will be provided on existing installations only.
[1] https://access.redhat.com/support/policy/updates/errata/#Extended_Life_Cycle_Phase
Jens
Quoted 13 lines · David Sommerseth
Just some more benchmarks. I just compiled successfully with -std=c99 on an old Scientific Linux 6.5 (RHEL 6.5 clone) I found. Another important detail, RHEL5 will reach the "End of Production" phase March 2017, OpenVPN have generally stopped supporting the oldest RHEL releases once it hits EOL. RHEL 5 subscribers may purchase an extended life cycle, but we have not cared too much about that so far.
There is one detail though regarding the patch itself. Your patch adds -std=c99 to the CFLAGS quite early. The compile line gets quite interesting if you try to swap this setting by using the recommended approach:
Quoted 6 lines
./configure CFLAGS="$CFLAGS -std=gnu89"Doing this results in the command line being run during compilation to be be: gcc -std=gnu89 .... -std=c99 ...
So the -std argument appears twice. This should probably be avoided.
Hm, good point. But I don't think settings CFLAGS="something" should overwrite *all* our default CFLAGS (I know there are currently none, but I'd love to add extra warning flags to the defaults in the future). We could do something like we did for the deps, i.e. add a CFLAGS_STD that defaults to (.e.g.) -std=c99.
-Steffan
Hi,
Quoted 2 lines · David Sommerseth
-std=c89
Makes the LZ4 library we're shipping explode.
We could fix that, but right now the LZ4 sources are "very close to upstream" (just a few file and #include renames) so that would make comparison "are these sane sources or have they been tampered with" less easy.
But I think -std=c89 would also break stuff that we really want, like
for( int i=0; i<10; i++)
^^^
... which really makes "this is the loop variable and nothing else" much easier to read than having an "int i" 50+ lines earlier in the code...
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...