unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Incorrect guile pkg-config --libs and --cflags
@ 2013-04-15  8:26 Jan Synacek
  2013-04-15 11:58 ` Daniel Hartwig
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Synacek @ 2013-04-15  8:26 UTC (permalink / raw)
  To: guile-devel

Hello list,

This part of guile-2.0.pc is quite confusing and I think it's wrong:

...
Libs: -L${libdir} -lguile-2.0 -lgc
...
Cflags: -I${pkgincludedir}/2.0  -pthread

Shouldn't the '-pthread' be in Libs, instead of Cflags? Compilation can fail
when relying on pkg-config [1] (the bug mentions guile-1.8, but it's the same
with the latest stable guile).

Cheers,

-- 
Jan Synacek
Software Engineer, Red Hat

[1] https://bugzilla.redhat.com/show_bug.cgi?id=951781



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

* Re: Incorrect guile pkg-config --libs and --cflags
  2013-04-15  8:26 Incorrect guile pkg-config --libs and --cflags Jan Synacek
@ 2013-04-15 11:58 ` Daniel Hartwig
  2013-04-15 13:45   ` Daniel Hartwig
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Hartwig @ 2013-04-15 11:58 UTC (permalink / raw)
  To: Jan Synacek; +Cc: guile-devel

On 15 April 2013 16:26, Jan Synacek <jsynacek@redhat.com> wrote:
> Hello list,
>
> This part of guile-2.0.pc is quite confusing and I think it's wrong:
>
> ...
> Libs: -L${libdir} -lguile-2.0 -lgc
> ...
> Cflags: -I${pkgincludedir}/2.0  -pthread
>
> Shouldn't the '-pthread' be in Libs, instead of Cflags?

-pthread is for the preprocessor and linker, so it is appropriate in
CFLAGS.  It is not required in LIBS due to libguile-2.0 already linked
against libpthread.

> Compilation can fail
> when relying on pkg-config [1] (the bug mentions guile-1.8, but it's the same
> with the latest stable guile).
>

Have never seen this to be a problem (debian sid), even using exact
same arguments as in [1]:

$ pkg-config --cflags guile-2.0
-pthread -I/usr/local/include/guile/2.0
$ pkg-config --libs guile-2.0
-L/usr/local/lib -lguile-2.0 -lgc
$ ldd /usr/local/lib/libguile-2.0.so | grep pthread
        libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb7372000)
$ gcc -std=c11 -O3 -g -c -Wall test.c -o test.o $(pkg-config --cflags guile-2.0)
$ gcc -std=c11 -O3 -g -Wall test.o -o test $(pkg-config --libs guile-2.0)
$ gcc --version | sed 1q
gcc (Debian 4.7.2-5) 4.7.2
$ ld --version | sed 1q
GNU ld (GNU Binutils for Debian) 2.22

Something related to this error perhaps (never seen it):
/lib64/libpthread.so.0: could not read symbols: Invalid operation

or peculiar to the linker, libguile on your system, other?



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

* Re: Incorrect guile pkg-config --libs and --cflags
  2013-04-15 11:58 ` Daniel Hartwig
@ 2013-04-15 13:45   ` Daniel Hartwig
  2013-04-15 13:59     ` Daniel Hartwig
                       ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Daniel Hartwig @ 2013-04-15 13:45 UTC (permalink / raw)
  To: Jan Synacek; +Cc: guile-devel

On 15 April 2013 19:58, Daniel Hartwig <mandyke@gmail.com> wrote:
> or peculiar to the linker, libguile on your system, other?

I see that this is related to the linker in fedora, which debian seems
also in the process of supporting.  Indirect linkage like this is out
(apparently), and LIBS should properly include -pthread option.

<https://fedoraproject.org/wiki/UnderstandingDSOLinkChange>
<http://wiki.debian.org/ToolChain/DSOLinking#Not_resolving_symbols_in_indirect_dependent_shared_libraries>



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

* Re: Incorrect guile pkg-config --libs and --cflags
  2013-04-15 13:45   ` Daniel Hartwig
@ 2013-04-15 13:59     ` Daniel Hartwig
  2013-04-16  6:35     ` Jan Synacek
  2013-04-24  7:21     ` Mark H Weaver
  2 siblings, 0 replies; 7+ messages in thread
From: Daniel Hartwig @ 2013-04-15 13:59 UTC (permalink / raw)
  To: Jan Synacek; +Cc: guile-devel

