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

FB4 build fails on big endian #6978

Closed
AlexPeshkoff opened this issue Sep 22, 2021 · 8 comments
Closed

FB4 build fails on big endian #6978

AlexPeshkoff opened this issue Sep 22, 2021 · 8 comments

Comments

@AlexPeshkoff
Copy link
Member

This is related to #6852

For big endian ttmath library should not be used

@real-dam
Copy link
Contributor

I wonder if libabsl shouldn't be used on all platforms instead of big-endian only? That would simplify the build process and guarantee equivalent behavior on little- and big-endian platforms.
(And libabsl is already available in Debian. I could provide the patch to add --with-system-absl to configure)

@AlexPeshkoff
Copy link
Member Author

Pay attention to comments in mentioned pull request - it's much slower than ttmath. And that's not only due to mentioned asm optimization - even when it turned off ttmath is much faster.

@real-dam
Copy link
Contributor

Yes, I just read those. Sorry for missing them earlier. Half as fast is a deal breaker indeed.

@AlexPeshkoff
Copy link
Member Author

AlexPeshkoff commented Sep 22, 2021

What about mentioned switch - it will not work on HW where gcc supports native __int128 due to alignment issues in FB. I've added slightly modified abseil's code.

AlexPeshkoff added a commit that referenced this issue Sep 22, 2021
AlexPeshkoff added a commit that referenced this issue Sep 23, 2021
AlexPeshkoff added a commit that referenced this issue Sep 23, 2021
…add binary .a to git repository

(cherry picked from commit a5024f8)
AlexPeshkoff added a commit that referenced this issue Sep 23, 2021
…der in XDR representation of decfloat

(cherry picked from commit 4dcfd02)
AlexPeshkoff added a commit that referenced this issue Sep 23, 2021
@real-dam
Copy link
Contributor

real-dam commented Oct 3, 2021

What about mentioned switch - it will not work on HW where gcc supports native __int128 due to alignment issues in FB. I've added slightly modified abseil's code.

I want to report a relative success on big-endian hardware (powerpc64) with libabsl20200923 that is available in Debian. FB4 client/isql on amd64 (little endian) talks to a server running on powerpc64 (big endian):

$ isql-fb -z
ISQL Version: LI-V4.0.0.2496 Firebird 4.0
SQL> connect to 'ppc64:test.fdb';
Server version:
LI-V4.0.0.2496 Firebird 4.0
LI-V4.0.0.2496 Firebird 4.0/tcp (ppc64)/P16:C
LI-V4.0.0.2496 Firebird 4.0/tcp (debian)/P16:C
SQL> select cast('123456789012345678901234567890123456789' as int128), cast('1234567890123456789012345678901234' as decfloat) from rdb$database;

                                         CAST                                       CAST 
============================================= ========================================== 
      123456789012345678901234567890123456789         1234567890123456789012345678901234 

This is 4.0.0 + a bunch of patches from the v4.0-release branch, including fixes for #6978 and PR#6852. Excluding extern/int128 and using libabsl20200923 from the Debian package. This is a private build for evaluating the situation and not in any way official or final.

The build went fine on s390x too, but I can't test the resulting server due to the limited access I have.

Is the above test enough to ensure compatibility with the official FB client/server?

@AlexPeshkoff
Copy link
Member Author

AlexPeshkoff commented Oct 5, 2021 via email

@real-dam
Copy link
Contributor

real-dam commented Oct 6, 2021

That's enough to be sure that mapper between internal and network representation works correctly. And yes, compatibility with the official FB client/server is verified.

Great!

Very interesting - does mentioned PPC have HW support for decfloats? We use IBM's emulation library and on PPC with such support is should use HW instead emulator.

I don't really know. How do I check? I can compile/run things if that would help.

The following program compiles and prints Size of __int128: 16 when run:

#include <stdio.h>

int main(int argc, char** argv) {
	__int128 value;
	printf("Size of __int128: %ld\n", sizeof(value));
	return 0;
}

But there is one more issue - data alignment. To check it do something like this:
create table tbl1(fld1 int128);
insert into tbl1 values (12345);
select * from tbl1;
In a case of alignment problems you get segfault when doing select.

Seems to execute normally on the build hosts (both ppc64 and s390x; real hardware; in embedded mode):

create database 'test.fdb';
create table t1(f1 int128);
insert into t1(f1) values(12345);
select * from t1;

                                           F1 
============================================= 
                                        12345 

also works when the client is amd64 (little endian) and the server is ppc64 (big endian; qemu)

@AlexPeshkoff
Copy link
Member Author

AlexPeshkoff commented Oct 7, 2021 via email

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

No branches or pull requests

4 participants