Failed to compile on macOS for iOS: 'pthread_jit_write_protect_np' is unavailable: not available on iOS

819 views
Skip to first unread message

chao...@gmail.com

unread,
Aug 5, 2021, 11:10:14 AM8/5/21
to v8-users
1.
*************************************************
gn args as following:
*************************************************

enable_ios_bitcode = true

ios_deployment_target = 10

is_component_build = false
is_debug = false
is_official_build = true

symbol_level = 0

target_cpu = "arm64"                  # "x64" for a simulator build.
target_os = "ios"

treat_warnings_as_errors = false

use_custom_libcxx = true             # Use Xcode's libcxx.
use_xcode_clang = false

v8_target_cpu = "arm64"
v8_enable_debugging_features = false
v8_enable_i18n_support = false        # Produces a smaller binary.
v8_enable_pointer_compression = false
v8_enable_v8_checks = false
v8_monolithic = true                  # Enable the v8_monolith target.
v8_use_external_startup_data = false  # The snaphot is included in the binary.


2.
*************************************************
error msg as following:
*************************************************

../../src/wasm/code-space-access.cc:40:3: error: 'pthread_jit_write_protect_np' is unavailable: not available on iOS
  pthread_jit_write_protect_np(0);
  ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/usr/include/pthread.h:561:6: note: 'pthread_jit_write_protect_np' has been explicitly marked unavailable here
void pthread_jit_write_protect_np(int enabled);
     ^
../../src/wasm/code-space-access.cc:44:3: error: 'pthread_jit_write_protect_np' is unavailable: not available on iOS
  pthread_jit_write_protect_np(1);

chao...@gmail.com

unread,
Aug 5, 2021, 8:06:29 PM8/5/21
to v8-users

Oh, I forgot to mention the version. I am trying to compile V8 v9.4.113.

chao...@gmail.com

unread,
Aug 5, 2021, 8:10:01 PM8/5/21
to v8-users
It shows another error when I Use Xcode's libcxx and Use Xcode's clang...

1.
*************************************************
gn args as following:
*************************************************

enable_ios_bitcode = true

ios_deployment_target = 10

is_component_build = false
is_debug = false
is_official_build = true

symbol_level = 0

target_cpu = "arm64"                  # "x64" for a simulator build.
target_os = "ios"

treat_warnings_as_errors = false

use_custom_libcxx = false             # Use Xcode's libcxx.
use_xcode_clang = true

v8_target_cpu = "arm64"
v8_enable_debugging_features = false
v8_enable_i18n_support = false        # Produces a smaller binary.
v8_enable_pointer_compression = false
v8_enable_v8_checks = false
v8_monolithic = true                  # Enable the v8_monolith target.
v8_use_external_startup_data = false  # The snaphot is included in the binary.


2.
*************************************************
error msg as following:
*************************************************

../../include/cppgc/allocation.h:168:39: error: no member named 'forward' in namespace 'std'

    T* object = ::new (memory) T(std::forward<Args>(args)...);

                                 ~~~~~^

../../include/cppgc/allocation.h:168:47: error: 'Args' does not refer to a value

    T* object = ::new (memory) T(std::forward<Args>(args)...);

                                              ^

../../include/cppgc/allocation.h:164:25: note: declared here

  template <typename... Args>


On Thursday, August 5, 2021 at 11:10:14 PM UTC+8 chao...@gmail.com wrote:

chao...@gmail.com

unread,
Aug 5, 2021, 9:50:03 PM8/5/21
to v8-users
My OS version is macOS Big Sur 11.5.

Clemens Backes

unread,
Aug 6, 2021, 2:33:27 PM8/6/21
to v8-u...@googlegroups.com
Thanks for letting us know, we indeed did not differentiate between MacOS and iOS. I just landed a fix for this: https://crrev.com/c/3077154

The error about std::forward should be fixable by adding an #include <utility> in include/cppgc/allocation.h. Can you try that?

--
--
v8-users mailing list
v8-u...@googlegroups.com
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 v8-users+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/b5cf66f9-95d7-4f2c-99f5-0fa655e11a56n%40googlegroups.com.


--

Clemens Backes

Software Engineer

clem...@google.com

Google Germany GmbH

Erika-Mann-Straße 33

80636 München


Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg


Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde.


