cowboyd/libv8 — pull request #73 by ignisf (2013-01-09 11:00:04+00:00)
Title: Linking against libv8 fails with a 'Malformed archive' error

On Linux GYP passes crsT flags to `ar` which creates thin archives that do not include libv8's .o files:

```Python
def RunSystemTests(flavor):
"""Run tests against the system to compute default settings for commands.

Returns:
dictionary of settings matching the block of command-lines used in
SHARED_HEADER. E.g. the dictionary will contain a ARFLAGS.target
key for the default ARFLAGS for the target ar command.
"""
# Compute flags used for building static archives.
# N.B.: this fallback logic should match the logic in SHARED_HEADER.
# See comment there for more details.
ar_target = GetEnvironFallback(('AR_target', 'AR'), 'ar')
cc_target = GetEnvironFallback(('CC_target', 'CC'), 'cc')
arflags_target = 'crs'
# ar -T enables thin archives on Linux. OS X's ar supports a -T flag, but it
# does something useless (it limits filenames in the archive to 15 chars).
if flavor != 'mac' and gyp.system_test.TestArSupportsT(ar_command=ar_target,
cc_command=cc_target):
arflags_target = 'crsT'

ar_host = os.environ.get('AR_host', 'ar')
cc_host = os.environ.get('CC_host', 'gcc')
arflags_host = 'crs'
# It feels redundant to compute this again given that most builds aren't
# cross-compiles, but due to quirks of history CC_host defaults to 'gcc'
# while CC_target defaults to 'cc', so the commands really are different
# even though they're nearly guaranteed to run the same code underneath.
if flavor != 'mac' and gyp.system_test.TestArSupportsT(ar_command=ar_host,
cc_command=cc_host):
arflags_host = 'crsT'

return { 'ARFLAGS.target': arflags_target,
'ARFLAGS.host': arflags_host }
```

While this may save space when building the gem on the host on which one is going to use it, it makes the static library not portable, which ultimately causes the Malformed archive issue when attempting to link against it.