linking c and fortran with pathscale compilers? 
Author Message
 linking c and fortran with pathscale compilers?

Hi folks.

What's the magic incantation to make pathf90 generate symbols that'll link
with .o's produced by pathcc without scattering underscores through my
code?

It appears that pathf90 wants to append an underscore to all its symbols,
and pathcc isn't appending or prepending anything.

Thanks!



Mon, 24 Nov 2008 02:22:56 GMT  
 linking c and fortran with pathscale compilers?

Quote:

> Hi folks.

> What's the magic incantation to make pathf90 generate symbols that'll link
> with .o's produced by pathcc without scattering underscores through my
> code?

> It appears that pathf90 wants to append an underscore to all its symbols,
> and pathcc isn't appending or prepending anything.

> Thanks!

perhaps....

-f[no-]underscoring (For fortran only) -funderscoring appends
underscores to symbols. -fno-underscoring tells the compiler not to
append underscores to symbols.



Mon, 24 Nov 2008 02:44:42 GMT  
 linking c and fortran with pathscale compilers?


Quote:
>What's the magic incantation to make pathf90 generate symbols that'll link
>with .o's produced by pathcc without scattering underscores through my
>code?

There's a section in the manual that explains it all -- we follow the
same name mangling convention as g77, and take the same flags
(-fno-second-underscore and -fno-underscoring) that g77 does.

There's also a way to control mangling on a symbol-by-symbol basis.

Quote:
>It appears that pathf90 wants to append an underscore to all its symbols,

The g77 mangling is to append 2 underscores to names which already have an
underscore, or 1 elsewise:

foo  -> foo_
f_o  -> f_o__
foo_ -> foo___

-- greg
(working for, not speaking for, QLogic. And I wrote this bit of the
code & documentation.)



Mon, 24 Nov 2008 04:27:50 GMT  
 linking c and fortran with pathscale compilers?

Quote:



> >What's the magic incantation to make pathf90 generate symbols that'll link
> >with .o's produced by pathcc without scattering underscores through my
> >code?

> There's a section in the manual that explains it all...

and if that adequately addresses your problem (as it might well), then
fine. But be aware that there were reasons for the underscore
convention, which is fairly widespread among Fortran compilers. There
are variations in detail, but most of them so something like this and
it isn't just in order to make life difficult for Fortran programmers.

In particular, if you turn off all the underscoring, you open up the
potential for conficts between Fortran names and C function names. The
number of possible conflicts is large. If the Fortran code was written
by people who knew about and consciously avoided the problematic names
(for example, if it was all written by you), then things might work
well. But....

I can testify first-hand about the kinds of problems you can run into.
Many moons ago (about 25-30 years worth), before I had ever heard about
C (it existed, but I hadn't head of it yet), the names fopen, fclose,
fread, fwrite, and fseek seemed appropriate for a Fortran library I was
writing. No, I'm not making this up; those were indeed the names that I
used. As I suspect you can imagine, those choices don't tend to work
very well on a Unix box where the Fortran compiler doesn't use something
like the underscore convention.

This might be an argument for overriding it only for the specific cases
where the inderscores are being a nuisance for you rather than globally.

--
Richard Maine                     | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov            |       -- Mark Twain



Mon, 24 Nov 2008 04:54:18 GMT  
 linking c and fortran with pathscale compilers?


Quote:
> As I suspect you can imagine, those choices don't tend to work
> very well on a Unix box where the Fortran compiler doesn't use something
> like the underscore convention.

Yeah, first time I used AIX, I learned that one the hard way!

Quote:
>This might be an argument for overriding it only for the specific cases
>where the inderscores are being a nuisance for you rather than globally.

It's fairly rare to be able to do this with a compiler, but that's
exactly why we added it -- we have customers who want to make a bunch
of libraries available without building multiple versions, and this
feature allows them to mangle just those symbols differently, without
changing the global default mangling.

-- greg



Mon, 24 Nov 2008 05:59:28 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. PathScale Compiler For AMD64

2. PathScale Compiler Team Joins SiCortex

3. Pathscale compiler errors and Emacs

4. linking to g77-compiled libraries with Intel Fortran Compiler on linux

5. Compiler error when link to the library created by Compaq Visual Fortran

6. Intel fortran linux compiler -link problems

7. Silicon Graphics: How can I get MIPSpro fortran 90 compiler to link with -o32 library

8. Fortran compiler/Dynamic Link Lib.

9. Linking Intel Fortran library with another compiler

10. I want to link Fortran static library compiled with pgf90 compiler with C++ in Linux

11. The Sun4 Fortran compiler and DEC Fortran compiler

12. Request: help linking egcs-compiled fortran + other fortran

 

 
Powered by phpBB® Forum Software