-
Notifications
You must be signed in to change notification settings - Fork 602
Description
Describe the bug
GCC cross compiler from package gcc-aarch64-linux-gnu fails to compile when referencing identifiers defined in <limits.h>.
To Reproduce
The following shows a simple C program which compiles with native GCC compiler but fails to compile with the GCC aarm64 cross compiler. It complains that the referenced identifier wasn't declared.
# docker run -it mcr.microsoft.com/cbl-mariner/base/core:2.0 /bin/bash
cd ~
tdnf update -y
tdnf install -y gcc glibc-devel binutils kernel-headers
tdnf install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu kernel-cross-headers
echo "
#include <limits.h>
int main() { return PATH_MAX; }
" > main.c
echo "compiling with gcc" && gcc main.c
echo "compiling with aarch64-linux-gnu-gcc" && aarch64-linux-gnu-gcc main.c
Expected behavior
The identifiers defined in <limits.h> should be accessible when cross compiling.
Why is this a AzureLinux bug?
The GCC Makefile produces a different <limits.h> file based on some conditions related to the build environment.
For native targets, the system's limits.h file is found and the produced limits.h is a concatenation of limitx.h, glimits.h and limity.h files.
For cross targets, the system's limits.h file is not found as sys-root is configured due to which the produced limits.h is just the glimits.h file.
So, any identifiers that are defined as part of the limitx.h and limity.h files will be absent when building cross target. PATH_MAX for which this issue is open is one such identifier.
Versions tested with
OS: Mariner 2.0
gcc: 11.2.0-8.cm2.x86_64
gcc-aarch64-linux-gnu: 11.2.0-8.cm2.x86_64




