From 2d83788eff8a8e4d9934075cb8a9e77bb90c6e61 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Thu, 2 Jun 2005 09:24:24 +0000 Subject: [PATCH] Make sure -fPIC is added when compiling objects declared with the 'obj' rule. [SVN r29369] --- src/tools/gcc.jam | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/tools/gcc.jam b/src/tools/gcc.jam index c0ec7641c..65f3dfcd6 100644 --- a/src/tools/gcc.jam +++ b/src/tools/gcc.jam @@ -87,7 +87,24 @@ flags gcc.compile OPTIONS on : -pg ; # inside 'init'. if [ os.name ] != CYGWIN && [ os.name ] != NT { - flags gcc.compile OPTIONS shared/LIB : -fPIC ; + # This logic will add -fPIC for all compilations: + # + # lib a : a.cpp b ; + # obj b : b.cpp ; + # exe c : c.cpp a d ; + # obj d : d.cpp ; + # + # This all is fine, except that 'd' will be compiled with + # -fPIC even though it's not needed, as 'd' is used only in + # exe. However, it's hard to detect where a target is going to + # be used. Alternative, we can set -fPIC only when main target type + # is LIB but than 'b' will be compiled without -fPIC. In x86-64 that + # will lead to link errors. So, compile everything with -fPIC. + # + # Yet another alternative would be to create propagated + # feature, and set it when building shared libraries, but that's hard + # to implement and will increate target path length even more. + flags gcc.compile OPTIONS shared : -fPIC ; } if [ os.name ] != NT {