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

Compile on qnx-700 platform #54

Closed
zeroxia opened this issue Nov 3, 2021 · 2 comments
Closed

Compile on qnx-700 platform #54

zeroxia opened this issue Nov 3, 2021 · 2 comments

Comments

@zeroxia
Copy link

zeroxia commented Nov 3, 2021

Hi, I want to compile sqlite3mc's amalgamation source on qnx-700, with different build configurations include aarch64, armv7a.

The toolchain of qnx-700 runs on a x86_64 Linux host.

If I run it with the provided C compiler:

sqlite3mc_amalgamation.c:250248:20: fatal error: endian.h: No such file or directory
 #include <endian.h>

Although there is: /opt/qnx700/target/qnx7/usr/include/io-pkt/machine/endian.h, I'm not sure whether it's the needed one.
In the end I just commented this #include <endian.h> line.

Then there is error about platform-specific entropy function.

The cross-compiler defines feature macro __QNX__, if I run it with command "/opt/qnx700/host/linux/x86_64/usr/bin/qcc", it has also __unix__ defined. If I run it with the command /opt/qnx700/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-gcc-5.4.0, no __unix__ is defined.

So I copied the following two functions from __unix__ section:

static size_t read_urandom(void* buf, size_t n)
static size_t entropy(void* buf, size_t n)

And put them to a new __QNX__ conditional compiling section, the compilation and linking of a simplistic main() function seemed OK, and the output program could be run on target board and call sqlite3_libversion(), version string is printed.

My question is:

is this entropy() function the only platform specific stuff to deal with?

If I don't care about the encryption strength, can I just call C standard rand() and fill the data in the buffer for entropy?

Some doc on the qnx-700:
https://www.qnx.com/developers/docs/7.0.0/#com.qnx.doc.neutrino.lib_ref/topic/manifests.html

Though the toolchain seems not freely available.

@utelle
Copy link
Owner

utelle commented Nov 3, 2021

Hi, I want to compile sqlite3mc's amalgamation source on qnx-700, with different build configurations include aarch64, armv7a.

I don't have access to QNX. It can well be that adjustments to SQLite3MC's code are necessary to support QNX.

The toolchain of qnx-700 runs on a x86_64 Linux host.

If I run it with the provided C compiler:

sqlite3mc_amalgamation.c:250248:20: fatal error: endian.h: No such file or directory
 #include <endian.h>

Maybe this is a QNX version issue. According to the QNX 7.1 documentation the header file endian.h exists in QNX 7.1.

Although there is: /opt/qnx700/target/qnx7/usr/include/io-pkt/machine/endian.h, I'm not sure whether it's the needed one. In the end I just commented this #include <endian.h> line.

No idea, whether the mentioned header file is the right one. If the header file is not available in QNX in the default search path of the compiler, but the code compiles without it, we should probably simply add

#ifndef __QNX__
 #include <endian.h>
#endif

Then there is error about platform-specific entropy function.

The cross-compiler defines feature macro __QNX__, if I run it with command "/opt/qnx700/host/linux/x86_64/usr/bin/qcc", it has also __unix__ defined. If I run it with the command /opt/qnx700/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-gcc-5.4.0, no __unix__ is defined.

Could you please try the following: Replace the line

#elif defined(__linux__) || defined(__unix__) || defined(__APPLE__)

by

#elif defined(__linux__) || defined(__unix__) || defined(__APPLE__) || defined(__QNX__)

I'm pretty sure that that should work.

My question is:

is this entropy() function the only platform specific stuff to deal with?

Yes.

If I don't care about the encryption strength, can I just call C standard rand() and fill the data in the buffer for entropy?

In principle, you could do that. However, you could also use the SQLite function

void sqlite3_randomness(int N, void *P);

At least on Unix-like platforms this function uses the same method as SQLite3MC uses as a fallback method.

utelle added a commit that referenced this issue Nov 18, 2021
- Set pager error state on reporting decrypt error condition to avoid assertion when SQLITE_DEBUG is defined (issue #55)
- Check definition of symbol `__QNX__` to support compilation for QNX (issue #54)
- Apply minor adjustments to ChaCha20 implementation (taken from upstream resilar/sqleet)
@utelle
Copy link
Owner

utelle commented Nov 18, 2021

Commit 11a7462 applies the modifications I proposed. This should fix the issue.

Closing ... reopen if necessary.

@utelle utelle closed this as completed Nov 18, 2021
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

2 participants