diff mbox

Link binaries with system libraries needed by LLVM

Message ID 1412259588-8542-1-git-send-email-anatol.pomozov@gmail.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Anatol Pomozov Oct. 2, 2014, 2:19 p.m. UTC
It is needed on Linux Arch with latest LLVM installed

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
---
 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Josh Triplett Oct. 2, 2014, 7:53 p.m. UTC | #1
On Thu, Oct 02, 2014 at 07:19:48AM -0700, Anatol Pomozov wrote:
> It is needed on Linux Arch with latest LLVM installed
> 
> Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>

One comment below.

>  Makefile | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 28c4df6..25087d7 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -112,11 +112,12 @@ LLVM_PROGS := sparse-llvm
>  $(LLVM_PROGS): LD := g++
>  LLVM_LDFLAGS := $(shell llvm-config --ldflags)
>  LLVM_CFLAGS := $(shell llvm-config --cflags | sed -e "s/-DNDEBUG//g")
> +LLVM_SYSTEM_LIBS := $(shell llvm-config --system-libs)
>  LLVM_LIBS := $(shell llvm-config --libs)
>  PROGRAMS += $(LLVM_PROGS)
>  INST_PROGRAMS += sparse-llvm sparsec
>  sparse-llvm.o: BASIC_CFLAGS += $(LLVM_CFLAGS)
> -sparse-llvm_EXTRA_OBJS := $(LLVM_LIBS) $(LLVM_LDFLAGS)
> +sparse-llvm_EXTRA_OBJS := $(LLVM_SYSTEM_LIBS) $(LLVM_LIBS) $(LLVM_LDFLAGS)

Does llvm-config support passing multiple options, such as "llvm-config
--libs --system-libs"?  If so, I'd suggest just adding --system-libs to
the call in LLVM_LIBS, rather than adding a second variable.

(It's obnoxious that llvm requires its own configuration tool rather
than using pkg-config.)

- Josh Triplett
--
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
Anatol Pomozov Oct. 2, 2014, 8:05 p.m. UTC | #2
Hi

On Thu, Oct 2, 2014 at 12:53 PM, Josh Triplett <josh@joshtriplett.org> wrote:
> On Thu, Oct 02, 2014 at 07:19:48AM -0700, Anatol Pomozov wrote:
>> It is needed on Linux Arch with latest LLVM installed
>>
>> Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
>
> One comment below.
>
>>  Makefile | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 28c4df6..25087d7 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -112,11 +112,12 @@ LLVM_PROGS := sparse-llvm
>>  $(LLVM_PROGS): LD := g++
>>  LLVM_LDFLAGS := $(shell llvm-config --ldflags)
>>  LLVM_CFLAGS := $(shell llvm-config --cflags | sed -e "s/-DNDEBUG//g")
>> +LLVM_SYSTEM_LIBS := $(shell llvm-config --system-libs)
>>  LLVM_LIBS := $(shell llvm-config --libs)
>>  PROGRAMS += $(LLVM_PROGS)
>>  INST_PROGRAMS += sparse-llvm sparsec
>>  sparse-llvm.o: BASIC_CFLAGS += $(LLVM_CFLAGS)
>> -sparse-llvm_EXTRA_OBJS := $(LLVM_LIBS) $(LLVM_LDFLAGS)
>> +sparse-llvm_EXTRA_OBJS := $(LLVM_SYSTEM_LIBS) $(LLVM_LIBS) $(LLVM_LDFLAGS)
>
> Does llvm-config support passing multiple options, such as "llvm-config
> --libs --system-libs"?  If so, I'd suggest just adding --system-libs to
> the call in LLVM_LIBS, rather than adding a second variable.

Thanks. Yeap it is better. Will send update in a second.

