ccan
ccan copied to clipboard
base64 build errors on big endian BSD
When building on powerpc64 FreeBSD 13.2-RELEASE.
cc ccan/ccan/base64/base64.c
ccan/ccan/base64/base64.c:34:10: error: result of comparison of constant 255 with expression of type 'int8_t' (aka 'signed char') is always false [-Werror,-Wt
autological-constant-out-of-range-compare]
if (ret == (char)0xff) {
~~~ ^ ~~~~~~~~~~
ccan/ccan/base64/base64.c:44:57: error: result of comparison of constant 255 with expression of type 'const signed char' is always true [-Werror,-Wtautologica
l-constant-out-of-range-compare]
return (maps->decode_map[(const unsigned char)b64char] != (char)0xff);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~
2 errors generated.
gmake: *** [Makefile:890: ccan-base64.o] Error 1
Looks like I'm hitting the same error on powerpc64 OpenBSD 7.2
CC: cc -DBINTOPKGLIBEXECDIR="../libexec/c-lightning" -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror -std=gnu11 -g -fstack-protector-strong -Og -I ccan -I external/libwally-core/include/ -I external/libwally-core/src/secp256k1/include/ -I external/jsmn/ -I external/libbacktrace/ -I external/gheap/ -I external/powerpc64-unknown-openbsd7.2/libbacktrace-build -I external/libsodium/src/libsodium/include -I external/libsodium/src/libsodium/include/sodium -I external/powerpc64-unknown-openbsd7.2/libsodium-build/src/libsodium/include -I . -I/usr/local/include -I/usr/local/include -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS -DCOMPAT_V052=1 -DCOMPAT_V060=1 -DCOMPAT_V061=1 -DCOMPAT_V062=1 -DCOMPAT_V070=1 -DCOMPAT_V072=1 -DCOMPAT_V073=1 -DCOMPAT_V080=1 -DCOMPAT_V081=1 -DCOMPAT_V082=1 -DCOMPAT_V090=1 -DCOMPAT_V0100=1 -DCOMPAT_V0121=1 -DBUILD_ELEMENTS=1 -c -o
LD: cc -Og config.vars -Lexternal/powerpc64-unknown-openbsd7.2 -lwallycore -lsecp256k1 -ljsmn -lbacktrace -lsodium -L/usr/local/include -lm -lgmp -L/usr/local/lib -lsqlite3 -lz -o
cc ccan/ccan/base64/base64.c
ccan/ccan/base64/base64.c:34:10: error: result of comparison of constant 255 with expression of type 'int8_t' (aka 'signed char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if (ret == (char)0xff) {
~~~ ^ ~~~~~~~~~~
ccan/ccan/base64/base64.c:44:57: error: result of comparison of constant 255 with expression of type 'const signed char' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
return (maps->decode_map[(const unsigned char)b64char] != (char)0xff);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~
2 errors generated.
gmake: *** [Makefile:867: ccan-base64.o] Error 1
Can you help me to reproduce this problem, I had no idea on how to start with OpenBSD, any tips?
To install OpenBSD, grab the installer image here: https://cdn.openbsd.org/pub/OpenBSD/7.2/powerpc64/install72.img
Load that up in KVM or something that supports powerpc64 (this is the important part, we want the big endian version) and from there its installer is super straightforward.
Then follow the CLN OpenBSD docs here: https://github.com/ElementsProject/lightning/blob/master/doc/INSTALL.md#to-build-on-openbsd
- This is not because of endianness - it doesn't matter here. What matters is whether the architecture uses signed char or unsigned.
- OpenBSD/powerpc64 doesn't support pseries platform, so unless you specifically choose powernv platform in QEMU, it won't work. You're better off trying FreeBSD, since it supports pseries.
It appears to happen on ppc64le Linux with clang as well. This is on Rocky Linux 9.
cc ccan/ccan/base64/base64.c
ccan/ccan/base64/base64.c:34:10: error: result of comparison of constant 255 with expression of type 'int8_t' (aka 'signed char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if (ret == (char)0xff) {
~~~ ^ ~~~~~~~~~~
ccan/ccan/base64/base64.c:44:57: error: result of comparison of constant 255 with expression of type 'const signed char' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
return (maps->decode_map[(const unsigned char)b64char] != (char)0xff);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~
2 errors generated.
make: *** [Makefile:897: ccan-base64.o] Error 1
Yes, because endianness doesn't matter here, but whether char is signed or unsigned. I believe you will also get the same results on ARM (both big-endian and little-endian, both 32-bit and 64-bit).
base64: fix for unsigned chars (e.g. ARM). doesn't fix the issue.
ccan/ccan/base64/base64.c:34:10: error: result of comparison of constant 255 with expression of type 'int8_t' (aka 'signed char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if (ret == '\xff') {
~~~ ^ ~~~~~~
ccan/ccan/base64/base64.c:44:57: error: result of comparison of constant 255 with expression of type 'const signed char' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
return (maps->decode_map[(const unsigned char)b64char] != '\xff');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~
You need this commit @weedcoder -> https://github.com/ElementsProject/lightning/pull/6472/commits/0b23f55c194cda0e08d0d9cc5901c66b5286979a