This e-mail is confidential. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person.

Message has been deleted
Message has been deleted

chao...@gmail.com

unread,
Aug 8, 2021, 12:47:31 AM8/8/21
to v8-users
Thanks for your quick response!

Compiled successfully when I switched to tag 9.4.116 and added an #include <utility> in include/cppgc/allocation.h.

But it shows error during the link stage: 

              Undefined symbols for architecture arm64:

                 "v8::internal::trap_handler::RegisterDefaultTrapHandler()", referenced from:

                     v8::internal::trap_handler::EnableTrapHandler(bool) in libv8_monolith.a(handler-outside.o)

                 "v8::internal::trap_handler::TryHandleSignal(int, __siginfo*, void*)", referenced from:

                     v8::TryHandleWebAssemblyTrapPosix(int, __siginfo*, void*) in libv8_monolith.a(api.o)

                     v8::V8::TryHandleSignal(int, void*, void*) in libv8_monolith.a(api.o)

               ld: symbol(s) not found for architecture arm64

               clang: error: linker command failed with exit code 1 (use -v to see invocation)

chao...@gmail.com

unread,
Aug 8, 2021, 12:51:05 AM8/8/21
to v8-users

*************************************************
gn args as following:
*************************************************

enable_ios_bitcode = true

ios_deployment_target = 10

is_component_build = false
is_debug = false
is_official_build = true

symbol_level = 1

target_cpu = "arm64"
target_os = "ios"

treat_warnings_as_errors = false

use_custom_libcxx = false             # Use Xcode's libcxx.
use_xcode_clang = true

v8_target_cpu = "arm64"
v8_enable_debugging_features = false
v8_enable_i18n_support = false        # Produces a smaller binary.
v8_enable_pointer_compression = false
v8_enable_v8_checks = false
v8_monolithic = true                  # Enable the v8_monolith target.
v8_use_external_startup_data = false  # The snaphot is included in the binary.

chao...@gmail.com

unread,
Aug 8, 2021, 12:53:40 AM8/8/21
to v8-users
If I switch to tag 8.5.188, everything works fine.

DEVANSH M KAUSHIK

unread,
Aug 10, 2021, 1:10:04 AM8/10/21
to v8-users
I am also facing the same issue. 
Details are :
v8: tag/8.5.188
macOS: Big Sur 11.3.1

the original error "../../include/cppgc/allocation.h:168:39: error: no member named 'forward' in namespace 'std'" is resolved by switching to this v8 version "tag/8.5.188" but I am still getting the following error in this version :
=============================================================

➜  v8 git:(heads/tags/8.5.188) ✗ ninja -C out/release-ios            