>
> (It's obnoxious that llvm requires its own configuration tool rather
> than using pkg-config.)
>
> - Josh Triplett
--
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
Ramsay Jones Oct. 2, 2014, 8:11 p.m. UTC | #3
On 02/10/14 20:53, Josh Triplett wrote:
> On Thu, Oct 02, 2014 at 07:19:48AM -0700, Anatol Pomozov wrote:
>> It is needed on Linux Arch with latest LLVM installed
>>
>> Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
> 
> One comment below.
> 
>>  Makefile | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 28c4df6..25087d7 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -112,11 +112,12 @@ LLVM_PROGS := sparse-llvm
>>  $(LLVM_PROGS): LD := g++
>>  LLVM_LDFLAGS := $(shell llvm-config --ldflags)
>>  LLVM_CFLAGS := $(shell llvm-config --cflags | sed -e "s/-DNDEBUG//g")
>> +LLVM_SYSTEM_LIBS := $(shell llvm-config --system-libs)
>>  LLVM_LIBS := $(shell llvm-config --libs)
>>  PROGRAMS += $(LLVM_PROGS)
>>  INST_PROGRAMS += sparse-llvm sparsec
>>  sparse-llvm.o: BASIC_CFLAGS += $(LLVM_CFLAGS)
>> -sparse-llvm_EXTRA_OBJS := $(LLVM_LIBS) $(LLVM_LDFLAGS)
>> +sparse-llvm_EXTRA_OBJS := $(LLVM_SYSTEM_LIBS) $(LLVM_LIBS) $(LLVM_LDFLAGS)
> 

This issue is addressed in commit d92353b4eacbac54d693edd62fb565f071e3ba86
("sparse-llvm: Fix LLVM 3.5 linker errors", 24-09-2014) in the main sparse
repo and in a follow-up commit a5bdeee9e145cc4313526f9722f80674321ab491
("Use LLVM_CONFIG instead of llvm-config in Makefile", 24-09-2014) in 
Christopher's public repo on kernel.org.

Neither commit is in a released version of sparse.

> Does llvm-config support passing multiple options, such as "llvm-config
> --libs --system-libs"?  If so, I'd suggest just adding --system-libs to
> the call in LLVM_LIBS, rather than adding a second variable.

An old version of llvm-config (prior to adding --system-libs) would
respond like so:

    $ llvm-config --libs --system-libs
    -lLLVM-3.4.2
    usage: llvm-config <OPTION>... [<COMPONENT>...]
    
    Get various configuration information needed to compile programs which use
    LLVM.  Typically called from 'configure' scripts.  Examples:
      llvm-config --cxxflags
      llvm-config --ldflags
      llvm-config --libs engine bcreader scalaropts

    Options:
      --version         Print LLVM version.
      --prefix          Print the installation prefix.
      --src-root        Print the source root LLVM was built from.
      --obj-root        Print the object root used to build LLVM.
...
      --build-mode      Print build mode of LLVM tree (e.g. Debug or Release).
    Typical components:
      all               All LLVM libraries (default).
      engine            Either a native JIT or a bitcode interpreter.
    $ echo $?
    1
    $ 

HTH

ATB,
Ramsay Jones


--
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 28c4df6..25087d7 100644
--- a/Makefile
+++ b/Makefile
@@ -112,11 +112,12 @@  LLVM_PROGS := sparse-llvm
 $(LLVM_PROGS): LD := g++
 LLVM_LDFLAGS := $(shell llvm-config --ldflags)
 LLVM_CFLAGS := $(shell llvm-config --cflags | sed -e "s/-DNDEBUG//g")
+LLVM_SYSTEM_LIBS := $(shell llvm-config --system-libs)
 LLVM_LIBS := $(shell llvm-config --libs)
 PROGRAMS += $(LLVM_PROGS)
 INST_PROGRAMS += sparse-llvm sparsec
 sparse-llvm.o: BASIC_CFLAGS += $(LLVM_CFLAGS)
-sparse-llvm_EXTRA_OBJS := $(LLVM_LIBS) $(LLVM_LDFLAGS)
+sparse-llvm_EXTRA_OBJS := $(LLVM_SYSTEM_LIBS) $(LLVM_LIBS) $(LLVM_LDFLAGS)
 endif
 endif