On OSX Lion, make without the -Dcomponent=shared_library built shared, dynamic, 
and debug versions.

The more interesting question is why he thinks he needs -fPIC for a static 
library.  The error message indicates the elf file contains a 32-bit relocation 
and it needs to be a 64-bit one.  

Position Independent Code (PIC) is typically (almost always) used in shared 
libraries.  

Statically linked libraries can have their code loaded at any address, and are 
loaded  as part of the executable at run time so they don't need to be position 
independent.  

Shared libraries can be loaded at any address and in any order, so they must be 
position independent.  Their code segments can be mapped with the MMU into 
several process' address space, so you don't have the overhead of loading that 
code into memory twice if you run the program twice at the same time.



On Jul 1, 2012, at 10:38 PM, Charles Lowell wrote:

> 
> 
> On Sunday, July 1, 2012 9:39:55 PM UTC-5, mschwartz wrote:
> make GYPFLAGS="-Dcomponent=shared_library"
> 
> Unfortunately, I need to build a static library. If I monkey patch 
> standalone.gypi to put in the -fPIC flag then it works fine, but it would be 
> nice if there were a way to specify this from the command line.
>  
> 
> I think the default is static library for OSX (x64).
> 
> Mixing static and shared libraries is really difficult with the GNU tools.  
> OSX uses the LLVM tool chain, which is similar but has significant 
> differences.
> 
> If you're building a 64-bit version on a 32-bit system, it could be that v8 
> is so big that 32-bit relocations in the code segments of the library are not 
> enough bits.
> 
> 
> On Jul 1, 2012, at 5:33 PM, Charles Lowell wrote:
> 
>> Hi,
>> 
>> I'm trying to build a shared object and link in the static v8 library. This 
>> works fine for me on OSX, but on Linux I get the following error:
>> 
>>     /usr/bin/ld: 
>> /tmp/build_321giz8disep/vendor/v8/out/x64.release/obj.target/v8_base/src/api.o:
>>  relocation R_X86_64_32S against `vtable for v8::ScriptData' can not be used 
>> when making a shared object; recompile with -fPIC
>>        
>> /tmp/build_321giz8disep/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a:
>>  could not read symbols: Bad value
>>        collect2: ld returned 1 exit status
>> 
>> Is there a way to tell GYP to build a static v8 library with -fPIC? Is there 
>> a way to do this without patching one of the gypfiles?
>> 
>> cheers,
>> Charles
>> 
> 
> 
> -- 
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to