When attempting to generate a large static library in a Fortran/C makefile-based project with devtoolset-11, the 'ar' step fails with: ar: first/object/in/alphabetical/order.o: file format not recognized
I'm using a devtoolset-11 installation contained in a Podman image based on Red Hat Enterprise Linux Server release 7.9 (Maipo). Devtoolset-11 is activated with: "source /opt/rh/devtoolset-11/enable", and "which ar" prints "/opt/rh/devtoolset-11/root/usr/bin/ar". "ar --version" is "GNU ar version 2.36.1-1.el7.1".
Where it gets interesting is if I rename devtoolset's 'ar' and create a link "ln -s /usr/bin/ar /opt/rh/devtoolset-11/root/usr/bin/ar", then the build completes without issue and the library is generated!
I've also tried using devtoolset's 'ar' to manually generate a library using one of the object files, and that also works, so it doesn't seem that the object is actually being compiled with an incompatible ELF format for 'ar'. I've also tried building test programs with the gcc/gfortran in devtoolset-11 and manually creating the library with devtoolset's 'ar' and this also works, it only fails within the context of my makefile project.
Any idea as to what could be going on here and why I can complete the build with the system default 'ar' but not the one in devtoolset-11? Appreciate any insight.
I found this issue was caused from a difference in available command line flags for the two different versions of "ar". The build system was using the flags "rul", and "l" was not listed as an option for the system's "ar", whereas in the one included in devtoolset-11 it is listed as "[l ] - specify the dependencies of this library". This difference in syntax lead to the message about unrecognized file format.