Failure to build for OSX

288 views
Skip to first unread message

Alex Dovzhanyn

unread,
Sep 19, 2024, 3:15:29 PM9/19/24
to v8-users
Hey all, I'm trying to follow the steps listed here in the V8 docs to build V8 on OSX. 

gn args out.gn/x64.release.sample
shows the generated arguments as:

is_component_build = false
is_debug = false
target_cpu = "x64"
use_custom_libcxx = false
v8_monolithic = true
v8_use_external_startup_data = false

However, when I run ninja -C out.gn/x64.release.sample v8_monolith
the build runs about halfway but ultimately fails with the following error:

In file included from ../../src/codegen/external-reference-table.h:8: ../../include/v8-memory-span.h:44:36: error: no member named 'enable_view' in namespace 'std::ranges' 44 | inline constexpr bool std::ranges::enable_view<v8::MemorySpan<T>> = true; | ~~~~~~~~~~~~~^ ../../include/v8-memory-span.h:44:47: error: expected ';' after top level declarator 44 | inline constexpr bool std::ranges::enable_view<v8::MemorySpan<T>> = true; | ^ | ; In file included from ../../src/codegen/external-reference-table.cc:5: In file included from ../../src/codegen/external-reference-table.h:9: In file included from ../../src/builtins/accessors.h:9: In file included from ../../src/base/bit-field.h:12: In file included from ../../src/base/macros.h:13: In file included from ../../src/base/logging.h:11: In file included from ../../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/sstream:184: In file included from ../../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/istream:163: In file included from ../../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/ostream:137: In file included from ../../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/bitset:122: In file included from ../../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/string:532: In file included from ../../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/string_view:191: ../../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/__ranges/enable_view.h:32:23: error: redefinition of 'enable_view' 32 | inline constexpr bool enable_view = derived_from<_Tp, view_base>; | ^ ../../include/v8-memory-span.h:44:36: note: previous definition is here 44 | inline constexpr bool std::ranges::enable_view<v8::MemorySpan<T>> = true; | ^ 3 errors generated.

I am building on OSX 12.5 with Xcode 13.4 installed -- using Apple clang version 13.1.6 (clang-1316.0.21.2.5).

Any help would be very greatly appreciated!

Ben Noordhuis

unread,
Sep 20, 2024, 4:53:30 AM9/20/24
to v8-u...@googlegroups.com
For building 13.0 or the main branch a C++20-capable compiler and
standard library are required; enable_view is a C++20-ism. Your
options are:

1. Set use_custom_libcxx=true and use the bundled libc++ (assuming
Xcode can handle C++20; I don't know)

2. Build an older version. I believe 12.9 is still C++17.

Alex Dovzhanyn

unread,
Sep 20, 2024, 11:37:53 AM9/20/24
to v8-users
Thanks so much for the response, Ben! 

I think that may be the issue -- I'm trying to compile 13.0 and am trying to build with apple clang c++20, and it's just continually tripping up on itself. It seems that apple clang doesn't support enable_view.

I've since switched to trying to build 12.9 but I think I was still trying to build with c++20. Is there a way to specify within gn.args that c++17 should be used? I couldn't find a relevant flag in the list of available flags. Unless 12.9 is indeed c++20? I'm seeing -std=c++20 being passed in as an argument during the build (and I'm not passing it myself, so I'm guessing its coming from ninja or somewhere else in v8).

Apologies for any ignorance on my part -- I've only recently started working with c++ so I'm not deeply familiar with the tooling.

Cheers,
Alex

Ben Noordhuis

unread,
Sep 20, 2024, 2:52:45 PM9/20/24
to v8-u...@googlegroups.com
There was no flag day event where everything was switched to C++20 _en
masse_ so what minor/patch works with your compiler and stdlib may be
hit or miss. The fact the compiler accepts -std=c++20 means it's at
least aware of C++20 - but maybe not everything, and evidently the
stdlib isn't fully conformant.

If it helps, I know for sure that 12.4.254.21 builds fine in C++17
mode because that's the version we (Node.js) currently ship in our
v22.x release line.

Some spelunking through the git history suggests 12.7 turned on C++20,
in commit https://github.com/v8/v8/commit/f06f6d1a45fe
> --
> --
> 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/3b58ea5f-acfb-4440-abe5-f2571f060d1en%40googlegroups.com.

Alex Dovzhanyn

unread,
Sep 20, 2024, 3:05:47 PM9/20/24
to v8-u...@googlegroups.com
Thats extremely helpful, Ben! I'll defer to trying to compile 12.4.254 then, since the rest of my codebase is in c++17 anyway -- that would allow me to keep things simpler. I'll report back (hopefully with a success) here soon.

Cheers,
Alex

You received this message because you are subscribed to a topic in the Google Groups "v8-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/v8-users/E8YcXnlV1w0/unsubscribe.
To unsubscribe from this group and all its topics, 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/CAHQurc_C1_Xop-5kzErWNwQZ-_BWa_gxaXok8pD_e36ZQ_Kjyw%40mail.gmail.com.

Alex Dovzhanyn

unread,
Sep 22, 2024, 12:40:31 AM9/22/24
to v8-users
Ben -- huge thanks again for the tips. Your recommendations were crucial to getting me unblocked. I'm happy to report that I was able to get v12.5 to compile successfully with c++17. I tried going up to 12.6 but was getting some weird issues with missing headers, so I'll stick with v12.5 for the time being.

If anyone ends up finding this through Google search in the future, here are the steps that I followed to get the build to succeed:

1. Fetch v8
2. git checkout branch-heads/12.5
3. gclient sync
4. tools/dev/v8gen.py x64.release
5. ninja -C out.gn/x64.release v8_monolith

All the best,
Alex

Reply all
Reply to author
Forward
0 new messages