Hi all,

I'm building v8 with gn, and embedding in my cmake.

I've upgraded to 12.3.x and I'm getting problems with
v8_generate_external_defines_header=true
These problems also occur in the 12.1 and 12.2 series.

I don't see anyone mentioning this flag anywhere, how are people managing 
their build flags?


Anyway, back to the problems:
There are several stages of problems, actually.
Stage 1: Can't find the generated header file.
Stage 2: Build doesn't work with generated header files (order of #includes 
are wrong)
Stage 3: Success if I adjust BUILD.gn to include headers on command line 
AND header file.

*Stage 1: Can't find the generated header file.*
Note the parameter is -Igen but it should be -Igen/include

[1/3906] CXX obj/cppgc_base/name-trait.o
FAILED: obj/cppgc_base/name-trait.o 
../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF 
obj/cppgc_base/name-trait.o.d -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 
-DUSE_OZONE=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D_FORTIFY_SOURCE=2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 
-D_LARGEFILE64_SOURCE -D_GNU_SOURCE 
-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE 
-DCR_CLANG_REVISION=\"llvmorg-18-init-16072-gc4146121e940-5\" 
-DCR_SYSROOT_KEY=20230611T210420Z-2 -DNDEBUG -DNVALGRIND 
-DDYNAMIC_ANNOTATIONS_ENABLED=0 -DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64 
-DENABLE_GDB_JIT_INTERFACE -DV8_INTL_SUPPORT 
-DV8_ATOMIC_OBJECT_FIELD_WRITES -DV8_ENABLE_LAZY_SOURCE_POSITIONS 
-DV8_SHARED_RO_HEAP -DV8_WIN64_UNWINDING_INFO 
-DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH -DV8_SHORT_BUILTIN_CALLS 
-DV8_EXTERNAL_CODE_SPACE -DV8_ENABLE_SPARKPLUG -DV8_ENABLE_MAGLEV 
-DV8_ENABLE_TURBOFAN -DV8_ENABLE_WEBASSEMBLY 
-DV8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA -DV8_ALLOCATION_FOLDING 
-DV8_ALLOCATION_SITE_TRACKING -DV8_ADVANCED_BIGINT_ALGORITHMS 
-DV8_STATIC_ROOTS -DV8_USE_ZLIB -DV8_USE_LIBM_TRIG_FUNCTIONS 
-DV8_ENABLE_WASM_SIMD256_REVEC -DV8_ENABLE_MAGLEV_GRAPH_PRINTER 
-DV8_ENABLE_BUILTIN_JUMP_TABLE_SWITCH -DV8_ENABLE_EXTENSIBLE_RO_SNAPSHOT 
-DV8_GN_HEADER -DV8_TARGET_ARCH_X64 -DV8_HAVE_TARGET_OS 
-DV8_TARGET_OS_LINUX -I../.. *-Igen* -I../../include -Wall -Wextra 
-Wimplicit-fallthrough -Wextra-semi -Wunreachable-code-aggressive 
-Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter 
-Wno-psabi -Wloop-analysis -Wno-unneeded-internal-declaration 
-Wenum-compare-conditional -Wno-ignored-pragma-optimize 
-Wno-deprecated-builtins -Wno-bitfield-constant-conversion 
-Wno-deprecated-this-capture -Wno-invalid-offsetof -Wno-vla-extension 
-Wno-thread-safety-reference-return -Wshadow -Werror 
-fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing 
-fstack-protector -funwind-tables -fPIC -pthread -fcolor-diagnostics 
-fmerge-all-constants 
-fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm 
-instcombine-lower-dbg-declare=0 -mllvm 
-split-threshold-for-reg-with-hint=0 -ffp-contract=off -m64 -msse3 
-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 
-Wmissing-field-initializers -Wunreachable-code -Wno-shadow 
-Wctad-maybe-unsupported -Wshorten-64-to-32 -Wno-invalid-offsetof -O3 
-fdata-sections -ffunction-sections -fno-unique-section-names 
-fno-math-errno -fvisibility=default -Wexit-time-destructors 
-Wno-c++11-narrowing-const-reference -std=c++20 -Wno-trigraphs 
-gsimple-template-names -fno-exceptions -fno-rtti 
--sysroot=../../build/linux/debian_bullseye_amd64-sysroot -c 
../../src/heap/cppgc/name-trait.cc -o obj/cppgc_base/name-trait.o
In file included from ../../src/heap/cppgc/name-trait.cc:5:
In file included from ../../include/cppgc/internal/name-trait.h:12:
In file included from ../../include/cppgc/name-provider.h:8:
../../include/v8config.h:10:2: error: Missing v8-gn.h. The configuration 
for v8 is missing from the include path. Add it with -I<path> to the 
command line
   10 | #error Missing v8-gn.h. The configuration for v8 is missing from 
