Re: [PATCH spice 03/18] build-sys: build a noinst libtest.la to link to

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

 



Hi

On Wed, Dec 16, 2015 at 10:44 AM, Frediano Ziglio <fziglio@xxxxxxxxxx> wrote:
> You are not... convenient library should not be linked to programs!
> Is in libtool documentation.

https://www.gnu.org/software/libtool/manual/html_node/Static-libraries.html
"The key is remembering that a convenience library contains PIC
objects, and can be linked where a list of PIC objects makes sense;
i.e. into a shared library. A static convenience library contains
non-PIC objects, so can be linked into an old static library, or a
program. "

Having -static or not doesn't change the result. All objects are
compiled with -fPIC. And ar of PIC objects + ld/elf is fine linking a
program or a library that way. Searching a bit over the web, it seems
to be a common practice for quite a while. Do we care so much about
other non-elf compilers/linkers that could in theory have issues? Even
win32 dll are fine with this (I created a small project to test this
attached). Do you know an arch/compiler that wouldn't support this?

What are the alternatives? To compile the library twice and pass all
the needed library flags when linking? I don't think we need to do all
that for something hypotetical we can't  test.


-- 
Marc-André Lureau
commit 4b5f87670fa866499812e202c2fb7b95df1c3f34
Author: Marc-André Lureau <marcandre.lureau@xxxxxxxxx>
Date:   Wed Dec 16 13:38:23 2015 +0100

    example of noinst_LTLIBRARIES being used by both dynamic library and
    static program linking

diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..10b1311
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,11 @@
+noinst_LTLIBRARIES = libstatic.la
+libstatic_la_SOURCES = foo.c
+
+lib_LTLIBRARIES = libexport.la
+libexport_la_LIBADD = libstatic.la
+libexport_la_LDFLAGS = -no-undefined
+libexport_la_SOURCES =
+
+noinst_PROGRAMS = test
+test_SOURCES = test.c
+test_LDADD = libstatic.la
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..c3ffefd
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,9 @@
+AC_INIT([test], [1])
+AM_INIT_AUTOMAKE([foreign])
+
+AC_PROG_CC
+AM_PROG_AR
+LT_INIT([win32-dll])
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/foo.c b/foo.c
new file mode 100644
index 0000000..0d38d43
--- /dev/null
+++ b/foo.c
@@ -0,0 +1,2 @@
+void foo(void) {
+}
diff --git a/foo.h b/foo.h
new file mode 100644
index 0000000..ee83a3d
--- /dev/null
+++ b/foo.h
@@ -0,0 +1 @@
+void foo(void);
diff --git a/test.c b/test.c
new file mode 100644
index 0000000..734ac11
--- /dev/null
+++ b/test.c
@@ -0,0 +1,5 @@
+#include "foo.h"
+
+void main(void) {
+    foo();
+}
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]