bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gold: problems with mixed C++/Fortran program


From: tuebenedikt
Subject: gold: problems with mixed C++/Fortran program
Date: Tue, 24 Mar 2009 14:45:57 +0000 (GMT)

Dear gold developers, 
Dear Ian,

Being very happy when I read about the new fast linker, I tried to use it on 
the package I'm working with (1050229 lines C++, 649866 lines Fortran 90), 
together with our preferred toolchain of the Intel C++ and Fortran compiler. 

For the linking step itself, I noticed a speedup beyond seven - from 28.67s to 
4.01s (time utility in csh, real time) !!! (Actually, these numbers might be 
somewhat optimistic: The package doesn't deal very much with namespaces...)

However, the program crashed with the message: 
forrtl: severe (48): invalid argument to FORTRAN Run-Time Library
Image              PC                Routine            Line        Source
libirc.so          00002AD00D23F05A  Unknown            Unknown  Unknown

Trying to boil down the problem to a small gold/C++/F90 test case, I wrote some 
lines (see below), but instead of a crash I found some errors in the program 
output - see the details section below.

Not being a linking expert, I assume the object code of fortran subroutines is 
compatible to objects derived from C code. Am I wrong? 

To have a fast linker that also supports C++/Fortran 90 hybrid programs would 
be really helpful to me. For any bugfixes many thanks in advance,

Benedikt


===========================================
And now for the details: You will find

1) file list
2) Makefile
3/4) C++ test class source and header
5/6) Fortran test routine source and header
7) main routine in test.C
8) version strings of the compilers and linkers used
9) compile and run log using GNU ld (--> this output is what I expected!)
10) compile and run log using GNU gold 
 (--> search for "Hi guys..." strange,isn't it? I think it isn't just a C/F90 
problem.)
===========================================

address@hidden:~/test/cxx_f90$ ls
Makefile  TestClass.C  TestClass.h  fibo_cycle.F  fortran_subs.h  test.C
address@hidden:~/test/cxx_f90$
address@hidden:~/test/cxx_f90$
address@hidden:~/test/cxx_f90$ cat *
# Makefile    (GNU gold/Intel icpc/Intel ifort test case)

ifdef GOLD
USE_GOLD = 1
LD_PATH = /mnt/nobackup/bs/gold/bin
else
USE_GOLD = 0
LD_PATH = /usr/bin
endif

FC  = ifort -O0
CXX = icpc  -O0
LD =  icpc  -O0 -v -Qlocation,ld,$(LD_PATH)

.PHONY: versions check clean
versions:
        $(CXX) --version
        $(FC) --version
        $(LD) --version
        $(LD_PATH)/ld --version

check: test.bin
        ./test.bin

test.bin: test.o TestClass.o fibo_cycle.o
        $(LD) -o $@ $^

test.o: CPPFLAGS = -DUSE_GOLD=$(USE_GOLD)
test.o: test.C TestClass.h Makefile

TestClass.o: TestClass.C TestClass.h fortran_subs.h
fibo_cycle.o: fibo_cycle.F

clean:
        rm -fr *.o test.bin

# End of Makefile -----------------------------------------
/* TestClass.C (GNU gold/Intel icpc/Intel ifort test case) */

#include <iostream>
#include <iomanip>
#include "TestClass.h"
#include "fortran_subs.h"

TestClass::TestClass()
{
  std::cout << "Hi guys..." << std::endl;
  x = 0.0e0;
  y = 1.0e0;
  for (unsigned int i = 0; i < 3 ; i++){
    fibo_cycle_(&z,&x,&y);
    std::cout << "z = " << std::fixed << std::setw(20)
              << std::setprecision(17) << z << std::endl;
  }
  std::cout << "...done." << std::endl;
}

TestClass::~TestClass()
{
  std::cout << "Ciao..." << std::endl;
}

/* End of TestClass.C ---------------------------------- */
/* TestClass.h (GNU gold/Intel icpc/Intel ifort test case) */

#ifndef _TESTCLASS_H
#define _TESTCLASS_H

class TestClass {
  private:
  double x,y,z;
  public:
  TestClass();
  ~TestClass();
};

#endif

/* End of TestClass.h ---------------------------------- */
c fibo_cycle.F (GNU gold/Intel icpc/Intel ifort test case)

      SUBROUTINE fibo_cycle(Z,X,Y)
      INTENT(OUT)   Z
      INTENT(INOUT) X,Y
      DOUBLE PRECISION Z,X,Y,X_OLD
      Z = X/Y;
      X_OLD = X;
      X = Y;
      Y = Y + X_OLD;

      RETURN
      END SUBROUTINE fibo_cycle

c End of fibo_cycle.F ------------------------------------
/* fortran_subs.h (GNU gold/Intel icpc/Intel ifort test case) */

#ifndef _FORTRAN_SUBS_H
#define _FORTRAN_SUBS_H

extern "C" {
  void fibo_cycle_(double* Z, double* X, double* Y);
}

#endif

/* End of fortran_subs.h ---------------------------------- */
/* test.C    (GNU gold/Intel icpc/Intel ifort test case) */

#include <cstdio>
#include "TestClass.h"

int main()
{
#if USE_GOLD == 1
  printf("Using gold\n");
#elif USE_GOLD == 0
  printf("Using GNU ld\n");
#else
#error Please define USE_GOLD as 0 or 1
#endif
  TestClass* tc = new TestClass();
  delete tc;
  printf("Byebye\n");
}

/* End of test.C ----------------------------------------*/
address@hidden:~/test/cxx_f90$
address@hidden:~/test/cxx_f90$
address@hidden:~/test/cxx_f90$ make versions
icpc  -O0 --version
icpc (ICC) 10.0 20070613
Copyright (C) 1985-2007 Intel Corporation.  All rights reserved.

ifort -O0 --version
ifort (IFORT) 10.0 20070613
Copyright (C) 1985-2007 Intel Corporation.  All rights reserved.

icpc  -O0 -v -Qlocation,ld,/usr/bin --version
Version 10.0
/usr/bin/ld --version
GNU ld version 2.17 Debian GNU/Linux
Copyright 2005 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.
address@hidden:~/test/cxx_f90$ /mnt/nobackup/bs/gold/bin/ld --version
GNU gold (GNU Binutils 2.19.1) 1.7
Copyright 2008 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
address@hidden:~/test/cxx_f90$
address@hidden:~/test/cxx_f90$
address@hidden:~/test/cxx_f90$ echo x"$GOLD"x
xx
address@hidden:~/test/cxx_f90$
address@hidden:~/test/cxx_f90$
address@hidden:~/test/cxx_f90$ make check
icpc  -O0  -DUSE_GOLD=0  -c -o test.o test.C
icpc  -O0    -c -o TestClass.o TestClass.C
ifort -O0    -c -o fibo_cycle.o fibo_cycle.F
icpc  -O0 -v -Qlocation,ld,/usr/bin -o test.bin test.o TestClass.o fibo_cycle.o
Version 10.0
/usr/bin/ld    /usr/lib64/crt1.o /usr/lib64/crti.o 
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/crtbegin.o --eh-frame-hdr -dynamic-linker 
/lib64/ld-linux-x86-64.so.2 -o test.bin test.o TestClass.o fibo_cycle.o 
-L/mnt/software/qc_dualcore/intel/cce/10.0.025/lib 
-L/usr/lib/gcc/x86_64-linux-gnu/4.1.2/ -L/usr/lib64 -Bstatic -limf -lsvml 
-Bdynamic -lm -Bstatic -lipgo -Bdynamic -lstdc++ -Bstatic -lirc -Bdynamic 
-lgcc_s -lgcc -lcxaguard -Bstatic -lirc -Bdynamic -lc -lgcc_s -lgcc -Bstatic 
-lirc_s -Bdynamic -ldl -lc /usr/lib/gcc/x86_64-linux-gnu/4.1.2/crtend.o 
/usr/lib64/crtn.o
rm /tmp/icpcvPRyrPgnudirs

rm /tmp/icpcydPLBugnudirs

./test.bin
Using GNU ld
Hi guys...
z =  0.00000000000000000
z =  1.00000000000000000
z =  0.50000000000000000
...done.
Ciao...
Byebye
address@hidden:~/test/cxx_f90$
address@hidden:~/test/cxx_f90$
address@hidden:~/test/cxx_f90$ make clean
rm -fr *.o test.bin
address@hidden:~/test/cxx_f90$
address@hidden:~/test/cxx_f90$
address@hidden:~/test/cxx_f90$ GOLD=yes make test.bin
icpc  -O0  -DUSE_GOLD=1  -c -o test.o test.C
icpc  -O0    -c -o TestClass.o TestClass.C
ifort -O0    -c -o fibo_cycle.o fibo_cycle.F
icpc  -O0 -v -Qlocation,ld,/mnt/nobackup/bs/gold/bin -o test.bin test.o 
TestClass.o fibo_cycle.o
Version 10.0
/mnt/nobackup/bs/gold/bin/ld    /usr/lib64/crt1.o /usr/lib64/crti.o 
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/crtbegin.o --eh-frame-hdr -dynamic-linker 
/lib64/ld-linux-x86-64.so.2 -o test.bin test.o TestClass.o fibo_cycle.o 
-L/mnt/software/qc_dualcore/intel/cce/10.0.025/lib 
-L/usr/lib/gcc/x86_64-linux-gnu/4.1.2/ -L/usr/lib64 -Bstatic -limf -lsvml 
-Bdynamic -lm -Bstatic -lipgo -Bdynamic -lstdc++ -Bstatic -lirc -Bdynamic 
-lgcc_s -lgcc -lcxaguard -Bstatic -lirc -Bdynamic -lc -lgcc_s -lgcc -Bstatic 
-lirc_s -Bdynamic -ldl -lc /usr/lib/gcc/x86_64-linux-gnu/4.1.2/crtend.o 
/usr/lib64/crtn.o
rm /tmp/icpccwP0hPgnudirs

rm /tmp/icpcQD18Nugnudirs

address@hidden:~/test/cxx_f90$
address@hidden:~/test/cxx_f90$
address@hidden:~/test/cxx_f90$ GOLD=yes make check
./test.bin
Using gold
Hi guys...
Hi guys... 0.00000000000000000
Hi guys... 1.00000000000000000
Hi guys... 0.50000000000000000
Hi guys...
Hi guys...
Using gold
address@hidden:~/test/cxx_f90$


      

Attachment: bug_report.gold-icpc-ifort.tar.bz2
Description: application/bzip


reply via email to

[Prev in Thread] Current Thread [Next in Thread]