On 15 April 2013 21:45, Daniel Hartwig <mandyke@gmail.com> wrote:
> On 15 April 2013 19:58, Daniel Hartwig <mandyke@gmail.com> wrote:
>> or peculiar to the linker, libguile on your system, other?
>
> I see that this is related to the linker in fedora, which debian seems
> also in the process of supporting.  Indirect linkage like this is out
> (apparently), and LIBS should properly include -pthread option.
>
> <https://fedoraproject.org/wiki/UnderstandingDSOLinkChange>
> <http://wiki.debian.org/ToolChain/DSOLinking#Not_resolving_symbols_in_indirect_dependent_shared_libraries>

Though I cant yet reproduce the error, may have to rebuild the library
using gold to trigger?



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

* Re: Incorrect guile pkg-config --libs and --cflags
  2013-04-15 13:45   ` Daniel Hartwig
  2013-04-15 13:59     ` Daniel Hartwig
@ 2013-04-16  6:35     ` Jan Synacek
  2013-04-24  7:21     ` Mark H Weaver
  2 siblings, 0 replies; 7+ messages in thread
From: Jan Synacek @ 2013-04-16  6:35 UTC (permalink / raw)
  To: Daniel Hartwig; +Cc: guile-devel

On 04/15/2013 03:45 PM, Daniel Hartwig wrote:
> On 15 April 2013 19:58, Daniel Hartwig <mandyke@gmail.com> wrote:
>> or peculiar to the linker, libguile on your system, other?
> 
> I see that this is related to the linker in fedora, which debian seems
> also in the process of supporting.  Indirect linkage like this is out
> (apparently), and LIBS should properly include -pthread option.
> 
> <https://fedoraproject.org/wiki/UnderstandingDSOLinkChange>
> <http://wiki.debian.org/ToolChain/DSOLinking#Not_resolving_symbols_in_indirect_dependent_shared_libraries>
> 

Indeed, the linker in fedora does not use indirect linking by default (or maybe
at all). I can patch guile-{1.8,2.0}.pc to correctly add the libraries, though
I'm not sure if that will work.

Is it a good idea to rely on indirect linking as you (upstream) do now? Maybe it
would be better to assume that indirect linking is not supported and have all
the linker flags in the pkgconfig file. Or are there any other implications that
I may not be aware of?



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

* Re: Incorrect guile pkg-config --libs and --cflags
  2013-04-15 13:45   ` Daniel Hartwig
  2013-04-15 13:59     ` Daniel Hartwig
  2013-04-16  6:35     ` Jan Synacek
@ 2013-04-24  7:21     ` Mark H Weaver
  2013-04-25  5:49       ` Sebastian Freundt
  2 siblings, 1 reply; 7+ messages in thread
From: Mark H Weaver @ 2013-04-24  7:21 UTC (permalink / raw)
  To: Daniel Hartwig; +Cc: Sebastian Freundt, guile-devel

Daniel Hartwig <mandyke@gmail.com> writes:

> On 15 April 2013 19:58, Daniel Hartwig <mandyke@gmail.com> wrote:
>> or peculiar to the linker, libguile on your system, other?
>
> I see that this is related to the linker in fedora, which debian seems
> also in the process of supporting.  Indirect linkage like this is out
> (apparently), and LIBS should properly include -pthread option.
>
> <https://fedoraproject.org/wiki/UnderstandingDSOLinkChange>
> <http://wiki.debian.org/ToolChain/DSOLinking#Not_resolving_symbols_in_indirect_dependent_shared_libraries>

FWIW, I've observed that on my Debian Wheezy system, almost all of the
*.pc files that include "-pthread" in Cflags also include it in Libs.

In the relevant bug report
<https://bugzilla.redhat.com/show_bug.cgi?id=951781>, Sebastian Freundt
claims that linking "any trivial test file test.c" against libguile
(1.8) fails on Fedora 18 unless -pthread is used during linking.

Apparently this is the case even if the main program does not directly
use the pthread API.  I confess that I don't understand the reason for
this, but if it's true, I'm inclined to believe that either we should
add -pthread to the pkg-config Libs, or that perhaps this is a bug in
the toolchain.  One way or another, $(pkg-config --libs guile-*) should
provide what is needed to link a minimal test program with guile.

I've taken the liberty of adding Sebastian to the CC list, since he
already expressed an interest in raising this issue with upstream.
Perhaps he can shed some light on this issue.

     Regards,
       Mark



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

* Re: Incorrect guile pkg-config --libs and --cflags
  2013-04-24  7:21     ` Mark H Weaver
