This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC automatic linkage of libquadmath with gfortran: PR driver/46516; libgfortran.spec, multilib search path

Hello all,

I am still struggling to get "gfortran" (the driver) to properly and automatically link libquadmath, if and only if it is available.

Not working ideas:

a) Adding it to the spec ("-lquadmath") in the front end. The problem is that adding or not adding (or the availability of __float128) can depend on compiler flags. With the current compiler one can implement this, but Jakub, Michael and Richard agree that it only works by chance and is hence the wrong solution. Cf. patch at

b) Asking the user to do it. Well, that always works, but is extremely user unfriendly - especially as the "-lquadmath" has to come after the "-lgfortran" which is not possible by a simply adding "-lquadmath" to the command line. Additionally, as libgfortran depends on libquadmath, one had to always add "-lgfortran -lquadmath" even if one does not use the quadmath library. (The dependency is typicalyl weakref, but one still might get linkage errors without "-lquadmath".)

c) Using a spec file: That's what is currently done. The FE passes a -spec=. However, the it is passed to gcc.c as user spec, which is read before set_multipath() has been called. Thus, either the wrong file is read or like on x86-64-linux with --disable-multilib, no spec file is found.

d) Michael suggested to add a FE hook to the link command spec, i.e. in fortran/lang-specs.h
#define LANG_LINK_LIBS "%:include(libgfortran.spec)%lib_gfortran)"
and then use it in gcc.c's LINK_COMMAND_SPEC. However, a straight-forward approach does not work as this would apply to all front ends. For OpenMP (libgomp.spec) it works as one has the flag -fopenmp, which tells the compiler when to include the spec file. I think, there is currently no means to say in a spec file that it is only for a certain FE (progname == "gfortran").

Any suggestions in which direction I should proceed? I think one can work on (d), but before I spend a significant amount of time, I would like to know whether (d) is the way forward and a sketch how one should handle this properly.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]