ninja: Entering directory `out/release-ios'

[0/1] Regenerating ninja files

[1/3397] CXX obj/cppgc_base/marking-worklists.o

FAILED: obj/cppgc_base/marking-worklists.o 

../../../../../../../../Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -MMD -MF obj/cppgc_base/marking-worklists.o.d -DCR_XCODE_VERSION=1251 -DCR_CLANG_REVISION=\"llvmorg-14-init-591-g7d9d926a-1\" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DNS_BLOCK_ASSERTIONS=1 -DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64 -DENABLE_MINOR_MC -DENABLE_HANDLE_ZAPPING -DV8_ATOMIC_OBJECT_FIELD_WRITES -DV8_ATOMIC_MARKING_STATE -DV8_ENABLE_LAZY_SOURCE_POSITIONS -DV8_SHARED_RO_HEAP -DV8_WIN64_UNWINDING_INFO -DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH -DV8_SNAPSHOT_COMPRESSION -DV8_ENABLE_WEBASSEMBLY -DV8_ALLOCATION_FOLDING -DV8_ALLOCATION_SITE_TRACKING -DV8_ADVANCED_BIGINT_ALGORITHMS -DV8_DEPRECATION_WARNINGS -DV8_IMMINENT_DEPRECATION_WARNINGS -DCPPGC_CAGED_HEAP -DV8_TARGET_ARCH_ARM64 -DV8_HAVE_TARGET_OS -DV8_TARGET_OS_IOS -DV8_RUNTIME_CALL_STATS -DDISABLE_UNTRUSTED_CODE_MITIGATIONS -I../.. -Igen -I../../include -Igen/include -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -fcolor-diagnostics -fmerge-all-constants -target arm64-apple-ios10 -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -ffile-compilation-dir=. -no-canonical-prefixes -Wall -Wextra -Wimplicit-fallthrough -Wunreachable-code -Wthread-safety -Wextra-semi -Wunguarded-availability -Wundeclared-selector -Wno-missing-field-initializers -Wno-unused-parameter -Wloop-analysis -Wno-unneeded-internal-declaration -fno-omit-frame-pointer -g2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk -fembed-bitcode -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wmissing-field-initializers -Wunreachable-code -Wshorten-64-to-32 -O3 -fvisibility=default -Wexit-time-destructors -std=c++14 -fno-trigraphs -Wno-trigraphs -fno-exceptions -fno-rtti -c ../../src/heap/cppgc/marking-worklists.cc -o obj/cppgc_base/marking-worklists.o

clang++: error: unknown argument: '-ffile-compilation-dir=.'

[2/3397] CXX obj/cppgc_base/name-trait.o

FAILED: obj/cppgc_base/name-trait.o 

=============================================================


*************************************************
gn args as following:
*************************************************
enable_ios_bitcode = true
ios_deployment_target = 10

is_component_build = false
is_debug = false

target_cpu = "arm64"
target_os = "ios"

treat_warnings_as_errors = false

use_custom_libcxx = false             # Use Xcode's libcxx.
use_xcode_clang = true

v8_target_cpu = "arm64"
v8_enable_debugging_features = false
v8_enable_i18n_support = false        # Produces a smaller binary.
v8_enable_pointer_compression = false
v8_enable_v8_checks = false
v8_monolithic = true                  # Enable the v8_monolith target.
v8_use_external_startup_data = false  # The snaphot is included in the binary.
ios_enable_code_signing=false

================================================

DEVANSH M KAUSHIK

unread,
Aug 10, 2021, 2:35:28 AM8/10/21
to v8-users
If I remove the following form gn args . 

==============
use_custom_libcxx = false             # Use Xcode's libcxx.
use_xcode_clang = true
==============

I am using following setup  
xcode : 12.5.1
v8: tag/8.5.188
macOS: Big Sur 11.3.1

the build starts but fails while linking d8 with the following error :

➜  v8 git:(heads/tags/8.5.188) ✗ ninja -C out/release-ios


ninja: Entering directory `out/release-ios'

[0/1] Regenerating ninja files

[3202/3507] LINK ./d8

FAILED: d8 

TOOL_VERSION=1628482238 ../../build/toolchain/apple/linker_driver.py -Wcrl,strippath,../../../../../../../../Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip --deterministic ../../third_party/llvm-build/Release+Asserts/bin/clang++ -B ../../../../../../../../Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/  -Wl,-fatal_warnings -target arm64-apple-ios10 -nostdlib++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk -Wl,-ObjC -Wl,-rpath,@executable_path/Frameworks -Wl,-dead_strip -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/usr/lib/swift -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -o "./d8" -Wl,-filelist,"./d8.rsp" -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation   

Undefined symbols for architecture arm64:

  "v8::internal::trap_handler::RegisterDefaultTrapHandler()", referenced from:

      v8::internal::trap_handler::EnableTrapHandler(bool) in handler-outside.o

ld: symbol(s) not found for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Traceback (most recent call last):

  File "../../build/toolchain/apple/linker_driver.py", line 305, in <module>

    Main(sys.argv)

  File "../../build/toolchain/apple/linker_driver.py", line 98, in Main

    subprocess.check_call(compiler_driver_args, env=env)

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 190, in check_call

    raise CalledProcessError(retcode, cmd)

subprocess.CalledProcessError: Command '['../../third_party/llvm-build/Release+Asserts/bin/clang++', '-B', '../../../../../../../../Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/', '-Wl,-fatal_warnings', '-target', 'arm64-apple-ios10', '-nostdlib++', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk', '-Wl,-ObjC', '-Wl,-rpath,@executable_path/Frameworks', '-Wl,-dead_strip', '-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/usr/lib/swift', '-L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos', '-o', './d8', '-Wl,-filelist,./d8.rsp', '-framework', 'CoreFoundation', '-framework', 'CoreGraphics', '-framework', 'CoreText', '-framework', 'Foundation']' returned non-zero exit status 1

