Some common troubles when cross compiling

Differences in file APIs

Although many POSIX APIs are available in QNX, there are some small differences in between. One of the most important differences are the flags for open() function. For more information on these flags, refer to the open() documentation in the C Library Reference.

In short, you must supply O_DIRECTORY flags when operating file descriptors pointing to a directory.

Differences in process's stack size

On Linux, applications usually benefit from large stack size that Linux offers. By default, GCC allows 8MB (8388608 bytes) of stack size for every binary it produces on Linux. This is extremely beneficial for high performance applications like Ninja to allocate less memories on heap for buffering. However, QCC produces binaries with much smaller stack size by default. Therefore, applications from Linux that use VLA (variable length array) or hard coded with large buffers generate segmentation violations when stack operations are requested.

Additionally, applications that rely on growing stack (-fsplit-stack for GCC) may not be compiled by QCC. Therefore, you must specify the stack size in linker flags when needed, so your applications can align their behavior with the Linux version. Here is an example of compiling an executable with a stack size of 8MB:

LD_FLAGS=-Wl,-z,stack-size,8388608 qcc -Vgcc_ntoaarch64le a.c -o a.out
Page updated: