# libtool -prefer-non-pic for apxs builds?

- Thread: https://externals.io/message/3682
- Original archive: https://news-web.php.net/php.internals/3682
- Started by Rasmus Lerdorf on 2003-08-01T16:22:25+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #3682 — Rasmus Lerdorf — 2003-08-01T16:22:25+00:00

URL: https://externals.io/message/3682#3682

Guys, what do you think about defaulting the build to use -prefer-non-pic
and having libtool build a non-pic libphp4.so when building the Apache
DSO?  That library isn't linked into other programs anyway, and Apache's
fork+exec model ensures the pages will be shared regardless of pic.  I
don't really see what we gain by building it pic, and we certainly lose
quite a bit by doing so.  In the order of 15-20% execution time on both
FreeBSD and Linux with gcc in my tests.

-Rasmus

---

## #3685 — Ilia Alshanetsky — 2003-08-01T18:31:57+00:00

URL: https://externals.io/message/3682#3685 · In reply to: #3682

> Guys, what do you think about defaulting the build to use -prefer-non-pic
> and having libtool build a non-pic libphp4.so when building the Apache
> DSO?  That library isn't linked into other programs anyway, and Apache's
> fork+exec model ensures the pages will be shared regardless of pic.  I
> don't really see what we gain by building it pic, and we certainly lose
> quite a bit by doing so.  In the order of 15-20% execution time on both
> FreeBSD and Linux with gcc in my tests.

I think this is a good idea, I've been manually doing the same thing on my 
servers by compiling cli & apache separately. Performance wise in my 
experience no-pic code is 25-30% faster on Linux. So far it worked perfectly 
and I had not experienced any problems. I see no reason why we cannot offer 
all PHP users the same performance advantages.

Ilia

---

## #3687 — Sascha Schumann — 2003-08-01T20:03:27+00:00

URL: https://externals.io/message/3682#3687 · In reply to: #3685

Not all dls support non-PIC code in DSOs.  If you know that
    your system handles it fine, just pass the right -pic flag to
    configure.

    - Sascha



> 
> > […]
>
> I think this is a good idea, I've been manually doing the same thing on my
> servers by compiling cli & apache separately. Performance wise in my
> experience no-pic code is 25-30% faster on Linux. So far it worked perfectly
> and I had not experienced any problems. I see no reason why we cannot offer
> all PHP users the same performance advantages.
>
> Ilia

---

## #3689 — Rasmus Lerdorf — 2003-08-01T20:11:58+00:00

URL: https://externals.io/message/3682#3689 · In reply to: #3687

>     Not all dls support non-PIC code in DSOs.  If you know that
>     your system handles it fine, just pass the right -pic flag to
>     configure.

Can't we check for that at configure time?

And I don't think we can do it at configure time currently.  At least the
obvious --without-pic doesn't work.  configure.in has:

unset with_pic

case $php_build_target in
program|static)
    standard_libtool_flag='-prefer-non-pic -static'
    if test -z "$PHP_MODULES"; then
        enable_shared=no
    fi
;;
shared)
    enable_static=no
    standard_libtool_flag=-prefer-pic
    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -avoid-version -module"
;;
esac

So it looks to me like the build target overrides the pic setting and
there is no way to build a shared library using -prefer-non-pic

-Rasmus

---

## #3688 — Ilia Alshanetsky — 2003-08-01T20:23:12+00:00

URL: https://externals.io/message/3682#3688 · In reply to: #3687

>     Not all dls support non-PIC code in DSOs.  If you know that
>     your system handles it fine, just pass the right -pic flag to
>     configure.

Could we not add the appropriate checks to enable this setting for people's 
who's dl support this? This is a fairly obscure point that most people are 
not aware of and consequently suffer a significant and unnecessary 
performance loss.

Ilia
