Re: problem building sparse 0.6.0 (sparse-llvm)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 26/04/2019 16:20, Randy Dunlap wrote:
[snip]
> Yes, that works and makes sense.  Thanks.
> 
> Here is the updated patch.
> 
> ---
> From: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
> 
> Certain macros have to be defined in order to use the llvm
> DataTypes.h header file.  Fixes these build errors when building
> sparse-llvm:
> 
>   CC      sparse-llvm.o
> In file included from /usr/include/llvm-c/Types.h:17:0,
>                  from /usr/include/llvm-c/ErrorHandling.h:17,
>                  from /usr/include/llvm-c/Core.h:18,
>                  from sparse-llvm.c:6:
> /usr/include/llvm/Support/DataTypes.h:57:3: error: #error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
>  # error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
>    ^
> /usr/include/llvm/Support/DataTypes.h:61:3: error: #error "Must #define __STDC_CONSTANT_MACROS before " "#including Support/DataTypes.h"
>  # error "Must #define __STDC_CONSTANT_MACROS before " \
>    ^
> 
> This is from using llvm 3.8.0.
> 
> Suggested-by: Ramsay Jones <ramsay@xxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
> ---
>  Makefile |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> --- sparse-0.6.0.orig/Makefile
> +++ sparse-0.6.0/Makefile
> @@ -160,7 +160,8 @@ ifeq ($(shell expr "$(LLVM_VERSION)" : '
>  LLVM_PROGS := sparse-llvm
>  $(LLVM_PROGS): LD := g++
>  LLVM_LDFLAGS := $(shell $(LLVM_CONFIG) --ldflags)
> -LLVM_CFLAGS := -I$(shell $(LLVM_CONFIG) --includedir)
> +LLVM_CFLAGS := -I$(shell $(LLVM_CONFIG) --includedir) \
> +	$(shell $(LLVM_CONFIG) --cppflags)
>  LLVM_LIBS := $(shell $(LLVM_CONFIG) --libs)
>  LLVM_LIBS += $(shell $(LLVM_CONFIG) --system-libs 2>/dev/null)
>  LLVM_LIBS += $(shell $(LLVM_CONFIG) --cxxflags | grep -F -q -e '-stdlib=libc++' && echo -lc++)

Thanks!

I just tested your patch on cygwin and, as expected, it does
not introduce any regressions.

However, I should have made it clear that I meant to suggest
that we should _replace_ the definition of LLVM_CFLAGS with
that single call to llvm-config. So, I also tested the
following on cygwin:

  $ git diff
  diff --git a/Makefile b/Makefile
  index f816a50..7e8c2ab 100644
  --- a/Makefile
  +++ b/Makefile
  @@ -165,8 +165,7 @@ ifeq ($(shell expr "$(LLVM_VERSION)" : '[3-9]\.'),2)
   LLVM_PROGS := sparse-llvm
   $(LLVM_PROGS): LD := g++
   LLVM_LDFLAGS := $(shell $(LLVM_CONFIG) --ldflags)
  -LLVM_CFLAGS := -I$(shell $(LLVM_CONFIG) --includedir) \
  -       $(shell $(LLVM_CONFIG) --cppflags)
  +LLVM_CFLAGS := $(shell $(LLVM_CONFIG) --cppflags)
   LLVM_LIBS := $(shell $(LLVM_CONFIG) --libs)
   LLVM_LIBS += $(shell $(LLVM_CONFIG) --system-libs 2>/dev/null)
   LLVM_LIBS += $(shell $(LLVM_CONFIG) --cxxflags | grep -F -q -e '-stdlib=libc++' && echo -lc++)
  $ 

... which also works! The only difference is that '-I/usr/include'
is not passed to gcc twice.

Looking at commit 65840c61dc ("build: only need includedir from
llvm-config", 2018-12-18), Luc only wanted the 'pre-processor'
flags not all of the '--cflags'. The '--cppflags' argument to
llvm-config is used for just that. ;-)

If you could confirm that the above works for you also, that
would be great. Thanks!

ATB,
Ramsay Jones




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux