utelle / SQLite3MultipleCiphers

SQLite3 encryption extension with support for multiple ciphers
https://utelle.github.io/SQLite3MultipleCiphers/
MIT License
390 stars 73 forks source link

Cross compilation Windows build quadmath problems #126

Closed Chris-SP365 closed 10 months ago

Chris-SP365 commented 10 months ago

I'm working on sqlite-jdbc-crypt and try to get up to date builds with current SQLite and current SQLite3MultipleCipher versions:

Since 1.6.3 there is a reference to quadmath for Windows 64 architectures in vsv.c:

https://github.com/utelle/SQLite3MultipleCiphers/blob/main/src/vsv.c

sqlite-jdbc-crypt uses Dockcross to compile to various architectures. When updated to 3.42.0 and 1.6.3 I get compile errors on Windows 64 builds.

The first one was a missing quadmath linker option on Windows x86-64. I added it and it worked. The second problem is a missing quadmath.h header for Windows ARM-64. I tried various things:

Could you please tell me if Win ARM64 is a supported configuration? Also could you elaborate why quadmath is only needed for Windows 64?

Thank you

Chris

utelle commented 10 months ago

I'm working on sqlite-jdbc-crypt and try to get up to date builds with current SQLite and current SQLite3MultipleCipher versions:

Since 1.6.3 there is a reference to quadmath for Windows 64 architectures in vsv.c:

vsv.c is a SQLite extension that supports variants of the CSV file format for importing CSV files. I added this extension on a user's request. However, if you don't need this extension in your applications then you can simply disable it.

quadmath is only referenced if the library is compiled with GCC for a WIN64 platform. This dependency was introduced by the author of the extension between February and May 2023.

sqlite-jdbc-crypt uses Dockcross to compile to various architectures. When updated to 3.42.0 and 1.6.3 I get compile errors on Windows 64 builds.

The first one was a missing quadmath linker option on Windows x86-64. I added it and it worked.

Actually, I wasn't aware of this problem until early October. The build files were fixed for version 1.7.1.

The second problem is a missing quadmath.h header for Windows ARM-64. I tried various things:

  • Adding includes/options -> no success
  • Adding a quadmath.h -> Compile error "__float128 not supported"

My guess is that the author of the extension never tested to compile it for ARM64. ... and I didn't use GCC for that purpose.

Could you please tell me if Win ARM64 is a supported configuration?

Yes. SQLite3 Multiple Ciphers can be compiled for almost any platform just like SQLite itself. However, sometimes minor adjustments may be necessary.

Also could you elaborate why quadmath is only needed for Windows 64?

I haven't inspected the VSV code in greater detail, but it has something to do with conversion between integer and floating point values. AFAICT this "feature" is not critical in any way. Most likely I will adjust the code, so that the feature will be disabled by default, but can be enabled, if someone really needs it.

Chris-SP365 commented 10 months ago

Thank you for your detailed response. This helps me to understand the problem. I'd like to keep this open for new questions regarding my task.

utelle commented 10 months ago

I applied a quick fix for the problem. The GCC quadmath library will now be referenced under WIN64 only, if the preprocessor symbol SQLITE_USE_QUADMATH is defined. By default it is not defined.

Chris-SP365 commented 10 months ago

Sounds reasonable. Thank you

utelle commented 10 months ago

Sounds reasonable. Thank you

You are welcome.

As I described already in a previous post, the use of quadmath in the VSV extension represents a very special case:

  1. The compiler is GCC
  2. The platform is WIN64
  3. The extension VSV is actually used
  4. The CSV file contains integer items with absolute values between 9.007.199.254.740.991 = 2^53-1 and 9.223.372.036.854.775.808 = 2^63-1, which should be represented as 64-bit integers internally. Without 128-bit floating point support all integers greater than 9.007.199.254.740.991 = 2^53-1 will be represented as doubles.

Only if your requirements meet all 4 conditions, you will want to define the symbol SQLITE_USE_QUADMATH.

I'd like to keep this open for new questions regarding my task.

IMHO this issue could be closed, because I find it highly unlikely that you will have further questions regarding quadmath in the light that this feature isn't used anywhere else in SQLite.

If you have further questions regarding other issues you may have with SQLite3 Multiple Ciphers, please open a new issue.

However, if you happen to have further questions regarding quadmath, simply reopen this issue. Thanks.