You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;thenpushd 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.
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:
(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.
The text was updated successfully, but these errors were encountered:
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!
Emerging a regular release build of www-client/ungoogled-chromium-126.0.6478.182_p1 with these flags works fine on ppc64:
Adding
debug
and-official
(but not-official
alone) causes the build to fail at the points described below.Highway
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
.... and so on for
vec_mulo
,vec_cmplt
,vec_cmpeq
andvec_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 symbolHWY_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):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
This is a continuation of what was discussed in ungoogled-software/ungoogled-chromium#2034: the ebuild enables DCHECK when
debug
is inUSE
, 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: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
(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 tosrc_prepare()
(e.g. after the Highway fix):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.
The text was updated successfully, but these errors were encountered: