Ticket #1147 (closed defect: needsinfo)
[NEEDS INFO] Fix malformed TOC linker error on OS X
| Reported by: | historic_bruno | Owned by: | |
|---|---|---|---|
| Priority: | If Time Permits | Milestone: | |
| Component: | Build & Packages | Keywords: | osx, build |
| Cc: |
Description (last modified by historic_bruno) (diff)
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
comment:2 Changed 15 months ago by k776
- Priority changed from Should Have to Nice to Have
- Milestone changed from Alpha 9 to Alpha 10
comment:3 in reply to: ↑ description Changed 15 months ago by Philip
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 Changed 15 months ago by historic_bruno
- 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.
comment:5 Changed 14 months ago by k776
- Keywords osx, build added; osx,linker removed
- Priority changed from Nice to Have to If Time Permits
comment:6 Changed 14 months ago by historic_bruno
I'm not sure if this still occurs with the latest command line tools package, at least I haven't encountered it since switching. Of course it would be nice to fix it for Snow Leopard and/or older tools.
comment:7 Changed 13 months ago by historic_bruno
- Status changed from new to closed
- Resolution set to worksforme
Marking as resolved with the latest command line tools.
comment:8 Changed 13 months ago by k776
- Status changed from closed to reopened
- Resolution worksforme deleted
Got the following invalid TOC error when compiling today. On Mac Lion, fully updated, latest development tools. Look like this issue is still alive.
==== Building pyrogenesis (release) ==== Linking pyrogenesis ld: warning: directory not found for option '-L../../../libraries/cxxtest/lib' ld: warning: directory not found for option '-L../../../libraries/valgrind/lib' ld: warning: directory not found for option '-L/opt/local/lib' ld: in ../../../binaries/system/libsimulation2.a, malformed archive TOC entry for vtable for CCmpObstructionManager, offset 132068723 is beyond end of file 27297032 for architecture x86_64 collect2: ld returned 1 exit status make[1]: *** [../../../binaries/system/pyrogenesis] Error 1 make: *** [pyrogenesis] Error 2
comment:9 Changed 13 months ago by historic_bruno
I'm surprised, I haven't seen that error in months (it used to occur almost every build when code changed). When you say latest development tools, do you mean Xcode?
comment:12 Changed 2 months ago by stwf
I don't see this any more either, is it a specific kind of change that triggers it?
comment:13 Changed 2 months ago by historic_bruno
- Cc Yves removed
- Status changed from reopened to closed
- Summary changed from Fix malformed TOC linker error on OS X to [NEEDS INFO] Fix malformed TOC linker error on OS X
- Resolution set to needsinfo
- Milestone Backlog deleted
