Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

www-client/ungoogled-chromium: debug build fails on ppc64 #365

Open
skrinakron opened this issue Aug 11, 2024 · 2 comments
Open

www-client/ungoogled-chromium: debug build fails on ppc64 #365

skrinakron opened this issue Aug 11, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@skrinakron
Copy link

Emerging a regular release build of www-client/ungoogled-chromium-126.0.6478.182_p1 with these flags works fine on ppc64:

[ebuild   R   ~] www-client/ungoogled-chromium-126.0.6478.182_p1::pf4public  USE="X clang libcxx official optimize-thinlto optimize-webui proprietary-codecs thinlto vaapi -bluetooth -cfi -convert-dict -cromite -cups -custom-cflags -debug -enable-driver -gtk4 -hangouts -headless -hevc -kerberos (-nvidia) -override-data-dir -pax-kernel -pgo -pulseaudio -qt5 -qt6 -screencast (-selinux) -system-abseil-cpp -system-av1 -system-brotli -system-crc32c -system-double-conversion -system-ffmpeg -system-harfbuzz -system-icu -system-jsoncpp -system-libevent -system-libusb -system-libvpx -system-openh264 -system-openjpeg -system-png -system-re2 -system-snappy -system-woff2 -system-zstd -wayland -widevine"

Adding debug and -official (but not -official alone) causes the build to fail at the points described below.

Highway

FAILED: obj/third_party/highway/libhwy/targets.o 
powerpc64le-unknown-linux-gnu-clang++ -MD -MF obj/third_party/highway/libhwy/targets.o.d -DDCHECK_ALWAYS_ON=1 -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_OZONE=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DNO_UNWIND_TABLES -D_GNU_SOURCE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_DEBUG_MODE -DCR_LIBCXX_REVISION=e3b94d0e5b86883fd77696bf10dc33ba250ba99b -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -I../.. -Igen -I../../buildtools/third_party/libc++ -I../../third_party/highway/src -Wimplicit-fallthrough -Wextra-semi -Wunreachable-code-aggressive -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wno-psabi -Wloop-analysis -Wno-unneeded-internal-declaration -Wno-cast-function-type -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 -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing -fstack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fPIC -pthread -fcolor-diagnostics -fmerge-all-constants -fcomplete-member-pointers -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -no-canonical-prefixes -ftrivial-auto-var-init=pattern -O0 -fno-omit-frame-pointer -gdwarf-4 -g2 -gdwarf-aranges -gsplit-dwarf -ggnu-pubnames -Xclang -fuse-ctor-homing -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wenum-compare-conditional -Wno-c++11-narrowing-const-reference -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=c++20 -Wno-trigraphs -gsimple-template-names -fno-exceptions -fno-rtti -nostdinc++ -isystem../../third_party/libc++/src/include -isystem../../third_party/libc++abi/src/include -fvisibility-inlines-hidden  -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -pipe -mcpu=power9 -mtune=power9 -U_GLIBCXX_ASSERTIONS -Wno-unknown-warning-option -Wno-builtin-macro-redefined -c ../../third_party/highway/src/hwy/targets.cc -o obj/third_party/highway/libhwy/targets.o
../../third_party/highway/src/hwy/targets.cc:49:10: fatal error: 'asm/hwcap.h' file not found
   49 | #include <asm/hwcap.h>
      |          ^~~~~~~~~~~~~
1 error generated.

This is the same issue as encountered by Firefox in their bundled Highway on ppc64, with the same solution: define the preprocessor symbol TOOLCHAIN_MISS_ASM_HWCAP_H.

FAILED: obj/third_party/highway/libhwy/per_target.o 
powerpc64le-unknown-linux-gnu-clang++ -MD -MF obj/third_party/highway/libhwy/per_target.o.d -DDCHECK_ALWAYS_ON=1 -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_OZONE=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DNO_UNWIND_TABLES -D_GNU_SOURCE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_DEBUG_MODE -DCR_LIBCXX_REVISION=e3b94d0e5b86883fd77696bf10dc33ba250ba99b -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -I../.. -Igen -I../../buildtools/third_party/libc++ -I../../third_party/highway/src -Wimplicit-fallthrough -Wextra-semi -Wunreachable-code-aggressive -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wno-psabi -Wloop-analysis -Wno-unneeded-internal-declaration -Wno-cast-function-type -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 -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing -fstack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fPIC -pthread -fcolor-diagnostics -fmerge-all-constants -fcomplete-member-pointers -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -no-canonical-prefixes -ftrivial-auto-var-init=pattern -O0 -fno-omit-frame-pointer -gdwarf-4 -g2 -gdwarf-aranges -gsplit-dwarf -ggnu-pubnames -Xclang -fuse-ctor-homing -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wenum-compare-conditional -Wno-c++11-narrowing-const-reference -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=c++20 -Wno-trigraphs -gsimple-template-names -fno-exceptions -fno-rtti -nostdinc++ -isystem../../third_party/libc++/src/include -isystem../../third_party/libc++abi/src/include -fvisibility-inlines-hidden  -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -pipe -mcpu=power9 -mtune=power9 -U_GLIBCXX_ASSERTIONS -Wno-unknown-warning-option -Wno-builtin-macro-redefined -c ../../third_party/highway/src/hwy/per_target.cc -o obj/third_party/highway/libhwy/per_target.o
In file included from ../../third_party/highway/src/hwy/per_target.cc:20:
In file included from ../../third_party/highway/src/hwy/foreach_target.h:255:
In file included from ../../third_party/highway/src/hwy/per_target.cc:21:
In file included from ../../third_party/highway/src/hwy/highway.h:399:
../../third_party/highway/src/hwy/ops/ppc_vsx-inl.h:2175:53: error: call to 'vec_mule' is ambiguous
 2175 |   const VU64 mul128_result = reinterpret_cast<VU64>(vec_mule(a.raw, b.raw));
      |                                                     ^~~~~~~~
