Opened 12 years ago

Last modified 11 years ago

#1147 closed defect

Fix malformed TOC linker error on OS X — at Version 4

Reported by: historic_bruno Owned by:
Priority: If Time Permits Milestone:
Component: Build & Packages Keywords: osx, build
Cc: Patch:

Description (last modified by historic_bruno)

On OS X, after performing a build and editing some source code, errors like the following occur:

ld: in ../../../binaries/system/libengine.a, malformed archive TOC entry for _MASK__PSRETURN_Scripting_SetupFailed, offset 164452311 is beyond end of file 14363576 for architecture x86_64

or equally disturbing:

ld: in ../../../binaries/system/libengine.a(!<arch> #1/20), archive member '!<arch> #1/20' with length 100644 is not mach-o or llvm bitcode for architecture x86_64

We've been working around this by performing make clean every time, but that's a slow and frustrating process. Apparently the problem is the library table of contents needs to be updated after a rebuild, and this isn't happening automatically with ar. A suggested fix is running ranlib after ar and before ld which I can confirm works (run ranlb on the affected library after you get the error, then make again and it works). I don't know about the other suggestion of using the -s option for ar, but that's worth testing too.

Change History (4)

comment:1 by historic_bruno, 12 years ago

Description: modified (diff)

comment:2 by Kieran P, 12 years ago

Milestone: Alpha 9Alpha 10
Priority: Should HaveNice to Have

in reply to:  description comment:3 by Philip Taylor, 12 years ago

Replying to historic_bruno:

We've been working around this by performing make clean every time, but that's a slow and frustrating process.

Sounds like a "rm ../../../binaries/system/*.a" would probably be a significantly less slow workaround for this problem, until it's fixed.

comment:4 by historic_bruno, 12 years ago

Description: modified (diff)

Actually I've started running ranlib ../../../binaries/system/*.a as a work around, once I learned of the cause :)

More info: Premake inserts an ar -rcs command into the makefile, which should be doing what we want, according to the ar manpage on Lion:

     -c      Whenever an archive is created, an informational message to that
             effect is written to standard error.  If the -c option is speci-
             fied, ar creates the archive silently.
     -r      Replace or add the specified files to the archive.  If the ar-
             chive does not exist a new archive file is created.  Files that
             replace existing files do not change the order of the files
             within the archive.  New files are appended to the archive unless
             one of the options -a, -b or -i is specified.
     -s      Write an object-file index into the archive, or update an exist-
             ing one, even if no other change is made to the archive.  You may
             use this modifier flag either with any operation, or alone.  Run-
             ning `ar s' on an archive is equivalent to running `ranlib' on
             it.

The last sentence is apparently not true, as running ranlib separately on the archive fixes the error.

Last edited 12 years ago by historic_bruno (previous) (diff)
Note: See TracTickets for help on using tickets.