mainAutoconf - Support: sr #110746, GNU Autoconf 2.71: F77...


sr #110746: GNU Autoconf 2.71: F77 name-mangling fails when compiling with mpicxx

Submitter:  None
Submitted:  Fri 21 Oct 2022 10:26:42 PM UTC
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  None
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment Rich Markup

Fri 21 Oct 2022 10:26:42 PM UTC, original submission:  


I tried to compile a software library with the compiler set to mpicxx (gcc, Ubuntu 11.2.0-19ubuntu1)) and GNU Autoconf 2.71 and encountered F77 name-mangling errors during configuration with the following output to the console.

| Checking MPI and related programs
checking whether we are using MPI... yes
checking whether we are using MPI I/O... yes
checking whether we are using MPI_Init_thread... yes
checking for mpirun... mpirun
configure:                             F77 set to gfortran
configure:                              FC set to gfortran
configure:                              CC set to mpicxx
configure:                             CXX set to mpicxx
checking whether the Fortran 77 compiler works... yes
checking for Fortran 77 compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU Fortran 77... yes
checking whether gfortran accepts -g... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to get verbose linking output from gfortran... -v
checking for Fortran 77 libraries of gfortran...  -L/usr/lib/gcc/x86_64-linux-gnu/11 -L/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/11/../../.. -lgfortran -lm -lquadmath
checking whether make supports the include directive... yes (GNU style)
checking for gcc... mpicxx
checking whether the compiler supports GNU C... yes
checking whether mpicxx accepts -g... yes
checking for mpicxx option to enable C11 features... unsupported
checking for mpicxx option to enable C99 features... unsupported
checking for mpicxx option to enable C89 features... unsupported
checking whether mpicxx understands -c and -o together... yes
checking dependency style of mpicxx... gcc3
checking for dummy main to link with Fortran 77 libraries... none
checking for Fortran 77 name-mangling scheme... unknown

When looking at the config.log I identified the following sequence to probably be the cause of the problem

configure:7972: checking for Fortran name-mangling scheme
configure:7986: gfortran -c -g -O2  conftest.f >&5
configure:7986: $? = 0
configure:8033: mpicxx -o conftest -O2 -Wall   conftest.c cfortran_test.o -lgfortran  -L/usr/lib/gcc/x86_64-linux-gnu/11 -L/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/11/../../.. -lgfortran -lm -lquadmath >&5
/usr/bin/ld: /tmp/ccT0CQ1j.ltrans0.ltrans.o: in function `main':
<artificial>:(.text.startup+0x9): undefined reference to `foobar()'
collect2: error: ld returned 1 exit status
configure:8033: $? = 1
configure: failed program was:
| /* confdefs.h */
| ...
/* end confdefs.h.  */
| /* Override any GCC internal prototype to avoid an error.
|    Use char because int might match the return type of a GCC
|    builtin and then its argument prototype would still apply.  */
| char foobar ();
| #ifdef F77_DUMMY_MAIN
| #  ifdef __cplusplus
|      extern "C"
| #  endif
|    int F77_DUMMY_MAIN() { return 1; }
| #endif
| #ifdef FC_DUMMY_MAIN
| #ifndef FC_DUMMY_MAIN_EQ_F77
| #  ifdef __cplusplus
|      extern "C"
| #  endifconfigure:8033: mpicxx -o conftest -O2 -Wall  
|    int FC_DUMMY_MAIN() { return 1; }
| #endif
| #endif
| int
| main (void)
| {
| return foobar ();
|   ;
|   return 0;
| }

Similar results where obtained when testing for foobar_(), FOOBAR () and FOOBAR_().
I suppose this it due to
   char foobar ();
being defined before any occurrence of
   #ifdef __cpluspluc
        extern "C"
For comparison I tried compiling the library with autoconf 2.69 installed and everything worked fine. In this case the config.log displayed an additional
   #ifdef __cpluspluc
        extern "C"
in front of
   char foobar ();.

Do you know if this will change back in future versions or what I can do to fix the name-mangling routine accordingly?

Best Regards
Hannes Brandt



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by None (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    No changes have been made to this item

    Back to the top

    Powered by Savane 3.12