Closed fndmaioli closed 2 years ago
Getting the same thing. I believe this error is due to the architecture being passed in is not compatible with clang14 which ninja is now bundling in src/third-party
. Also the gn arg use_xcode_clang
is no longer supported. I believe the build script needs to be modified to fix or workaround some of these issues and also to support building with Bitcode enabled which requires removing -mllvm
args in src/build/config/compiler/BUILD.gn
.
So after some more digging: build M96(the latest WebRTC code used in this repo as of this date) has this code in src/build/config/ios/BUILD.gn
:
# TODO(crbug.com/1223481): Temporarily use a different
# libclang_rt.iossim.a for arm64 simulator builds. This can be
# removed when an arm64 slice is added to upstream Clang.
if (false) {
ldflags += [
"-lSystem",
rebase_path("$ios_toolchains_path/usr/lib/clang/13.0.0/" +
"lib/darwin/libclang_rt.iossim.a",
root_build_dir),
"-nodefaultlibs",
]
}
That obviously won't ever be executed because the if condition always fails. Why is it false
? I don't know, but it shouldn't be false
because indeed the error above is being caused because the bundled third_party/llvm-build/Release+Asserts/lib/clang/14.0.0/lib/darwin/libclang_rt.iossim.a
doesn't include the arm64 simulator architecture.
You can verify this to be the case by doing file libclang_rt.iossim.a
and getting:
libclang_rt.iossim.a: Mach-O universal binary with 2 architectures: [i386:current ar archive random library] [x86_64:current ar archive random library]
libclang_rt.iossim.a (for architecture i386): current ar archive random library
libclang_rt.iossim.a (for architecture x86_64): current ar archive random library
Notice that an arm64 target is not included in there.
I'm not sure where the if (false)
is coming from to be honest but chromium's source code instead has:
# TODO(crbug.com/1223481): Temporarily use a different
# libclang_rt.iossim.a for arm64 simulator builds. This can be
# removed when an arm64 slice is added to upstream Clang.
if (target_environment == "simulator" && current_cpu == "arm64") {
assert(xcode_version_int == 1300)
ldflags += [
"-lSystem",
rebase_path("$ios_toolchains_path/usr/lib/clang/13.0.0/" +
"lib/darwin/libclang_rt.iossim.a",
root_build_dir),
"-nodefaultlibs",
]
}
This looks correct (apart from the strict xcode version 13.0.0 check) and would make the build work because it would swap out the libclang_rt.iossim.a file from xcode correctly.
Also please note there is corresponding bug report in webrtc here where they are awaiting for apple to properly include the proper architecture in clang 14. Once that is truly done then the if check and its code won't be needed. As of now it is still needed however which goes against the if (false)
implying that it isn't. I can't track where that if (false)
is coming from in WebRTC's M96 code, once I can find that a bug report can be filed on WebRTC itself.
Some further info: Even if you manually edit src/build/config/ios/BUILD.gn
to be like chromium's check so that the build works, running build.sh, runs ninja, which for some odd reason resets src/build/config/ios/BUILD.gn
to its original state and wipes out any edits. Only thing I can think of right now is to manually replace third_party/llvm-build/Release+Asserts/lib/clang/14.0.0/lib/darwin/libclang_rt.iossim.a
with Xcode's and hopefully the build works.
Update: Compiling M97 - M102 was a mess. M103 can be compiled with no tricks or modifications to the build scripts.
Hello, i'm trying to generate a framework using your build.sh script but i keep getting the same error and i'm not sure how to solve it. It seems that it manages to execute the
gn gen
command, but then it fails when trying to build with Ninja. The error messageld64.lld: error: unable to find matching architecture in ../../third_party/llvm-build/Release+Asserts/lib/clang/14.0.0/lib/darwin/libclang_rt.iossim.a
is the same one i got when using these commands to build the framework without the script.This is the message i get: