Bug 5515 - [review] libsslspamc.so & libsslspamc.so can not build without -fPIC
[review] libsslspamc.so & libsslspamc.so can not build without -fPIC
Status: RESOLVED FIXED
Product: Spamassassin
Classification: Unclassified
Component: Building & Packaging
3.2.1
Other FreeBSD
: P3 normal
: 3.2.2
Assigned To: SpamAssassin Developer Mailing List
go
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2007-06-13 15:57 UTC by Mark Martinec
Modified: 2007-06-18 09:29 UTC (History)
0 users



Attachment Type Modified Status Actions Submitter/CLA Status
the promised patch patch None Mark Martinec [HasCLA]
fix using cccdlflags patch None Justin Mason [HasCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Martinec 2007-06-13 15:57:52 UTC
Compiling for shareable libraries must produce position-independent
code (PIC) for a shareable library to build and work properly.
gcc compiler needs option -fPIC to request it to produce a PIC code.

On 32-bit Intel processors with OS in 32-bit mode one may get away
by forgetting the -fPIC, resulting .so just happens to work.

On 64-bit Intel platforms (like on a FreeBSD built in 64-bit mode)
and on other architectures one can not get away so easily,
so -fPIC should be specified every time that objects for a
shareable library are produced, regardless of platform and OS.

The attached patch adds -fPIC option to spamc/Makefile.in
when libsslspamc.so and libsslspamc.so are to be built,
avoiding ugly hacks that packagers would otherwise need
to apply.

Note that the issue is not specific to FreeBSD nor to AMD,
it is just that it was discovered there when building
for 64-bit Intel or 64-bit AMD platforms.
Comment 1 Mark Martinec 2007-06-13 15:59:05 UTC
Created attachment 3987 [details]
the promised patch
Comment 2 Justin Mason 2007-06-14 03:19:57 UTC
actually, perl is supposed to take care of this.

the "DL" part of "CCDLFLAGS" in that Makefile.in refers to dynamic loading, ie.
the -fPIC, -pic, or equivalent flag for the platform.   In turn,
spamc/configure.in takes this from the perl config like so:

# we cheat, since we *know* we have Perl installed ;)
CCDLFLAGS=`perl -e 'use Config; print $Config::Config{ccdlflags}'`
LDDLFLAGS=`perl -e 'use Config; print $Config::Config{lddlflags}'`

from perldoc Config:

       "ccdlflags"
           From dlsrc.U:

           This variable contains any special flags that might need to be passed
           to cc to link with a shared library for dynamic loading.  It is up to
           the makefile to use it.  For sunos 4.1, it should be empty.

oops.  I've just realised, we're using the wrong one.  that's for people linking
against dyn libs; we want cccdlflags:

       "cccdlflags"
           From dlsrc.U:

           This variable contains any special flags that might need to be passed
           with "cc -c" to compile modules to be used to create a shared library
           that will be used for dynamic loading.  For hpux, this should be +z.
           It is up to the makefile to use it.

on my x86 linux:

perl -e 'use Config; print $Config::Config{ccdlflags}'
-Wl,-E
perl -e 'use Config; print $Config::Config{cccdlflags}'
-fPIC

-Wl,-E will be irrelevant to us; we indeed want -fPIC.  So we should be using
cccdlflags instead of ccdlflags.

Could you check your platforms and run the second perl commandline, and verify
that it creates the right -fPIC-equivalent for that platform?  if it does, we
need to fix the configure.in to use that.
Comment 3 Mark Martinec 2007-06-14 03:40:35 UTC
> -Wl,-E will be irrelevant to us; we indeed want -fPIC.
> So we should be using cccdlflags instead of ccdlflags.

Thanks for checking! I just came across the cccdlflags too.

> Could you check your platforms and run the second perl commandline,
> and verify that it creates the right -fPIC-equivalent for that platform?
> if it does, we need to fix the configure.in to use that.

Looks good:

$ perl -le 'use Config; print $Config::Config{ccdlflags}'
  -Wl,-R/usr/local/lib/perl5/5.8.8/mach/CORE
$ perl -le 'use Config; print $Config::Config{cccdlflags}'
  -DPIC -fPIC
$ uname -a
  FreeBSD xxx 6.2-RELEASE-p5 FreeBSD 6.2-RELEASE-p5... amd64

Comment 4 Justin Mason 2007-06-15 05:51:00 UTC
Created attachment 3992 [details]
fix using cccdlflags

ok, here's a patch that uses cccdlflags instead of ccdlflags; please vote...
Comment 5 Justin Mason 2007-06-15 08:36:23 UTC
applied to trunk:

: jm 299...; svn commit -m "bug 5515: libsslspamc.so & libsslspamc.so can not build
 without -fPIC, but we were picking up the wrong CFLAGS to do this. fix"
spamc/configure* spamc/Makefile.in
Sending        spamc/Makefile.in
Sending        spamc/configure
Sending        spamc/configure.in
Transmitting file data ...
Committed revision 547714.
Comment 6 Sidney Markowitz 2007-06-15 08:42:59 UTC
+1
Comment 7 Daryl C. W. O'Shea 2007-06-17 20:11:31 UTC
+1
Comment 8 Justin Mason 2007-06-18 09:29:54 UTC
applied for 3.2.2:

: jm 164...; svn commit -m "bug 5515: libsslspamc.so & libsslspamc.so can not
build without -fPIC, but we were picking up the wrong CFLAGS to do this. fix"
spamc/configure spamc/Makefile.in spamc/configure.in
Sending        spamc/Makefile.in
Sending        spamc/configure
Sending        spamc/configure.in
Transmitting file data ...
Committed revision 548399.