Menu

#57 Some things on autotools m4 files

v1.0 (example)
open
nobody
None
5
2024-04-05
2024-04-05
No

Hi, Mark. Seems that sf does not allow two way discussions in feature request tickets. This is not a bug itself but some discussion on the build system, so I think it belongs here, but we can continue in a proper bug ticket or in a mailing list.

FYI I already had the "alpha" patch. I have attached a patch file for common/inclibarch.m4 (and indirectly configure) which has extra 64bit platforms which had caused me issues on OpenSUSE Build Service.
These patches however do raise a maintenance issue. Would it be better to use an autoconf test for sizeof(long) to determine if the platform is 32 or 64 bit?

I am not an expert in this kind of things (nor even in C), but I would only use hardcoded arches for evident things or for things that have no better approach. I have seen people proposing to use AC_CHECK_SIZEOF([size_t]) for this test assuming that the definition of "64 bit" machine is that void * are size 8, but depending on your specific needs you may prefer a different check.

While we are at this I would like to comment some things on a test that appears frequently in regina-rexx configure.in and configure and in some m4 macros.

if test "$ac_cv_prog_CC" = "gcc" -o "$ac_cv_prog_CC" = "g++" ...; then ...

It has been pointed out in https://bugs.debian.org/1027405 that this test will not work as expected when cross compiling (CC will be things like i686-linux-gnu-gcc). I guess this will also happen when a versioned gcc is used (gcc-10 and friends instead of plain gcc). Do not take too seriously 2001_configures_cross-compilation.diff patch there, is just a hack for a particular occurrence.

AC_PROG_CC seems to set GCC=yes when gcc is used
AC_PROG_CXX seems to set GXX=yes when g++ is used

so, it may better to check for that instead of checking for plain gcc or g++ name, even if you do not use above autotools macros (By the way, GCC=yes seems to be handled by configure, do not know where it comes from). Even a name based test at top may help (or testing plain *gcc*) and *g++*))

case "$ac_cv_prog_CC" in
    gcc|*-gcc|gcc-*)
        GCC=yes
        ;;
     g++|*-g++|g++-*)
        GXX=yes
        ;;
esac

...
if test "$GCC" = "yes" -o "$GXX" = "yes" ...; then ...

Do not know what to do for clang, so did not include it above.

Another thing about autotools m4 macros is that there a lot of local macros coming from a time where official autotools macros were way more limited than they are now. I am aware that this is a very unpleasant work, but I wonder how many of those local macros currently have an official macro that could be used with no much work, resulting in code simplification.

Cross compilation is another issue, even with the above will work only for compatible arches (e.g, amd64->i386) because of msgcmp

Best regards,

--
Agustin

Discussion