[Numpy-discussion] scipy.scons branch: building numpy and scipy with scons

David Cournapeau cournape@gmail....
Wed Dec 5 00:29:33 CST 2007

On Dec 5, 2007 3:11 PM, Robert Kern <robert.kern@gmail.com> wrote:

> I was only reading code; I haven't tested building Fortran extensions, yet.
> However, using a generic link tool would be the wrong thing to do for most
> Fortran extensions, I think. Where does it get the correct Fortran runtime
> libraries from? Some Fortran compilers really like to be the linker when mixing
> languages.

Yes. SCons does not know how to do that, so I did it the "autoconf"
way: I implemented a mini library to get those linker flags, so that I
can still link C and Fortran code with gcc, not with gfortran or g77
(for example). The relevant code (+ tests) is in scons/fortran.py,
scons/fortran_scons.py + scons/tests. I have tested the parsing part
with g77, gfortran, ifort and sunfort.
> > But I may have done something wrong, because I don't know much about
> > mac os X idiosyncraties on this: basically, what's the difference
> > between -dynamiclib and -bundle ?
> >
> > When I build python extension, I used the module scons builder, which
> > is the same than shared library except on mac os X (on mac os X,
> > shared libraries use -dynamiclib, modules use -bundle). I must confess
> > that I used the thing which worked in thise case, without knowing
> > exactly what i was doing.
> ifort only supports -dynamiclib. For the regular linker, -bundle is correct for
> building Python extensions; I may have to rethink about using ifort to link,
> then. Basically, a bundle can be dynamically loaded while dylibs can't, so
> Python uses bundles for extension modules.
>   http://www.finkproject.org/doc/porting/shared.php

Ah, that rings a bell, I remember now.

> What confuses me is that I successfully built some Fortran modules last night
> using numpy.distutils and ifort -dynamiclib. Hmm.
> >> One thing to note is that this option is only valid for GNU compilers. Linking
> >> with ifort, I need to use -Wl,-undefined,dynamic_lookup .
> > Can't we just add a linker flag instead of using it from the compiler
> > ? We still use the apple linker with ifort/icc, no ?
> I don't know. We'd have to locate all of the Fortran runtime libraries and add
> them. How do we do that? Or is that already done?

Yes, this is already done. To see how it works concretely (from the
package developer POW), you could take a look there, for example:


You use CheckF77Clib during the configuration stage, and if
successfull, this put all the relevant link flags into
env['F77_LDFLAGS']. This is more "hackish" than defining fortran
runtime and co in the tools, but also more robust. What I like with
this approach is that it is testable (you can have trivial unit tests
to test those checkers, without the need for the tested tools to be



More information about the Numpy-discussion mailing list