the include \
      |  ^
../../include/v8config.h:13:10: fatal error: 'v8-gn.h' file not found
   13 | #include "v8-gn.h"  // NOLINT(build/include_directory)
      |          ^~~~~~~~~
2 errors generated.


To get past this step, I adjusted BUILD.gn:746
include_dirs = [ 
....
"$target_gen_dir*/include*"
]


*Stage 2: Build fails with external defines file*
$ ninja -C out.gn/x64.release.sample/ v8_monolith
ninja: Entering directory `out.gn/x64.release.sample/'
[1075/1084] LINK ./mksnapshot
FAILED: mksnapshot 
"python3" "../../build/toolchain/gcc_link_wrapper.py" 
--output="./mksnapshot" -- 
../../third_party/llvm-build/Release+Asserts/bin/clang++ -pie -Werror 
-fuse-ld=lld -Wl,--fatal-warnings -Wl,--build-id -fPIC -Wl,-z,noexecstack 
-Wl,-z,relro -Wl,-z,now -Wl,--icf=all -Wl,--color-diagnostics 
-Wl,--undefined-version -Wl,--no-call-graph-profile-sort -m64 
-no-canonical-prefixes -Wl,-z,defs -Wl,--as-needed 
--sysroot=../../build/linux/debian_bullseye_amd64-sysroot -rdynamic -pie 
-Wl,--disable-new-dtags -Wl,-O2 -Wl,--gc-sections -o "./mksnapshot" 
-Wl,--start-group @"./mksnapshot.rsp"  -Wl,--end-group  -latomic -ldl 
-lpthread -lrt 
ld.lld: error: undefined symbol: 
cppgc::internal::OldToNewRememberedSet::AddSlot(void*)
>>> referenced by write-barrier.cc
>>>               obj/cppgc_base/write-barrier.o:(void 
cppgc::internal::WriteBarrier::CombinedWriteBarrierSlow<(cppgc::internal::WriteBarrierSlotType)1>(void
 
const*))
>>> referenced by write-barrier.cc
>>>               obj/cppgc_base/write-barrier.o:(void 
cppgc::internal::WriteBarrier::CombinedWriteBarrierSlow<(cppgc::internal::WriteBarrierSlotType)0>(void
 
const*))
>>> referenced by write-barrier.cc
>>>               
obj/cppgc_base/write-barrier.o:(cppgc::internal::WriteBarrier::GenerationalBarrierSlow(cppgc::internal::CagedHeapLocalData
 
const&, cppgc::internal::AgeTable const&, void const*, unsigned long, 
cppgc::HeapHandle*))

I did some poking, and the code is seeing different #define values for the 
key settings.
I have solved this problem in the past, in the 11.x series IIRC,
by patching a bunch of v8 source files to rearrange the #include order so 
the v8-gn.h file gets included earlier.

This time, I solved it by adjusting BUILD.gn again, around line 988
config("cppgc_header_features") {
  visibility = [ ":*" ]

  if (v8_generate_external_defines_header) {

*    defines = enabled_external_cppgc_defines    defines += [ 
"V8_GN_HEADER" ]*
  } else {
    defines = enabled_external_cppgc_defines
  }
}


ie define BOTH V8_GN_HEADER *and* all of the defines so they are added to 
the command line, as usual.


cheers,
Paul

-- 
-- 
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/05208cc2-cc6f-4b42-89d6-eefaed2acbf8n%40googlegroups.com.

Reply via email to