This is the mail archive of the gcc-patches@gcc.gnu.org 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]

[PATCH] Fix libgfortran compilation on Tru64


The following libgfortran patch cures a mainline bootstrap failure on
alphaev67-dec-osf5.1.  It turns out that Tru64's libm is broken w.r.t.
its definition of cabs, cabsf and cabsl.  Instead of the ISO C99
mandated definitions that take complex arguments, the Tru64 v5.1
implementations take a pair of floating point values instead of a
complex.  Hence on this target cabs is effectively a synonym for
hypot.  I've no idea if ABI-wise these are equivalent, but the
incompatible function prototypes break our implementations of
clog10f, clog10 and clog10l which call cabsf, cabs and cabsl
respectively.

Admittedly, Tru64 is an old operating system and will never be fixed,
so a reasonable course might be to disable libgfortran on this platform.
Correcting the headers with fixincludes isn't an option due to the
possibility of breaking code that depends upon the Digital/Compaq/HP
definitions.

Alternatively, the patch (hack?) below works around this problem
by convincing c99_functions.c to declare our own local __gfc_cabs,
__gfc_cabsf and __gfc_cabsl functions (that don't conflict with the
symbols in libm.a or prototypes in <math.h>) and then using these
replacements in the definitions of clog10 and friends.

My apologies in advance for the poor idiom "ifdef __osf__" to detect
the affected targets.  If someone with a higher-dan black belt in
configure-foo could show me how to get libgfortran's configure to
conveniently define TARGET_CABS_BROKEN instead, I'll gladly test it
and the obvious tweak to the patch below on the Tru64 box here.

Always the optimist, in case testing __osf__ might be acceptable...
Ok for mainline?  Tested on alphaev67-dec-osf5.1 with a "make
bootstrap" in a tree containing Paolo's patch for PR 25259.

Many thanks in advance,



2005-12-20  Roger Sayle  <roger@eyesopen.com>

	* intrinsics/c99_functions.c: Add function prototypes to avoid
	warnings from -Wstrict-prototypes -Wmissing-prototypes.  On Tru64
	work around a brain-dead libm by redirecting calls to cabs{,f,l}
	to a local __gfc_cabs{,f,l}.


Index: c99_functions.c
===================================================================
*** c99_functions.c	(revision 108807)
--- c99_functions.c	(working copy)
*************** Boston, MA 02110-1301, USA.  */
*** 35,40 ****
--- 35,67 ----
  #define C99_PROTOS_H WE_DONT_WANT_PROTOS_NOW
  #include "libgfortran.h"

+ /* Tru64's <math.h> declares a non-C99 compliant implementation of cabs,
+    which takes two floating point arguments instead of a single complex.
+    To work around this we redirect cabs{,f,l} calls to __gfc_cabs{,f,l}.  */
+
+ #ifdef __osf__
+ #undef HAVE_CABS
+ #undef HAVE_CABSF
+ #undef HAVE_CABSL
+ #define cabs __gfc_cabs
+ #define cabsf __gfc_cabsf
+ #define cabsl __gfc_cabsl
+ #endif
+
+ /* Prototypes to silence -Wstrict-prototypes -Wmissing-prototypes.  */
+
+ float cabsf(float complex);
+ double cabs(double complex);
+ long double cabsl(long double complex);
+
+ float cargf(float complex);
+ double carg(double complex);
+ long double cargl(long double complex);
+
+ float complex clog10f(float complex);
+ double complex clog10(double complex);
+ long double complex clog10l(long double complex);
+

  #ifndef HAVE_ACOSF
  #define HAVE_ACOSF 1


Roger
--


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