/usr/lib/llvm/18/bin/../../../../lib/clang/18/include/altivec.h:6263:45: note: candidate function
 6263 | static __inline__ vector short __ATTRS_o_ai vec_mule(vector signed char __a,
      |                                             ^
/usr/lib/llvm/18/bin/../../../../lib/clang/18/include/altivec.h:6273:1: note: candidate function
 6273 | vec_mule(vector unsigned char __a, vector unsigned char __b) {
      | ^
/usr/lib/llvm/18/bin/../../../../lib/clang/18/include/altivec.h:6281:43: note: candidate function
 6281 | static __inline__ vector int __ATTRS_o_ai vec_mule(vector short __a,
      |                                           ^
/usr/lib/llvm/18/bin/../../../../lib/clang/18/include/altivec.h:6291:1: note: candidate function
 6291 | vec_mule(vector unsigned short __a, vector unsigned short __b) {
      | ^
/usr/lib/llvm/18/bin/../../../../lib/clang/18/include/altivec.h:6301:1: note: candidate function
 6301 | vec_mule(vector signed int __a, vector signed int __b) {
      | ^
/usr/lib/llvm/18/bin/../../../../lib/clang/18/include/altivec.h:6310:1: note: candidate function
 6310 | vec_mule(vector unsigned int __a, vector unsigned int __b) {
      | ^

... and so on for vec_mulo, vec_cmplt, vec_cmpeq and vec_cmpne. This is Highway trying to call variants of VSX vector intrinsics only available on POWER10, whereas my system is POWER9. The Highway detection headers do deduce POWER9 to be the most eligible target here, but they also default to building for dynamic switching between the best "attainable" targets, which for PPC are defined to always include POWER10. The solution is to build only the single most suitable target for static use by defining the preprocessor symbol HWY_COMPILE_ONLY_STATIC.

These two symbols can be defined specifically for Highway by adding something like this to src_prepare() (e.g. right before the "Removing bundled libraries" step):

if use ppc64; then
    pushd third_party/highway >/dev/null || die
    local hwy_defines=""
    # ppc64 lacks asm/hwcap.h, so don't try to include it
    hwy_defines+='"TOOLCHAIN_MISS_ASM_HWCAP_H"'
    # Only compile the most suitable target (otherwise we may end
    # up compiling e.g. for POWER10 on POWER9, which will fail)
    hwy_defines+=', "HWY_COMPILE_ONLY_STATIC"'
    sed -i -E -e 's/^(\s+defines\s+=\s+)\[\]/\1[ '"${hwy_defines}"' ]/' BUILD.gn || die
    popd >/dev/null || die
fi

These Highway problems occur only in the debug build due to third_party/highway apparently being pulled in by third_party/distributed_point_functions, which is enabled by the use_debug GN flag. However, as defining the above symbols verifiably doesn't hurt release builds, they may as well always be defined on ppc64 in case the situation changes and Highway ends up in regular builds as well.

Ungoogled Chromium patches

FAILED: obj/components/signin/internal/identity_manager/identity_manager/primary_account_manager.o 
powerpc64le-unknown-linux-gnu-clang++ -MD -MF obj/components/signin/internal/identity_manager/identity_manager/primary_account_manager.o.d -DDCHECK_ALWAYS_ON=1 -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_OZONE=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DNO_UNWIND_TABLES -D_GNU_SOURCE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_DEBUG_MODE -DCR_LIBCXX_REVISION=e3b94d0e5b86883fd77696bf10dc33ba250ba99b -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_56 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_56 -DBASE_USE_PERFETTO_CLIENT_LIBRARY=1 -DLIBYUV_DISABLE_NEON -DLIBYUV_DISABLE_LSX -DLIBYUV_DISABLE_LASX -DSK_ENABLE_SKSL -DSK_UNTIL_CRBUG_1187654_IS_FIXED -DSK_USER_CONFIG_HEADER=\"../../skia/config/SkUserConfig.h\" -DSK_WIN_FONTMGR_NO_SIMULATIONS -DSK_DISABLE_LEGACY_INIT_DECODERS -DSK_SLUG_DISABLE_LEGACY_DESERIALIZE -DSK_DISABLE_LEGACY_VULKAN_BACKENDSEMAPHORE -DSK_DISABLE_LEGACY_CREATE_CHARACTERIZATION -DSK_DISABLE_LEGACY_VULKAN_MUTABLE_TEXTURE_STATE -DSK_CODEC_DECODES_JPEG -DSK_ENCODE_JPEG -DSK_ENCODE_PNG -DSK_ENCODE_WEBP -DSK_GANESH -DSK_GPU_WORKAROUNDS_HEADER=\"gpu/config/gpu_driver_bug_workaround_autogen.h\" -DSK_GL -DSK_VULKAN=1 -DSK_GRAPHITE -DSK_DAWN -DVK_USE_PLATFORM_XCB_KHR -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -DGOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE=0 -DHAVE_PTHREAD -DWEBRTC_ENABLE_AVX2 -DWEBRTC_CHROMIUM_BUILD -DWEBRTC_POSIX -DWEBRTC_LINUX -DABSL_ALLOCATOR_NOTHROW=1 -DWEBRTC_USE_X11 -DLOGGING_INSIDE_WEBRTC -I../.. -Igen -I../../buildtools/third_party/libc++ -I../../third_party/perfetto/include -Igen/third_party/perfetto/build_config -Igen/third_party/perfetto -Igen/shim_headers/zlib_shim -I../../net/third_party/quiche/overrides -I../../net/third_party/quiche/src/quiche/common/platform/default -I../../net/third_party/quiche/src -I../../third_party/libyuv/include -I../../third_party/skia -Igen/third_party/skia -I../../third_party/wuffs/src/release/c -I../../third_party/vulkan/include -I../../third_party/vulkan-deps/vulkan-headers/src/include -Igen/third_party/dawn/include -I../../third_party/dawn/include -Igen/shim_headers/libwebp_shim -I../../base/allocator/partition_allocator/src -Igen/base/allocator/partition_allocator/src -I../../third_party/abseil-cpp -I../../third_party/boringssl/src/include -I../../third_party/protobuf/src -Igen/protoc_out -I../../third_party/ipcz/include -I../../third_party/ced/src -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n -Igen/net/third_party/quiche/src -I../../third_party/webrtc_overrides -I../../third_party/webrtc -Igen/third_party/webrtc -Wimplicit-fallthrough -Wextra-semi -Wunreachable-code-aggressive -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wno-psabi -Wloop-analysis -Wno-unneeded-internal-declaration -Wno-cast-function-type -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 -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing -fstack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fPIC -pthread -fcolor-diagnostics -fmerge-all-constants -fcomplete-member-pointers -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -no-canonical-prefixes -ftrivial-auto-var-init=pattern -O0 -fno-omit-frame-pointer -gdwarf-4 -g2 -gdwarf-aranges -gsplit-dwarf -ggnu-pubnames -Xclang -fuse-ctor-homing -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wexit-time-destructors -isystem/usr/lib64/libffi/include -isystem/usr/include/glib-2.0 -isystem/usr/lib64/glib-2.0/include -Wno-redundant-parens -DPROTOBUF_ALLOW_DEPRECATED=1 -isystem/usr/include/nss -isystem/usr/include/nspr -Wno-redundant-parens -Wenum-compare-conditional -Wno-c++11-narrowing-const-reference -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=c++20 -Wno-trigraphs -gsimple-template-names -fno-exceptions -fno-rtti -nostdinc++ -isystem../../third_party/libc++/src/include -isystem../../third_party/libc++abi/src/include -fvisibility-inlines-hidden  -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -pipe -mcpu=power9 -mtune=power9 -U_GLIBCXX_ASSERTIONS -Wno-unknown-warning-option -Wno-builtin-macro-redefined -c ../../components/signin/internal/identity_manager/primary_account_manager.cc -o obj/components/signin/internal/identity_manager/identity_manager/primary_account_manager.o
../../components/signin/internal/identity_manager/primary_account_manager.cc:400:47: error: no member named 'kGoogleServicesAccountId' in namespace 'prefs'
  400 |         client_->GetPrefs()->GetString(prefs::kGoogleServicesAccountId);
      |                                        ~~~~~~~^
../../components/signin/internal/identity_manager/primary_account_manager.cc:402:48: error: no member named 'kGoogleServicesConsentedToSync' in namespace 'prefs'
  402 |         client_->GetPrefs()->GetBoolean(prefs::kGoogleServicesConsentedToSync);
      |                                         ~~~~~~~^
2 errors generated.

This is a continuation of what was discussed in ungoogled-software/ungoogled-chromium#2034: the ebuild enables DCHECK when debug is in USE, but the UGC patches don't touch portions that are only compiled when DCHECK is enabled, leading to this inconsistency. This simple patch – like gringus's in the above issue – solves the problem when applied after the UGC patches:

--- a/components/signin/internal/identity_manager/primary_account_manager.cc
+++ b/components/signin/internal/identity_manager/primary_account_manager.cc
@@ -397,9 +397,9 @@ void PrimaryAccountManager::SetSyncPrimaryAccountInternal(
 #if DCHECK_IS_ON()
   {
     std::string pref_account_id =
-        client_->GetPrefs()->GetString(prefs::kGoogleServicesAccountId);
+        std::string();
     bool consented_to_sync =
-        client_->GetPrefs()->GetBoolean(prefs::kGoogleServicesConsentedToSync);
+        false;
 
     DCHECK(pref_account_id.empty() || !consented_to_sync ||
            pref_account_id == account_info.account_id.ToString())

As this appears to be architecture-independent, the patching should probably be done unconditionally.

This keeps coming up and is trivial to solve. Perhaps the fix should be proposed to UGC proper once more?

V8

FAILED: gen/v8/embedded.S snapshot_blob.bin 
python3.12 ../../v8/tools/run.py ./mksnapshot --turbo_instruction_scheduling --stress-turbo-late-spilling --target_os=linux --target_arch=ppc64 --embedded_src gen/v8/embedded.S --embedded_variant Default --random-seed 314159265 --startup_blob snapshot_blob.bin --native-code-counters --verify-heap


#
# Fatal error in ../../v8/src/heap/base/active-system-pages.cc, line 20
# Debug check failed: RoundUp(user_page_size, page_size) >> page_size_bits <= ActiveSystemPages::kMaxPages (128 vs. 64).
#
#
#
#FailureMessage Object: 0x3fffc2fadce0
==== C stack trace ===============================

    ./mksnapshot(v8::base::debug::StackTrace::StackTrace()+0x34) [0x117635024]
    ./mksnapshot(+0xb97ad98) [0x11762ad98]
    ./mksnapshot(V8_Fatal(char const*, int, char const*, ...)+0x188) [0x1175f30a8]
    ./mksnapshot(+0xb9428b0) [0x1175f28b0]
    ./mksnapshot(V8_Dcheck(char const*, int, char const*)+0x9c) [0x1175f323c]
    ./mksnapshot(heap::base::ActiveSystemPages::Init(unsigned long, unsigned long, unsigned long)+0xd8) [0x11521d328]
    ./mksnapshot(v8::internal::MutablePageMetadata::MutablePageMetadata(v8::internal::Heap*, v8::internal::BaseSpace*, unsigned long, unsigned long, unsigned long, v8::internal::VirtualMemory, v8::internal::PageSize)+0x39c) [0x111b1569c]
    ./mksnapshot(v8::internal::PageMetadata::PageMetadata(v8::internal::Heap*, v8::internal::BaseSpace*, unsigned long, unsigned long, unsigned long, v8::internal::VirtualMemory)+0xb4) [0x111b3e754]
    ./mksnapshot(v8::internal::MemoryAllocator::AllocatePage(v8::internal::MemoryAllocator::AllocationMode, v8::internal::Space*, v8::internal::Executability)+0x3a8) [0x111ae0908]
    ./mksnapshot(v8::internal::SemiSpace::Commit()+0x1c8) [0x111b18e98]
    ./mksnapshot(v8::internal::SemiSpaceNewSpace::SemiSpaceNewSpace(v8::internal::Heap*, unsigned long, unsigned long)+0x11c) [0x111b1b7ac]
    ./mksnapshot(std::__Cr::__unique_if<v8::internal::SemiSpaceNewSpace>::__unique_single std::__Cr::make_unique<v8::internal::SemiSpaceNewSpace, v8::internal::Heap*, unsigned long&, unsigned long&>(v8::internal::Heap*&&, unsigned long&, unsigned long&)+0x54) [0x111956cc4]
    ./mksnapshot(v8::internal::Heap::SetUpSpaces(v8::internal::LinearAllocationArea&, v8::internal::LinearAllocationArea&)+0x1fc) [0x11193088c]
    ./mksnapshot(v8::internal::Isolate::Init(v8::internal::SnapshotData*, v8::internal::SnapshotData*, v8::internal::SnapshotData*, bool)+0xe50) [0x1115d0280]
    ./mksnapshot(v8::internal::Isolate::InitWithoutSnapshot()+0x38) [0x1115cf408]
    ./mksnapshot(v8::internal::SnapshotCreatorImpl::InitInternal(v8::StartupData const*)+0x9c) [0x1129254ac]
    ./mksnapshot(v8::internal::SnapshotCreatorImpl::SnapshotCreatorImpl(v8::internal::Isolate*, v8::Isolate::CreateParams const&)+0x278) [0x112925c88]
    ./mksnapshot(v8::SnapshotCreator::SnapshotCreator(v8::Isolate*, v8::Isolate::CreateParams const&)+0x4c) [0x110e321ec]
    ./mksnapshot(main+0x6c0) [0x110dbe850]
    /usr/lib64/libc.so.6(+0x26bac) [0x3fffb3766bac]
    /usr/lib64/libc.so.6(__libc_start_main+0x1ac) [0x3fffb3766dec]
Return code is -5

(The output is from a build with the flag v8_optimized_debug=false added to the GN config, as without that the stack trace only shows the numeric offsets.)

This is caused by my kernel having a 4k page size instead of the 64k more common on PPC platforms. V8's MemoryAllocator allocates chunks based on a platform-specific hardcoded size, which the lower-level MutablePageMetadata and ActiveSystemPages expect to be at most 64 operating system page sizes. The OS page size is queried at runtime with sysconf(_SC_PAGESIZE) and correctly set to 4k on my system, but due to the hardcoded size assuming 64k pages on PPC64, the allocated chunks end up too big and the invariant doesn't hold. The hardcoded size can be fixed by adding something like this to src_prepare() (e.g. after the Highway fix):

if use ppc64 && [[ $(getconf PAGESIZE) -ne 65536 ]]; then
    einfo "Fixing V8 for non-64k page size"
    pushd v8/src/base >/dev/null || die
    sed -i -E -e '/^#if \(defined\(V8_HOST_ARCH_PPC\)/,/^#elif defined\(ENABLE_HUGEPAGE\)/ s/(\s+kPageSizeBits\s*=\s*)19;/\118;/' build_config.h || die
    popd >/dev/null || die
fi

This is kind of a dirty hack. A more proper fix would be to test for a 4k-selecting preprocessor symbol in the #if condition (which is already kind of done, just with an AIX-specific one that also enables AIXisms elsewhere) and expose this as a GN flag. I'll take a look at the situation in the main V8 repository and see about raising an issue on this there.

The invariant appears to be violated in regular builds as well but only causes the build to fail when the DCHECK enforcing it is enabled. This suggests the fix should not be confined to debug builds – and also illustrates how useful it is to have support for proper debug builds in this ebuild, so thank you for that!

Conclusion

The above fixes allow the merge to complete without issues and should have no undue effect on non-ppc64 (or non-4k) systems. The resulting binary works alright – though naturally rather more slowly than a release build – but keeps emitting errors to the console about failing memory-related sanity checks, which I'm hoping are linked to the issue I need the debug build for to begin with. I'll be looking into these next.

I won't have access to a computer for the next couple of weeks, but I can prepare a pull request after that if this seems too involved to address through snippets.

@skrinakron skrinakron added the bug Something isn't working label Aug 11, 2024
@PF4Public
Copy link
Owner

support for proper debug builds in this ebuild, so thank you for that!

I'm doing trying my best :)

This keeps coming up and is trivial to solve. Perhaps the fix should be proposed to UGC proper once more?

Agreed! Do you have a solution that could go straight to ungoogled-chromium repository?

I can prepare a pull request after that

It would be best if you could prepare and submit the PR, you have the hardware after all!

@skrinakron
Copy link
Author

Agreed! Do you have a solution that could go straight to ungoogled-chromium repository?

Offered in ungoogled-software/ungoogled-chromium#3008.

The V8 issue is here. Ironically, submitting it required setting up a Google account – exactly the kind of thing one wishes to avoid by using ungoogled software.

It would be best if you could prepare and submit the PR, you have the hardware after all!

OK, will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants