Error while creating static lib for mac arm and x86 machines

87 views
Skip to first unread message

Shivam Gupta

unread,
Jul 31, 2023, 7:38:24 AM7/31/23
to v8-users
Hi Guys,
I am trying to create a static lib(monolith) for v8 11.3(11.3.244.12-pgo) but while doing so I see below error in mksnapshot:

[1424/1433] LINK ./mksnapshot

FAILED: mksnapshot mksnapshot.dSYM/Contents/Info.plist mksnapshot.dSYM/Contents/Resources/DWARF/mksnapshot 

TOOL_VERSION=1690480611 ../../build/toolchain/apple/linker_driver.py -Wcrl,strippath,/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -Wcrl,installnametoolpath,/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool ../../third_party/llvm-build/Release+Asserts/bin/clang++  -Wcrl,dsym,. -Wcrl,dsymutilpath,../../tools/clang/dsymutil/bin/dsymutil  -Werror -fuse-ld=lld -Wl,-fatal_warnings -Wl,--icf=all -Wl,--color-diagnostics -Wl,-mllvm,-instcombine-lower-dbg-declare=0 -flto=thin -Wl,--thinlto-jobs=all -Wl,-cache_path_lto,thinlto-cache -Wcrl,object_path_lto -Wl,--thinlto-cache-policy=cache_size=10\%:cache_size_bytes=40g:cache_size_files=100000 -Wl,-mllvm,-import-instr-limit=30 -fwhole-program-vtables -Wl,--strict-auto-link -Wl,--no-call-graph-profile-sort -arch x86_64 -no-canonical-prefixes -isysroot ../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mmacos-version-min=10.13 -Wl,--lto-O0 -Wl,-ObjC -Wcrl,strip,-x,-S -Wl,-dead_strip -Wl,-no_data_in_code_info -Wl,-no_function_starts -o "./mksnapshot" "@./mksnapshot.rsp"

ld64.lld: error: undefined symbol: vtable for v8::internal::SimpleStringResource<unsigned short, v8::String::ExternalStringResource>

>>> referenced by externalize-string-extension.cc:23 (../../src/extensions/externalize-string-extension.cc:23)

>>>               /Users/shivamgupta/Desktop/v8/v8/out.gn/x64.release/tmpzjkia50z/141.x86_64.lto.o:(symbol v8::internal::ExternalizeStringExtension::Externalize(v8::FunctionCallbackInfo<v8::Value> const&)+0x203)


ld64.lld: error: undefined symbol: vtable for v8::internal::SimpleStringResource<char, v8::String::ExternalOneByteStringResource>

>>> referenced by externalize-string-extension.cc:23 (../../src/extensions/externalize-string-extension.cc:23)

>>>               /Users/shivamgupta/Desktop/v8/v8/out.gn/x64.release/tmpzjkia50z/141.x86_64.lto.o:(symbol v8::internal::ExternalizeStringExtension::Externalize(v8::FunctionCallbackInfo<v8::Value> const&)+0x19a)

>>> referenced by externalize-string-extension.cc:25 (../../src/extensions/externalize-string-extension.cc:25)

>>>               /Users/shivamgupta/Desktop/v8/v8/out.gn/x64.release/tmpzjkia50z/141.x86_64.lto.o:(symbol v8::internal::SimpleStringResource<char, v8::String::ExternalOneByteStringResource>::~SimpleStringResource()+0x7)

>>> referenced by externalize-string-extension.cc:25 (../../src/extensions/externalize-string-extension.cc:25)

>>>               /Users/shivamgupta/Desktop/v8/v8/out.gn/x64.release/tmpzjkia50z/141.x86_64.lto.o:(symbol v8::internal::SimpleStringResource<char, v8::String::ExternalOneByteStringResource>::~SimpleStringResource()+0xc)

I used the following gn commands:
is_debug=false
target_cpu="arm64" ("x64" for x86 arch)
v8_target_cpu="arm64" ("x64" for x86 arch)
v8_monolithic=true
v8_use_external_startup_data=false
is_component_build=false
use_custom_libcxx=false
symbol_level=2
v8_enable_i18n_support=false
is_official_build=true
chrome_pgo_phase=false

Does anybody know what could be the possible reason or possible fix for this? Anyhelp would be much appreciated.

Shivam Gupta

unread,
Jan 5, 2024, 4:54:47 AMJan 5
to v8-users
Found a workaround to create static file successfully but I am not sure if this is a valid method:
I found that removing use_custom_libcxx=false gn args created the static successfully. In the documentation I read that use_custom_libcxx is used to use c++ library present in buildTools. My System c++ library is clang. I am suspecting that is the reason it is failing. 

I am unsure what the best practice is here. Should we use use_custom_libcxx or not? Anyhelp would be much appreciated.

Ben Noordhuis

unread,
Jan 5, 2024, 5:50:19 AMJan 5
to v8-u...@googlegroups.com
On Fri, Jan 5, 2024 at 10:54 AM 'Shivam Gupta' via v8-users
<v8-u...@googlegroups.com> wrote:
>
> Found a workaround to create static file successfully but I am not sure if this is a valid method:
> I found that removing use_custom_libcxx=false gn args created the static successfully. In the documentation I read that use_custom_libcxx is used to use c++ library present in buildTools. My System c++ library is clang. I am suspecting that is the reason it is failing.
>
> I am unsure what the best practice is here. Should we use use_custom_libcxx or not? Anyhelp would be much appreciated.

There's no right or wrong answer, it depends on your requirements.

V8 bundles its own copy of the C++ standard library for $REASONS. If
you're okay with your program living in its own little pocket universe
(i.e., doesn't interact with code that uses a different stdlib), then
that's a perfectly fine choice.
Reply all
Reply to author
Forward
0 new messages