[3207/3507] CXX obj/test/unittests/unittests_sources/instruction-selector-arm64-unittest.o

ninja: build stopped: subcommand failed.




Clemens Backes

unread,
Aug 12, 2021, 10:55:24 AM8/12/21
to v8-u...@googlegroups.com
Hm, that symbol is defined in src/trap-handler/handler-outside-posix.cc, which should be included for iOS builds. Can you check if you have a handler-outside-posix.o file in the output directory, and if it contains the RegisterDefaultTrapHandler symbol?

DEVANSH M KAUSHIK

unread,
Aug 12, 2021, 1:57:02 PM8/12/21
to v8-users
Yes, handler-outside-posix.o is present at ***/v8/v8/out/release-ios/clang_x64_v8_arm64/obj/v8_base_without_compiler/ and 
the "objdump -t handler-outside-posix.o" is : 

handler-outside-posix.o: file format mach-o 64-bit x86-64

SYMBOL TABLE:

0000000000002db8 l     O __DATA,__bss __ZN2v88internal12trap_handler12_GLOBAL__N_138g_is_default_signal_handler_registeredE

0000000000002dc0 l     O __DATA,__bss __ZN2v88internal12trap_handler12_GLOBAL__N_113g_old_handlerE

0000000000000060 g     F __TEXT,__text __ZN2v88internal12trap_handler17RemoveTrapHandlerEv

0000000000000000 g     F __TEXT,__text __ZN2v88internal12trap_handler26RegisterDefaultTrapHandlerEv

0000000000000000         *UND* __ZN2v88internal12trap_handler12HandleSignalEiP9__siginfoPv

0000000000000000         *UND* _sigaction


It looks like this object file is created for x86-64 while the targeted build architecture is arm64.


==============gn args===================

# Set build arguments here. See `gn help buildargs`.

enable_ios_bitcode = true

ios_deployment_target = 10

is_component_build = false

is_debug = false

target_cpu = "arm64"                  # "x64" for a simulator build.

target_os = "ios"

v8_enable_i18n_support = false        # Produces a smaller binary.

v8_monolithic = true                  # Enable the v8_monolith target.

v8_use_external_startup_data = false  # The snaphot is included in the binary.

v8_enable_pointer_compression = false # Unsupported on iOS.

ios_enable_code_signing=false

==================================================


build commands  :

1. gn gen out/release-ios

2. set args.gn as above

3. ninja -C out/release-ios

Thanks and Regards,

Devansh Mohan Kaushik

DEVANSH M KAUSHIK

unread,
Aug 13, 2021, 4:04:28 AM8/13/21
to v8-users
Indeed, only the "arm64 ios" build is failing with above- mentioned inking errors i.e. :

[3202/3507] LINK ./d8

FAILED: d8 

TOOL_VERSION=1628482238 ../../build/toolchain/apple/linker_driver.py -Wcrl,strippath,../../../../../../../../Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip --deterministic ../../third_party/llvm-build/Release+Asserts/bin/clang++ -B ../../../../../../../../Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/  -Wl,-fatal_warnings -target arm64-apple-ios10 -nostdlib++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk -Wl,-ObjC -Wl,-rpath,@executable_path/Frameworks -Wl,-dead_strip -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/usr/lib/swift -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -o "./d8" -Wl,-filelist,"./d8.rsp" -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation   

Undefined symbols for architecture arm64:

  "v8::internal::trap_handler::RegisterDefaultTrapHandler()", referenced from:

      v8::internal::trap_handler::EnableTrapHandler(bool) in handler-outside.o

ld: symbol(s) not found for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)


I tried for  target_cpu = "x64" i.e. ios simulator and everything worked fine perfectly.  
The build is only failing for the arm64 ios.
Mac Big Sur 11.3.1. 
v8 version : tags/8.5.188 as well as at detached HEAD 5d18f75b7b9fc60fc01300334a938145c9e2a2aa. 

other information : 
 xcode :  12.5.1
clang --version : Apple clang version 12.0.5 (clang-1205.0.22.11)

Please let me know if any other information is required or if I need to report it to some other forum as well.

Thanks and Regards,
Devansh Mohan Kaushik

Reply all
Reply to author
Forward
0 new messages