2015-12-31 16:06:40

by Vegard Nossum

[permalink] [raw]
Subject: [PATCH] um: link with -lpthread

Similarly to commit fb1770aa78a43530940d0c2dd161e77bc705bdac, with gcc 5
on Ubuntu and CONFIG_STATIC_LINK=y I was seeing these linker errors:

/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/librt.a(timer_create.o): In function `__timer_create_new':
(.text+0xcd): undefined reference to `pthread_once'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/librt.a(timer_create.o): In function `__timer_create_new':
(.text+0x126): undefined reference to `pthread_attr_init'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/librt.a(timer_create.o): In function `__timer_create_new':
(.text+0x168): undefined reference to `pthread_attr_setdetachstate'
[...]

Obviously we also need -lpthread for librt.a.

Signed-off-by: Vegard Nossum <[email protected]>
---
scripts/link-vmlinux.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index dacf71a..ba6c34e 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -62,7 +62,7 @@ vmlinux_link()
-Wl,--start-group \
${KBUILD_VMLINUX_MAIN} \
-Wl,--end-group \
- -lutil -lrt ${1}
+ -lutil -lrt -lpthread ${1}
rm -f linux
fi
}
--
1.9.1


2015-12-31 16:51:56

by Thomas Meyer

[permalink] [raw]
Subject: Re: [uml-devel] [PATCH] um: link with -lpthread

Am 31.12.2015 5:06 nachm. schrieb Vegard Nossum <[email protected]>:
>
> Similarly to commit fb1770aa78a43530940d0c2dd161e77bc705bdac, with gcc 5
> on Ubuntu and CONFIG_STATIC_LINK=y I was seeing these linker errors:

Hi,

Oops, yes this patch looks good to me. Honestly I did never test the static link case. Sorry.

With kind regards
Thomas

>
> /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/librt.a(timer_create.o): In function `__timer_create_new':
> (.text+0xcd): undefined reference to `pthread_once'
> /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/librt.a(timer_create.o): In function `__timer_create_new':
> (.text+0x126): undefined reference to `pthread_attr_init'
> /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/librt.a(timer_create.o): In function `__timer_create_new':
> (.text+0x168): undefined reference to `pthread_attr_setdetachstate'
> [...]
>
> Obviously we also need -lpthread for librt.a.
>
> Signed-off-by: Vegard Nossum <[email protected]>
> ---
> scripts/link-vmlinux.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> index dacf71a..ba6c34e 100755
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -62,7 +62,7 @@ vmlinux_link()
> -Wl,--start-group                                    \
> ${KBUILD_VMLINUX_MAIN}                      \
> -Wl,--end-group                                      \
> - -lutil -lrt ${1}
> + -lutil -lrt -lpthread ${1}
> rm -f linux
> fi
> }
> --
> 1.9.1
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> User-mode-linux-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2015-12-31 16:41:08

by Richard Weinberger

[permalink] [raw]
Subject: Re: [uml-devel] [PATCH] um: link with -lpthread

Am 31.12.2015 um 17:21 schrieb Thomas Meyer:
> Am 31.12.2015 5:06 nachm. schrieb Vegard Nossum <[email protected]>:
>>
>> Similarly to commit fb1770aa78a43530940d0c2dd161e77bc705bdac, with gcc 5
>> on Ubuntu and CONFIG_STATIC_LINK=y I was seeing these linker errors:
>
> Hi,
>
> Oops, yes this patch looks good to me. Honestly I did never test the static link case. Sorry.

Thanks for fixing this.
I'm back from being MIA and start collecting patches soon.

Thanks,
//richard