# Compiling with --prefer-non-pic

- Thread: https://externals.io/message/9827
- Original archive: https://news-web.php.net/php.internals/9827
- Started by Olivier Hill on 2004-05-13T02:33:49+00:00
- Messages: 2
- 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

---

## #9827 — Olivier Hill — 2004-05-13T02:33:49+00:00

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

Good evening,

Over a year ago, Rasmus and Ilia had a discussion on the list about 
building the Apache DSO with non-PIC code.

My question is, what is the easiest way to build with --prefer-non-pic 
using a release tarball? Would it be possible to add a ./configure 
option, because right now I'm editing files manually.

Sincerely,
Olivier
-- 
GB/E/IT d+ s+:+ a-- C++$ UL++++$ P++++ L+++$ E- W++$ N- ?o ?K w--(---) 
!O M+$ V- PS+ PE- Y PGP t++ 5-- X+@ R- tv++ b++(+++) DI++++ D+ G++ e+>++ 
h(*) r y+(?)

---

## #9828 — Rasmus Lerdorf — 2004-05-13T03:23:34+00:00

URL: https://externals.io/message/9827#9828 · In reply to: #9827

> Over a year ago, Rasmus and Ilia had a discussion on the list about
> building the Apache DSO with non-PIC code.
>
> My question is, what is the easiest way to build with --prefer-non-pic
> using a release tarball? Would it be possible to add a ./configure
> option, because right now I'm editing files manually.

Well, the following is what needs to be changed.  I have not had the
mental energy to figure out the magic incantation to get a configure flag
to do this:

--- acinclude.m4.orig   Tue Nov 11 13:36:31 2003
+++ acinclude.m4        Tue Nov 11 13:35:57 2003
@@ -777,10 +777,10 @@
   php_lo=o

   shared_c_pre='$(LIBTOOL) --mode=compile $(CC)'
-  shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -prefer-pic'
+  shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -prefer-non-pic'
   shared_c_post=
   shared_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
-  shared_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) -prefer-pic'
+  shared_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) -prefer-non-pic'
   shared_cxx_post=
   shared_lo=lo

@@ -1166,7 +1166,7 @@
        \$(LIBTOOL) --mode=install cp $3/$1.la \$(phplibdir)

 $3/$1.la: \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_DEPENDENCIES)
-       \$(LIBTOOL) --mode=link ifelse($4,,[\$(CC)],[\$(CXX)]) \$(COMMON_FLAGS) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(LDFLAGS) -o \[$]@ -export-dynamic -avoid-version -prefer-pic -module -rpath \$(phplibdir) \$(EXTRA_LDFLAGS) \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_LIBADD)
+       \$(LIBTOOL) --mode=link ifelse($4,,[\$(CC)],[\$(CXX)]) \$(COMMON_FLAGS) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(LDFLAGS) -o \[$]@ -export-dynamic -avoid-version -prefer-non-pic -module -rpath \$(phplibdir) \$(EXTRA_LDFLAGS) \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_LIBADD)

 EOF
 ])
Index: configure.in
===================================================================
RCS file: /repository/php-src/configure.in,v
retrieving revision 1.396.2.61
diff -u -p -w -r1.396.2.61 configure.in
--- configure.in       30 Jul 2003 13:20:49 -0000      1.396.2.61
+++ configure.in       4 Aug 2003 20:26:23 -0000
@@ -818,7 +818,7 @@ program|static)
 ;;
 shared)
     enable_static=no
-    standard_libtool_flag=-prefer-pic
+    standard_libtool_flag=-prefer-non-pic
     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -avoid-version -module"
 ;;
 esac
