*"Currently, I am still using the configuration use_custom_libcxx = false,
and I applied the following patch to modify the code and make it compile
successfully."*
*builtins-typed-array.cc*
diff --git a/src/builtins/builtins-typed-array.cc
b/src/builtins/builtins-typed-array.cc
index abc1234..def5678 100644
--- a/src/builtins/builtins-typed-array.cc
+++ b/src/builtins/builtins-typed-array.cc
@@ -506,10 +506,15 @@ simdutf::result ArrayBufferSetFromBase64(
simdutf::last_chunk_handling_options last_chunk_handling,
DirectHandle<JSTypedArray> typed_array, size_t& output_length) {
output_length = array_length;
- simdutf::result simd_result;
+ simdutf::result simd_result = {simdutf::error_code::SUCCESS, 0};
if (typed_array->buffer()->is_shared()) {
- simd_result = simdutf::atomic_base64_to_binary_safe(
- reinterpret_cast<const T>(input_vector), input_length,
+ // For shared buffers, we need to copy to a temporary buffer first
+ std::unique_ptr<char[]> temp_input =
std::make_unique<char[]>(input_length);
+ std::memcpy(temp_input.get(), reinterpret_cast<const char*>(input_vector),
+ input_length);
+
+ simd_result = simdutf::base64_to_binary_safe(
+ temp_input.get(), input_length,
reinterpret_cast<char*>(typed_array->DataPtr()), output_length,
alphabet, last_chunk_handling, /*decode_up_to_bad_char*/ true);
} else {
@@ -836,8 +841,13 @@ BUILTIN(Uint8ArrayPrototypeToBase64) {
size_t simd_result_size;
if (uint8array->buffer()->is_shared()) {
- simd_result_size = simdutf::atomic_binary_to_base64(
- std::bit_cast<const char*>(uint8array->DataPtr()), length,
+ // For shared buffers, we need to copy to a temporary buffer first
+ std::unique_ptr<char[]> temp_input = std::make_unique<char[]>(length);
+ std::memcpy(temp_input.get(),
+ std::bit_cast<const char*>(uint8array->DataPtr()), length);
+
+ simd_result_size = simdutf::binary_to_base64(
+ temp_input.get(), length,
reinterpret_cast<char*>(output->GetChars(no_gc)), alphabet);
} else {
simd_result_size = simdutf::binary_to_base64(
simd.cc
diff --git a/src/objects/simd.cc b/src/objects/simd.cc
index ef2b8118eec..c595f955efe 100644
--- a/src/objects/simd.cc
+++ b/src/objects/simd.cc
@@ -484,11 +484,23 @@ void AtomicUint8ArrayToHexSlow(const char* bytes,
size_t length,
// https://cplusplus.github.io/LWG/issue3508
// we instead provide a mutable input, which is ok since we are only reading
// from it.
- char* mutable_bytes = const_cast<char*>(bytes);
+ // char* mutable_bytes = const_cast<char*>(bytes);
for (size_t i = 0; i < length; i++) {
- uint8_t byte =
- std::atomic_ref<char>(mutable_bytes[i]).load(std::memory_order_relaxed);
- PerformNibbleToHexAndWriteIntoStringOutPut(byte, index, string_output);
+ // uint8_t byte =
+ //
std::atomic_ref<char>(mutable_bytes[i]).load(std::memory_order_relaxed);
+ // PerformNibbleToHexAndWriteIntoStringOutPut(byte, index, string_output);
+
+ // Use compiler built-in atomic load for shared memory
+ char byte;
+ __atomic_load(
+ const_cast<char*>(bytes) + i,
+ &byte,
+ __ATOMIC_RELAXED
+ );
+ PerformNibbleToHexAndWriteIntoStringOutPut(
+ static_cast<uint8_t>(byte),
+ index, string_output);
+
index += 2;
}
}
@@ -1081,14 +1093,23 @@ bool ArrayBufferFromHex(const base::Vector<T>&
input_vector, bool is_shared,
size_t index = 0;
std::optional<uint8_t> result = 0;
- for (uint32_t i = 0; i < output_length * 2; i += 2) {
+ for (size_t i = 0; i < output_length * 2; i += 2) {
result = HandleRemainingHexValues(input_vector, i);
if (result.has_value()) {
+ uint8_t value = result.value();
if (is_shared) {
- std::atomic_ref<uint8_t>(buffer[index++])
- .store(result.value(), std::memory_order_relaxed);
+ // std::atomic_ref<uint8_t>(buffer[index++])
+ // .store(result.value(), std::memory_order_relaxed);
+ // Use compiler built-in atomic store for shared memory
+ __atomic_store(
+ buffer + index,
+ &value,
+ __ATOMIC_RELAXED
+ );
+ index++;
} else {
- buffer[index++] = result.value();
+ // buffer[index++] = result.value();
+ buffer[index++] = value;
}
} else {
return false;
在2025年7月29日星期二 UTC+8 20:13:45<[email protected]> 写道:
> “Did you solve this issue? I’m currently facing the same problem and at
> the time I didn’t have a good solution. I’m using a configuration similar
> to yours and am encountering the exact same issue.”
> 在2025年7月28日星期一 UTC+8 21:16:30<[email protected]> 写道:
>
>> *"When building the V8 static library for the Android platform
>> (arm64-v8a), the following error occurred in simdutf."*
>>
>> root@ce59529b30aa:~/v8/v8# gn gen out/android.arm64.monolith --args="
>>
>> > target_os = \"android\"
>>
>> > target_cpu = \"arm64\"
>>
>> > is_debug = false
>>
>> > optimize_for_size = true
>>
>> > v8_enable_31bit_smis_on_64bit_arch = true
>>
>> > symbol_level = 0
>>
>> > v8_use_external_startup_data=false
>>
>> >
>>
>> > v8_monolithic = true
>>
>> > v8_static_library = true
>>
>> > is_component_build = false
>>
>> >
>>
>> > v8_enable_webassembly = false
>>
>> > v8_enable_i18n_support = false
>>
>> > #v8_enable_pointer_compression = true
>>
>> >
>>
>> > android_unstripped_runtime_outputs = false
>>
>> > dcheck_always_on = false
>>
>> > default_min_sdk_version = 21
>>
>> > v8_android_log_stdout = true
>>
>> >
>>
>> > use_sysroot = false
>>
>> > use_custom_libcxx = false
>>
>> > use_glib = false
>>
>> > "
>>
>> Done. Made 1013 targets from 228 files in 454ms
>>
>> root@ce59529b30aa:~/v8/v8# autoninja -C out/android.arm64.monolith
>> v8_monolith
>>
>> ninja: Entering directory `out/android.arm64.monolith'
>>
>> 1.06s load siso config
>>
>> [1227/3101] 25m00.40s F CXX
>> obj/v8_base_without_compiler/builtins-typed-array.o
>>
>> *FAILED: 6a074098-7768-4ded-a7d8-da56e857aaa2
>> "./obj/v8_base_without_compiler/builtins-typed-array.o" CXX
>> obj/v8_base_without_compiler/builtins-typed-array.o*
>>
>> err: exit=1
>>
>> ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MD -MF
>> obj/v8_base_without_compiler/builtins-typed-array.o.d
>> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2
>> -D_GNU_SOURCE -D__ARM_NEON__=1 -DANDROID
>> -D__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__ -DHAVE_SYS_UIO_H
>> -DANDROID_NDK_VERSION_ROLL=r28_1
>> -DCR_CLANG_REVISION=\"llvmorg-21-init-11777-gfd3fecfc-1\"
>> -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -DNDEBUG -DNVALGRIND
>> -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64
>> -DV8_TEMPORAL_SUPPORT -DV8_ATOMIC_OBJECT_FIELD_WRITES
>> -DV8_ENABLE_LAZY_SOURCE_POSITIONS -DV8_WIN64_UNWINDING_INFO
>> -DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH -DV8_SNAPSHOT_COMPRESSION
>> -DV8_ENABLE_CONTROL_FLOW_INTEGRITY -DV8_ENABLE_FUZZTEST
>> -DV8_SHORT_BUILTIN_CALLS -DV8_EXTERNAL_CODE_SPACE -DV8_ENABLE_SPARKPLUG
>> -DV8_ENABLE_MAGLEV -DV8_ENABLE_TURBOFAN
>> -DV8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA -DV8_ALLOCATION_FOLDING
>> -DV8_ALLOCATION_SITE_TRACKING -DV8_USE_ZLIB -DV8_USE_LIBM_TRIG_FUNCTIONS
>> -DV8_ENABLE_MAGLEV_GRAPH_PRINTER -DV8_ENABLE_BUILTIN_JUMP_TABLE_SWITCH
>> -DV8_ENABLE_EXTENSIBLE_RO_SNAPSHOT -DV8_ENABLE_BLACK_ALLOCATED_PAGES
>> -DV8_ENABLE_LEAPTIERING -DV8_WASM_RANDOM_FUZZERS
>> -DV8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT=0
>> -DV8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT=0
>> -DV8_PROMISE_INTERNAL_FIELD_COUNT=0 -DV8_COMPRESS_POINTERS
>> -DV8_COMPRESS_POINTERS_IN_SHARED_CAGE -DV8_31BIT_SMIS_ON_64BIT_ARCH
>> -DV8_ENABLE_SANDBOX -DV8_DEPRECATION_WARNINGS
>> -DV8_IMMINENT_DEPRECATION_WARNINGS -DV8_HAVE_TARGET_OS
>> -DV8_TARGET_OS_ANDROID -DCPPGC_CAGED_HEAP -DCPPGC_YOUNG_GENERATION
>> -DCPPGC_POINTER_COMPRESSION -DCPPGC_ENABLE_LARGER_CAGE
>> -DCPPGC_SLIM_WRITE_BARRIER -DV8_TARGET_ARCH_ARM64 -DV8_ANDROID_LOG_STDOUT
>> -DV8_RUNTIME_CALL_STATS -DABSL_ALLOCATOR_NOTHROW=1
>> -DTEMPORAL_CAPI_VERSION_0_0_9 -DHWY_BROKEN_TARGETS=HWY_ALL_SVE -I../..
>> -Igen -I../../include -Igen/include -I../../third_party/abseil-cpp
>> -I../../third_party/fp16/src/include
>> -I../../third_party/rust/chromium_crates_io/vendor/temporal_capi-v0_0_9/bindings/cpp
>>
>> -I../../third_party/dragonbox/src/include
>> -I../../third_party/fast_float/src/include -I../../third_party/highway/src
>> -I../../third_party/zlib -Wall -Wextra -Wimplicit-fallthrough -Wextra-semi
>> -Wunreachable-code-aggressive -Wthread-safety -Wgnu
>> -Wno-gnu-anonymous-struct -Wno-gnu-conditional-omitted-operand
>> -Wno-gnu-include-next -Wno-gnu-label-as-value -Wno-gnu-redeclared-enum
>> -Wno-gnu-statement-expression -Wno-gnu-zero-variadic-macro-arguments
>> -Wno-zero-length-array -Wunguarded-availability
>> -Wno-missing-field-initializers -Wno-unused-parameter -Wno-psabi
>> -Wloop-analysis -Wno-unneeded-internal-declaration -Wno-cast-function-type
>> -Wno-thread-safety-reference-return -Wno-nontrivial-memcall -Wshadow
>> -Werror -fno-delete-null-pointer-checks -fno-strict-overflow -fno-ident
>> -fno-strict-aliasing -fstack-protector -funwind-tables -fPIC
>> -fcolor-diagnostics -fmerge-all-constants -fno-sized-deallocation
>> -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm
>> -instcombine-lower-dbg-declare=0 -mllvm
>> -split-threshold-for-reg-with-hint=0 -ffp-contract=off -ffunction-sections
>> -fno-short-enums -mbranch-protection=standard
>> --target=aarch64-linux-android21 -mno-outline -Wno-builtin-macro-redefined
>> -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -ffile-compilation-dir=.
>> -no-canonical-prefixes -fno-omit-frame-pointer -g0 -Wheader-hygiene
>> -Wstring-conversion -Wtautological-overlap-compare -Wunreachable-code
>> -Wno-shadow -Wctad-maybe-unsupported -Xclang -add-plugin -Xclang
>> blink-gc-plugin -Wno-invalid-offsetof -Wshorten-64-to-32
>> -Wmissing-field-initializers -O2 -fdata-sections -ffunction-sections
>> -fno-unique-section-names -fno-math-errno -fvisibility=default
>> -Wexit-time-destructors -Wno-invalid-offsetof -Wenum-compare-conditional
>> -Wno-nullability-completeness -std=c++20 -Wno-trigraphs
>> -gsimple-template-names -fno-exceptions -fno-rtti
>> --sysroot=../../third_party/android_toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot
>>
>> -c ../../src/builtins/builtins-typed-array.cc -o
>> obj/v8_base_without_compiler/builtins-typed-array.o
>>
>> build step: cxx "./obj/v8_base_without_compiler/builtins-typed-array.o"
>>
>> siso_rule: clang/cxx
>>
>> stderr:
>>
>> *../../src/builtins/builtins-typed-array.cc:508:28: **error: **no member
>> named 'atomic_base64_to_binary_safe' in namespace 'simdutf'; did you mean
>> 'base64_to_binary_safe'?*
>>
>> 508 | simd_result = simdutf::atomic_base64_to_binary_safe(
>>
>> | * ^~~~~~~~~~~~~~~~~~~~~~~~~~~~*
>>
>> | base64_to_binary_safe
>>
>> *../../third_party/simdutf/simdutf.h:4369:1: **note:
>> *'base64_to_binary_safe'
>> declared here
>>
>> 4369 | base64_to_binary_safe(const char *input, size_t length, char
>> *output,
>>
>> | *^*
>>
>> *../../src/builtins/builtins-typed-array.cc:829:35: **error: **no member
>> named 'atomic_binary_to_base64' in namespace 'simdutf'; did you mean
>> 'binary_to_base64'?*
>>
>> 829 | simd_result_size = simdutf::atomic_binary_to_base64(
>>
>> | * ^~~~~~~~~~~~~~~~~~~~~~~*
>>
>> | binary_to_base64
>>
>> *../../third_party/simdutf/simdutf.h:4110:8: **note: *'binary_to_base64'
>> declared here
>>
>> 4110 | size_t binary_to_base64(const char *input, size_t length, char
>> *output,
>>
>> | * ^*
>>
>> *../../src/builtins/builtins-typed-array.cc:509:9: **error: **cannot
>> initialize a parameter of type 'const char *' with an rvalue of type 'const
>> char16_t *'*
>>
>> 509 | reinterpret_cast<const T>(input_vector), input_length,
>>
>> | * ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
>>
>> *../../src/builtins/builtins-typed-array.cc:687:21: **note: *in
>> instantiation of function template specialization 'v8::internal::(anonymous
>> namespace)::ArrayBufferSetFromBase64<const char16_t *>' requested here
>>
>> 687 | simd_result = ArrayBufferSetFromBase64(
>>
>> | * ^*
>>
>> *../../third_party/simdutf/simdutf.h:4369:35: **note: *passing argument
>> to parameter 'input' here
>>
>> 4369 | base64_to_binary_safe(const char *input, size_t length, char
>> *output,
>>
>> | * ^*
>>
>> 3 errors generated.
>>
>>
>> build failed
>>
>> local:1228 remote:0 cache:0 fallback:0 retry:0 skip:478
>>
>> fs: ops: 105378(err:21627) / r:13726(err:0) 1.09GiB / w:124(err:0)
>> 113.85MiB
>>
>> resource/capa used(err) wait-avg | s m | serv-avg | s m |
>>
>> localexec/8 1135(1) 5m01.65s |▂▂▂▂▃█▄| 10.36s | ▃▃█▅▂ |
>>
>> pool=link/1 16(0) 13.35s |▆ ▇█▃ | 6.21s | ▃█▃ |
>>
>>
>> *25m00.93s* Build Failure: 1228 done 1 failed 1873 remaining - 0.82/s
>>
>> 1 steps failed: exit=1
>>
>> *see ./out/android.arm64.monolith/siso_output for full command line and
>> output*
>>
>> * or ./out/android.arm64.monolith/siso.INFO*
>>
>> *use ./out/android.arm64.monolith/siso_failed_commands.sh to re-run
>> failed commands*
>>
>>
>> *------------------------------------------------------------------------------*
>>
>> *"If I remove the use_custom_libcxx, use_sysroot, and use_glib
>> configurations, it can successfully compile libv8_monolith.a. However, when
>> I integrate it into my Android project and use NDK version 28.1.13356709,
>> it encounters unresolved symbol errors."*
>>
>>
>> [image: error.png]
>>
>> *"I'm very confused right now and can't find any useful resources to help
>> me solve the problem. Please tell me how to compile a static library that
>> can be used on Android. The V8 tag I'm currently using is 13.9.210."*
>>
>>
>>
>>
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/v8-users/1168f1b6-4c1a-4df6-83d7-0296515ddc38n%40googlegroups.com.