diff mbox

[2/3] Makefile: Fix some macro redefinition warnings

Message ID 519536B5.7020603@ramsay1.demon.co.uk (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Ramsay Jones May 16, 2013, 7:42 p.m. UTC
In particular, gcc complains as follows:

       CC       sparse-llvm.o
  <command line>:1:1: warning: "__STDC_CONSTANT_MACROS" redefined
  <command line>:1:1: warning: this is the location of the previous definition
  <command line>:1:1: warning: "__STDC_FORMAT_MACROS" redefined
  <command line>:1:1: warning: this is the location of the previous definition
  <command line>:1:1: warning: "__STDC_LIMIT_MACROS" redefined
  <command line>:1:1: warning: this is the location of the previous definition

The warnings are caused by the macros being defined twice on the
gcc command line. These command line -D macro definitions come
originally from the output of 'llvm-config --cflags', which is
recorded in the $(LLVM_CFLAGS) variable. This variable is then
included in the $(BASIC_CFLAGS) variable twice due to duplication
of the target-specific additions to the BASIC_CFLAGS, viz:

  sparse-llvm_EXTRA_DEPS := sparse-llvm.o
  sparse-llvm.o $(sparse-llvm_EXTRA_DEPS): BASIC_CFLAGS += $(LLVM_CFLAGS)

In order to suppress the warnings, we remove the duplication of
the sparse-llvm.o target in the above rule.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christopher Li May 17, 2013, 6:30 p.m. UTC | #1
On 05/16/2013 12:42 PM, Ramsay Jones wrote:
> 
> In particular, gcc complains as follows:
> 
>        CC       sparse-llvm.o
>   <command line>:1:1: warning: "__STDC_CONSTANT_MACROS" redefined
>   <command line>:1:1: warning: this is the location of the previous definition
>   <command line>:1:1: warning: "__STDC_FORMAT_MACROS" redefined
>   <command line>:1:1: warning: this is the location of the previous definition
>   <command line>:1:1: warning: "__STDC_LIMIT_MACROS" redefined
>   <command line>:1:1: warning: this is the location of the previous definition
> 
> The warnings are caused by the macros being defined twice on the
> gcc command line. These command line -D macro definitions come
> originally from the output of 'llvm-config --cflags', which is
> recorded in the $(LLVM_CFLAGS) variable. This variable is then
> included in the $(BASIC_CFLAGS) variable twice due to duplication
> of the target-specific additions to the BASIC_CFLAGS, viz:
> 
>   sparse-llvm_EXTRA_DEPS := sparse-llvm.o
>   sparse-llvm.o $(sparse-llvm_EXTRA_DEPS): BASIC_CFLAGS += $(LLVM_CFLAGS)
> 
> In order to suppress the warnings, we remove the duplication of
> the sparse-llvm.o target in the above rule.
> 
> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>

I already commit a similar fix to remove the duplication.
I did not realize it can generate warning though.

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 35e3801..ba2ba85 100644
--- a/Makefile
+++ b/Makefile
@@ -90,7 +90,7 @@  LLVM_LIBS := $(shell llvm-config --libs)
 PROGRAMS += $(LLVM_PROGS)
 INST_PROGRAMS += sparse-llvm sparsec
 sparse-llvm_EXTRA_DEPS := sparse-llvm.o
-sparse-llvm.o $(sparse-llvm_EXTRA_DEPS): BASIC_CFLAGS += $(LLVM_CFLAGS)
+$(sparse-llvm_EXTRA_DEPS): BASIC_CFLAGS += $(LLVM_CFLAGS)
 sparse-llvm_EXTRA_OBJS := $(LLVM_LIBS)
 endif
 endif