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.
Screenshots

Why is this a AzureLinux bug?
The GCC Makefile produces a different <limits.h> file based on some conditions related to the build environment.
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/Makefile.in;hb=4b29be7216daa5921aae340388ef6416b1631f0a


https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/configure;h=b4c52de6218406ddb00425a29b6effa5d6130d9c;hb=4b29be7216daa5921aae340388ef6416b1631f0a


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
Describe the bug
GCC cross compiler from package
gcc-aarch64-linux-gnufails 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.
Expected behavior
The identifiers defined in
<limits.h>should be accessible when cross compiling.Screenshots

Why is this a AzureLinux bug?
The GCC Makefile produces a different <limits.h> file based on some conditions related to the build environment.
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/Makefile.in;hb=4b29be7216daa5921aae340388ef6416b1631f0a
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/configure;h=b4c52de6218406ddb00425a29b6effa5d6130d9c;hb=4b29be7216daa5921aae340388ef6416b1631f0a
For native targets, the system's limits.h file is found and the produced
limits.his a concatenation oflimitx.h,glimits.handlimity.hfiles.For cross targets, the system's
limits.hfile is not found as sys-root is configured due to which the producedlimits.his just theglimits.hfile.So, any identifiers that are defined as part of the
limitx.handlimity.hfiles will be absent when building cross target.PATH_MAXfor 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