Paul
Paul

Reputation: 13238

ld: Invalid record for architecture arm64

I'm building a framework for tvOS and use an obfuscation software. All sources are compiled with -emit-llvm, obfuscator processes LLVM IR code, then it is compiled into .o with clang++, then ld is being called to produce the final binary and ld fails with this error:

ld: Invalid record for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Program xcrun returned error code 1

Reproducible on different machines with Xcode 11.2.1 and 11.3.

How can I troubleshoot this error? I've added -v to the linker flags but it did not add any hints to the output.

Upvotes: 1

Views: 1072

Answers (2)

Marcelo Santos
Marcelo Santos

Reputation: 33

In my case, I was getting this error when the app was linked to external libraries but only when generating the Product Archive. The solution for me was to disable the bitcode of the Target under Build Settings > Build Options. I had it previously disabled but my Xcode updated recently and the setting might have gotten overridden.

Upvotes: 3

Paul
Paul

Reputation: 13238

Answering my own question once again, just in case someone else will hit this issue.

In my case the problem was caused by one of the libraries I was linking to, that was built for arm64e for tvOS. It was a fat binary with arm64, arm64e and x86_64 slices. For some reason ld didn't like it (even though I was building the framework only for arm64) and was throwing out this error. Removing arm64e slice fixed the issue.

Another interesting detail is that Debug build linked fine with that library.

Upvotes: 1

Related Questions