@ 2013-04-25  5:49       ` Sebastian Freundt
  0 siblings, 0 replies; 7+ messages in thread
From: Sebastian Freundt @ 2013-04-25  5:49 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: guile-devel

Mark H Weaver <mhw@netris.org> writes:

> Daniel Hartwig <mandyke@gmail.com> writes:
>
>> On 15 April 2013 19:58, Daniel Hartwig <mandyke@gmail.com> wrote:
>>> or peculiar to the linker, libguile on your system, other?
>>
>> I see that this is related to the linker in fedora, which debian seems
>> also in the process of supporting.  Indirect linkage like this is out
>> (apparently), and LIBS should properly include -pthread option.
>>
>> <https://fedoraproject.org/wiki/UnderstandingDSOLinkChange>
>> <http://wiki.debian.org/ToolChain/DSOLinking#Not_resolving_symbols_in_indirect_dependent_shared_libraries>
>
> FWIW, I've observed that on my Debian Wheezy system, almost all of the
> *.pc files that include "-pthread" in Cflags also include it in Libs.
>
> In the relevant bug report
> <https://bugzilla.redhat.com/show_bug.cgi?id=951781>, Sebastian Freundt
> claims that linking "any trivial test file test.c" against libguile
> (1.8) fails on Fedora 18 unless -pthread is used during linking.
>
> Apparently this is the case even if the main program does not directly
> use the pthread API.  I confess that I don't understand the reason for
> this, but if it's true, I'm inclined to believe that either we should
> add -pthread to the pkg-config Libs, or that perhaps this is a bug in
> the toolchain.  One way or another, $(pkg-config --libs guile-*) should
> provide what is needed to link a minimal test program with guile.
>
> I've taken the liberty of adding Sebastian to the CC list, since he
> already expressed an interest in raising this issue with upstream.
> Perhaps he can shed some light on this issue.

Hi there,
indeed I can shed some light, on a Fedora 16/17/18 try:

gcc -std=c99 -x c -c -o trivial.o -O2 $(pkg-config --cflags guile-1.8) - <<'EOF'
#include <libguile.h>

int
main(void)
{
        static scm_t_bits scm_tc16_echs_mod;
        SCM XSMOB;
        char smob[4];

        SCM_NEWSMOB(XSMOB, scm_tc16_echs_mod, smob);
        return 0;
}
EOF

followed by:

gcc -std=c99 -o trivial trivial.o $(pkg-config --libs guile-1.8) 
/usr/bin/ld: trivial.o: undefined reference to symbol 'pthread_getspecific@@GLIBC_2.2.5'
/usr/bin/ld: note: 'pthread_getspecific@@GLIBC_2.2.5' is defined in DSO /lib64/libpthread.so.0 so try adding it to the linker command line
/lib64/libpthread.so.0: could not read symbols: Invalid operation
collect2: ld returned 1 exit status

whereas it would have worked if pkg-config --libs also emitted -lpthread.


Just for the sake of completeness:

ldd /usr/lib64/libguile.so
        linux-vdso.so.1 =>  (0x00007fff9a3ff000)
        libgmp.so.3 => /usr/lib64/libgmp.so.3 (0x0000003674600000)
        libcrypt.so.1 => /lib64/libcrypt.so.1 (0x0000003677600000)
        libm.so.6 => /lib64/libm.so.6 (0x0000003673e00000)
        libltdl.so.7 => /usr/lib64/libltdl.so.7 (0x00000033b2400000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003672e00000)
        libc.so.6 => /lib64/libc.so.6 (0x0000003672a00000)
        /lib64/ld-linux-x86-64.so.2 (0x0000003672600000)
        libfreebl3.so => /lib64/libfreebl3.so (0x0000003677200000)
        libdl.so.2 => /lib64/libdl.so.2 (0x0000003673200000)

guile --version
Guile 1.8.8
Copyright (c) 1995, 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation
Guile may be distributed under the terms of the GNU General Public Licence;
certain other uses are permitted as well.  For details, see the file
`COPYING', which is included in the Guile distribution.
There is no warranty, to the extent permitted by law.

Cheers,
Sebastian



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

end of thread, other threads:[~2013-04-25  5:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-15  8:26 Incorrect guile pkg-config --libs and --cflags Jan Synacek
2013-04-15 11:58 ` Daniel Hartwig
2013-04-15 13:45   ` Daniel Hartwig
2013-04-15 13:59     ` Daniel Hartwig
2013-04-16  6:35     ` Jan Synacek
2013-04-24  7:21     ` Mark H Weaver
2013-04-25  5:49       ` Sebastian Freundt

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).