On 12/06/2010 11:52 AM, Patrick Ohly wrote:
On Mi, 2010-11-24 at 14:07 +0000, Andris Pavenis wrote:
libsynthesissdk.a can be linked into external libsynthesis plugins, but
is built without -fPIC. It works OK for 32 bit Linux but not 64 bit Linux.
I'm getting error message:
/usr/bin/ld:
/usr/lib64/libsynthesissdk.a(libsynthesissdk_la-SDK_support.o):
relocation R_X86_64_32 against `a local symbol' can not be used when
making a shared object; recompile with -fPIC
/usr/lib64/libsynthesissdk.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
I'm aware of the need for -fPIC on 64 bit. What I don't quite understand
is that I'm not seeing that problem when compiling on it myself and that
we haven't heard of the problem elsewhere before. libsyncevolution.so
links fine against a libsynthesissdk.a.
What I see is that libtool invokes g++ with -fPIC -DPIC when compiling
libsynthesissdk.a source files. This is with libtool 2.2.6b on Debian
Testing, with --enable-shared --enable-static. Also works in other
combinations, expect with an explicit --disable-shared, but then also
libsynthesis.a is compiled without PIC mode.
In that case I wouldn't expect libsynthesissdk.a to work inside a shared
library, although I don't know whether that is formally defined anywhere
in libtool or what the common way of handling these configure flags is.
PIC mode causes a slight performance degradation, so it makes sense to
not use it in static libs which are meant to be used in executables.
I'm a bit reluctant to hard-code -fPIC in the makefile - what if the
compiler doesn't support it? Unlikely, but not impossible.
Does the attached patch work for you? If it does, then I can include it
in the next Linux libsynthesis update (which usually happens via
SyncEvolution) and it trickle into upstream libsynthesis the next time
Lukas merges back changes.
The patch is not sufficient. One must also set CFLAGS, not only
CXXFLAGS as libsynthesissdk contains also C cources. See attached
patch for details (complete updated patch, not incremental).
Some system information I forgot to mention earlier:
The problem appeared for me in CentOS-5.5, which has old
libtool-1.5.22.
Andris
--- libsynthesis_3.4.0.16/src/Makefile.am.in.pic 2010-09-09 08:27:57.000000000 +0300
+++ libsynthesis_3.4.0.16/src/Makefile.am.in 2010-12-09 08:11:56.000000000 +0200
@@ -108,6 +108,8 @@ XMLPARSE_CFLAGS_BUILTIN = -I$(srcdir)/Ta
endif
libsynthesissdk_la_LDFLAGS = -static
+libsynthesissdk_la_CFLAGS = $(PIC_CXXFLAGS)
+libsynthesissdk_la_CXXFLAGS = $(PIC_CXXFLAGS)
libsynthesissdk_la_SOURCES = @LIBSYNTHESISSDK_HEADERS@
if COND_STATIC
libsynthesissdk_la_SOURCES += @LIBSYNTHESISSDK_SOURCES_SDK_ONLY@
@@ -128,6 +130,8 @@ libsynthesissdk_la_CPPFLAGS = \
-I$(srcdir)/syncml_tk/src/sml/mgr/inc/
libsynthesisstubs_la_LDFLAGS = -static
+libsynthesisstubs_la_CFLAGS = $(libsynthesissdk_la_CXXFLAGS)
+libsynthesisstubs_la_CXXFLAGS = $(libsynthesissdk_la_CXXFLAGS)
libsynthesisstubs_la_SOURCES = sysync_SDK/Sources/enginestubs.c
libsynthesisstubs_la_CPPFLAGS = $(libsynthesissdk_la_CPPFLAGS)
--- libsynthesis_3.4.0.16/configure.in.pic 2010-09-09 08:27:57.000000000 +0300
+++ libsynthesis_3.4.0.16/configure.in 2010-12-09 08:08:40.000000000 +0200
@@ -12,6 +12,13 @@ AC_PROG_LIBTOOL
AC_PROG_MAKE_SET
AM_PROG_CC_C_O
+dnl Extract PIC flags from libtool configure for libsynthesissdk.a
+dnl (makes assumptions about libtool var naming!). Some versions
+dnl of libtool use PIC mode automatically for static libraries,
+dnl others don't (?!). See "[os-libsynthesis] libsynthesissdk.a built without -fPIC".
+PIC_CXXFLAGS="$lt_prog_compiler_pic_CXX"
+AC_SUBST(PIC_CXXFLAGS)
+
AC_ARG_ENABLE(debug-logs,
AS_HELP_STRING([--debug-logs],
[For developers: add links to call location to HTML log files. Depends on Doxygen (for HTML version of source) and g++ (for __PRETTY_FUNCTION__).]),
_______________________________________________
os-libsynthesis mailing list
[email protected]
http://lists.synthesis.ch/mailman/listinfo/os-libsynthesis