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

base64 build errors on big endian BSD #105

Open
grubles opened this issue May 7, 2023 · 7 comments
Open

base64 build errors on big endian BSD #105

grubles opened this issue May 7, 2023 · 7 comments

Comments

@grubles
Copy link

grubles commented May 7, 2023

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
@vincenzopalazzo
Copy link

Can you help me to reproduce this problem, I had no idea on how to start with OpenBSD, any tips?

@grubles
Copy link
Author

grubles commented May 7, 2023

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

@pkubaj
Copy link

pkubaj commented Jul 5, 2023

  1. This is not because of endianness - it doesn't matter here. What matters is whether the architecture uses signed char or unsigned.
  2. 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.

@grubles
Copy link
Author

grubles commented Jul 22, 2023

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

@pkubaj
Copy link

pkubaj commented Jul 22, 2023

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).

@weedcoder
Copy link

weedcoder commented Aug 4, 2023

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');
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~

@grubles
Copy link
Author

grubles commented Aug 4, 2023

You need this commit @weedcoder -> ElementsProject/lightning@0b23f55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants