std::atomic in v8.h

27 views
Skip to first unread message

Alex Kodat

unread,
Aug 31, 2020, 10:12:42 AM8/31/20
to v8-users
In doing a clang build under Windows (for reasons I'll get into in another post) I hit a the following issue:

[4/1336] CXX obj/src/inspector/inspector/v8-stack-trace-impl.obj
FAILED: obj/src/inspector/inspector/v8-stack-trace-impl.obj
..\..\third_party\llvm-build\Release+Asserts\bin\clang-cl.exe /nologo /showIncludes:user "-imsvc..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\ATLMFC\include" "-imsvc..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include" "-imsvc..\..\..\..\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-imsvc..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-imsvc..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-imsvc..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-imsvc..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-imsvc..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" -DUSE_AURA=1 "-DCR_CLANG_REVISION=\"llvmorg-12-init-3492-ga1caa302-1\"" -D_HAS_NODISCARD -D_HAS_EXCEPTIONS=0 -D__STD_C -D_CRT_RAND_S -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE -D_ATL_NO_OPENGL -D_WINDOWS -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS -DPSAPI_VERSION=2 -DWIN32 -D_SECURE_ATL -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -DWIN32_LEAN_AND_MEAN -DNOMINMAX -D_UNICODE -DUNICODE -DNTDDI_VERSION=NTDDI_WIN10_VB -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64 -DENABLE_MINOR_MC -DV8_INTL_SUPPORT -DENABLE_HANDLE_ZAPPING -DV8_CONCURRENT_MARKING -DV8_ENABLE_LAZY_SOURCE_POSITIONS -DV8_SHARED_RO_HEAP -DV8_WIN64_UNWINDING_INFO -DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH -DV8_SNAPSHOT_COMPRESSION -DV8_DEPRECATION_WARNINGS -DV8_IMMINENT_DEPRECATION_WARNINGS -DV8_TARGET_ARCH_X64 -DV8_HAVE_TARGET_OS -DV8_TARGET_OS_WIN -DDISABLE_UNTRUSTED_CODE_MITIGATIONS -DV8_DEPRECATION_WARNINGS -DV8_IMMINENT_DEPRECATION_WARNINGS -DV8_DEPRECATION_WARNINGS -DV8_IMMINENT_DEPRECATION_WARNINGS -I../.. -Igen -I../../include -I../.. -I../../include -Igen -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -fcomplete-member-pointers /Gy /FS /bigobj /utf-8 /Zc:twoPhase /Zc:sizedDealloc- /X /D__WRL_ENABLE_FUNCTION_STATICS__ -fmsc-version=1916 /guard:cf,nochecks -m64 /Brepro -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -Xclang -fdebug-compilation-dir -Xclang . -no-canonical-prefixes /W4 -Wimplicit-fallthrough -Wunreachable-code -Wthread-safety -Wextra-semi /wd4091 /wd4127 /wd4251 /wd4275 /wd4312 /wd4324 /wd4351 /wd4355 /wd4503 /wd4589 /wd4611 /wd4100 /wd4121 /wd4244 /wd4505 /wd4510 /wd4512 /wd4610 /wd4838 /wd4995 /wd4996 /wd4456 /wd4457 /wd4458 /wd4459 /wd4200 /wd4201 /wd4204 /wd4221 /wd4245 /wd4267 /wd4305 /wd4389 /wd4702 /wd4701 /wd4703 /wd4661 /wd4706 /wd4715 -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-psabi -Wno-ignored-pragma-optimize -Wno-implicit-int-float-conversion -Wno-final-dtor-non-final-class -Wno-builtin-assume-aligned-alignment -Wno-deprecated-copy -Wno-non-c-typedef-for-linkage -Wno-string-concatenation -Wmax-tokens /Z7 -gcodeview-ghash -Xclang -debug-info-kind=constructor /MT -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wmissing-field-initializers -Wunreachable-code -Wshorten-64-to-32 /wd4245 /wd4267 /wd4324 /wd4701 /wd4702 /wd4703 /wd4709 /wd4714 /wd4715 /wd4718 /wd4723 /wd4724 /wd4800 /O2 /Ob2 /Oy- /Zc:inline /Gw -Wexit-time-destructors -Wno-trigraphs /TP /wd4577 /GR- /c ../../src/inspector/v8-stack-trace-impl.cc /Foobj/src/inspector/inspector/v8-stack-trace-impl.obj /Fd"obj/src/inspector/inspector_cc.pdb"
In file included from ../../src/inspector/v8-stack-trace-impl.cc:5:
In file included from ../..\src/inspector/v8-stack-trace-impl.h:11:
In file included from ../..\include/v8-inspector.h:14:
../../include/v8.h(912,27): error: no template named 'atomic' in namespace 'std'
    reinterpret_cast<std::atomic<T*>*>(&val_)->store(new_val,
                     ~~~~~^
../../include/v8.h(920,34): error: no template named 'atomic' in namespace 'std'
    return reinterpret_cast<std::atomic<const T*> const*>(&val_)->load(
                            ~~~~~^
2 errors generated.

Weirdly, I don't get similar errors with clang under say MacOS and I'm not sure I see why clang is seeing fit to expand the TracedReferenceBase template (MSVC doesn't seem to) but, all that said, it seems a little tacky having a std::atomic reference in v8.h without a corresponding #include <atomic> at the top. When I added this include to v8.h, my compiles all worked (though with lots of warnings, another story) so happy to do a PR to add this or maybe an insider could fix this more easily than me. Or maybe I'm missing something?

Ordinarily, if this were my company's product, I'd insist on understanding why this doesn't happen on other platforms but, since it seems just wrong not to have the #include <atomic> I don't think it's worth the time.

Thanks

Ben Noordhuis

unread,
Aug 31, 2020, 11:41:03 AM8/31/20
to v8-users
I suspect it's a simple mistake. If I had to venture a guess, it's
that on most platforms <atomic> gets pulled in by <memory> (which v8.h
includes) but not on your system.

I'm not on the V8 team but a CL with a fix is almost certainly
welcome. Explicitly including <atomic> is the right thing to do.
Reply all
Reply to author
Forward
0 new messages