bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* [PATCH] Don't use $(CC) for the -std=gnu11 flag
@ 2019-11-18 21:45 Christian Biesinger
  2019-11-18 22:15 ` Bruno Haible
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Biesinger @ 2019-11-18 21:45 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Christian Biesinger

Currently, the std-gnu11 module uses $(CC) to store the
compiler flag to enable C11. This has the downside that
if someone uses make CC=foo, the flag will be overridden.

Instead, this patch uses its own variable that it then
uses in AM_CFLAGS, similar to lib-symbol-visibility.

2019-11-18  Christian Biesinger  <cbiesinger@google.com>

	* m4/std-gnu11.m4: Store -std= flag in C_VERSION_FLAG.
	* modules/std-gnu11: Add C_VERSION_FLAG to AM_CFLAGS.
---
 m4/std-gnu11.m4   | 3 ++-
 modules/std-gnu11 | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/m4/std-gnu11.m4 b/m4/std-gnu11.m4
index 23e7f75f1..746d1e004 100644
--- a/m4/std-gnu11.m4
+++ b/m4/std-gnu11.m4
@@ -189,7 +189,8 @@ case "x$ac_cv_prog_cc_$1" in
     AC_MSG_RESULT([unsupported]) ;;
   *)
     ac_prog_cc_stdc_options=" $ac_cv_prog_cc_$1"
-    CC=$CC$ac_prog_cc_stdc_options
+    C_VERSION_FLAG=$C_VERSION_FLAG$ac_prog_cc_stdc_options
+    AC_SUBST(C_VERSION_FLAG)
     AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;;
 esac
 AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])
diff --git a/modules/std-gnu11 b/modules/std-gnu11
index 26c71153e..0a20ec6f8 100644
--- a/modules/std-gnu11
+++ b/modules/std-gnu11
@@ -9,6 +9,7 @@ Depends-on:
 configure.ac:
 
 Makefile.am:
+AM_CFLAGS += $(C_VERSION_FLAG)
 
 Include:
 
-- 
2.24.0.432.g9d3f5f5b63-goog



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Don't use $(CC) for the -std=gnu11 flag
  2019-11-18 21:45 [PATCH] Don't use $(CC) for the -std=gnu11 flag Christian Biesinger
@ 2019-11-18 22:15 ` Bruno Haible
  2019-11-18 22:38   ` Christian Biesinger
  0 siblings, 1 reply; 3+ messages in thread
From: Bruno Haible @ 2019-11-18 22:15 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Christian Biesinger

Hi Christian,

This patch is not good. In a package where some subdirectories
use automake and gnulib and other subdirectories don't use Automake,
it will have the effect that some subdirectories are compiled with
-std=gnu11 and some without. This is a recipe for hassles.

One such package is GNU libiconv; there probably are others.

> Currently, the std-gnu11 module uses $(CC) to store the
> compiler flag to enable C11. This has the downside that
> if someone uses make CC=foo, the flag will be overridden.

A user is not supposed to use
  make CC=some-other-compiler

This works only with packages which don't use autoconfiguration;
it does not work with gnulib (which has tons of autoconf tests
whose results depend on $CC).

Bruno



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Don't use $(CC) for the -std=gnu11 flag
  2019-11-18 22:15 ` Bruno Haible
@ 2019-11-18 22:38   ` Christian Biesinger
  0 siblings, 0 replies; 3+ messages in thread
From: Christian Biesinger @ 2019-11-18 22:38 UTC (permalink / raw)
  To: Bruno Haible; +Cc: bug-gnulib

On Mon, Nov 18, 2019 at 4:15 PM Bruno Haible <bruno@clisp.org> wrote:
>
> Hi Christian,
>
> This patch is not good. In a package where some subdirectories
> use automake and gnulib and other subdirectories don't use Automake,
> it will have the effect that some subdirectories are compiled with
> -std=gnu11 and some without. This is a recipe for hassles.
>
> One such package is GNU libiconv; there probably are others.
>
> > Currently, the std-gnu11 module uses $(CC) to store the
> > compiler flag to enable C11. This has the downside that
> > if someone uses make CC=foo, the flag will be overridden.
>
> A user is not supposed to use
>   make CC=some-other-compiler
>
> This works only with packages which don't use autoconfiguration;
> it does not work with gnulib (which has tons of autoconf tests
> whose results depend on $CC).

OK, thanks for the explanation. I will instead fix the GDB build
system to not override $(CC).

Christian


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-18 22:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18 21:45 [PATCH] Don't use $(CC) for the -std=gnu11 flag Christian Biesinger
2019-11-18 22:15 ` Bruno Haible
2019-11-18 22:38   ` Christian Biesinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).