添加了 rust 文件的 Chromium Android arm 构建上的 clang++ 错误

clang++ error on Chromium Android arm builds with rust files added

提问人:Volodymyr Shalashenko 提问时间:8/31/2023 最后编辑:Volodymyr Shalashenko 更新时间:8/31/2023 访问量:31

问:

在尝试基于结帐 100.0.4896.127 为 Android 臂拱构建 Chromium 时,我遇到了一些奇怪的行为。我添加了一些 rust 代码,对于 arm64 arch,它构建得很好,但是如果我尝试为 arm arch 编译相同的代码,我会收到以下错误:

[1/6] SOLINK ./libchrome__combined.so
FAILED: libchrome__combined.so libchrome__combined.so.TOC lib.unstripped/libchrome__combined.so lib.unstripped/libchrome__combined.so.map.gz
python3 "../../build/toolchain/gcc_solink_wrapper.py" --readelf="../../third_party/llvm-build/Release+Asserts/bin/llvm-readelf" --nm="../../third_party/llvm-build/Release+Asserts/bin/llvm-nm" --strip=../../third_party/llvm-build/Release+Asserts/bin/llvm-strip  --sofile="./lib.unstripped/libchrome__combined.so" --tocfile="./libchrome__combined.so.TOC" --map-file "./lib.unstripped/libchrome__combined.so.map.gz" --output="./libchrome__combined.so" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -Wl,-soname="libchrome__combined.so" -Wl,--version-script=gen/chrome/android/libchrome_linker_script.txt -Wl,--hash-style=gnu -Wl,-soname,libchrome.so --partitioned-library -fuse-ld=lld -Wl,--fatal-warnings -Wl,--build-id=sha1 -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--icf=all -Wl,--color-diagnostics -Wl,-mllvm,-instcombine-lower-dbg-declare=0 -flto=thin -Wl,--thinlto-jobs=all -Wl,--thinlto-cache-dir=thinlto-cache -Wl,--thinlto-cache-policy=cache_size=10\%:cache_size_bytes=40g:cache_size_files=100000 -Wl,-mllvm,-import-instr-limit=5 -march=armv7-a -Wl,--no-rosegment -Wl,--no-call-graph-profile-sort -Wl,--exclude-libs=libvpx_assembly_arm.a --unwindlib=none --target=arm-linux-androideabi23 -no-canonical-prefixes -Wl,--warn-shared-textrel -Wl,-O2 -Wl,--gc-sections -nostdlib++ --sysroot=../../third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Wl,--warn-shared-textrel -Wl,-z,defs -Wl,--as-needed -Wl,--lto-O2 -Wl,--pack-dyn-relocs=android -Wl,-wrap,calloc -Wl,-wrap,free -Wl,-wrap,malloc -Wl,-wrap,memalign -Wl,-wrap,posix_memalign -Wl,-wrap,pvalloc -Wl,-wrap,realloc -Wl,-wrap,valloc -Wl,-wrap,realpath -Wl,-wrap,strdup -Wl,-wrap,strndup -Wl,-wrap,getcwd -Wl,-wrap,asprintf -Wl,-wrap,vasprintf -Wl,--dynamic-linker,/system/bin/linker -o "./lib.unstripped/libchrome__combined.so" @"./libchrome__combined.so.rsp"
ld.lld: error: undefined symbol: __sync_synchronize
>>> referenced by custom_rust.88h8kfpr-cgu.0
>>>               custom_rust.custom_rust.88h8kfpr-cgu.0.rcgu.o:(_$LT$hashbrown..raw..RawTable$LT$T$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::hae04102c385906b5) in archive ex_rust/out/arm/arm-linux-androideabi/release/libex_rust.a
>>> referenced by custom_rust.88h8kfpr-cgu.0
>>>               custom_rust.custom_rust.88h8kfpr-cgu.0.rcgu.o:(_$LT$hashbrown..raw..RawTable$LT$T$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::hfb3bf3ac01fde59c) in archive ex_rust/out/arm/arm-linux-androideabi/release/libex_rust.a
>>> referenced by custom_rust.88h8kfpr-cgu.4
>>>               custom_rust.custom_rust.88h8kfpr-cgu.4.rcgu.o:(core::ptr::drop_in_place$LT$regex..dfa..Cache$GT$::h0ad6b25ba2b2a137 (.llvm.14177781091992271989)) in archive ex/out/arm/arm-linux-androideabi/release/libex_rust.a
>>> referenced 77 more times

这是我 args.gn:

target_os = "android"
is_debug = false
target_cpu = "arm"
is_component_build = false
is_official_build = true
android_channel = "stable"
proprietary_codecs = true
ffmpeg_branding = "Chrome"
enable_widevine = true
enable_nacl = false
use_official_google_api_keys=false
google_api_key = "no"
google_default_client_id = "no"
google_default_client_secret = "no"
enable_full_stack_frames_for_profiling = false
treat_warnings_as_errors=false

我之前一直在使用 96.0.4664.104 Chromium 结帐的相同代码,没有任何问题,但现在我花了很多时间试图解决这个问题,但不幸的是没有成功。

我将不胜感激任何提示!

安卓 Rust Chromium Clang++ AMR

评论

0赞 Volodymyr Shalashenko 9/9/2023
好吧,幸运的是我能够自己解决这个问题。它与此提交从 Chromium 版本 97+ 的 build/config/android/BUILD.gn 中删除的 ldflags 和 cflags 有关:chromium.googlesource.com/chromium/src/+/...

答: 暂无答案