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]

tgmath.h without complex.h


This patch follows on from:

    http://gcc.gnu.org/ml/gcc/2007-09/msg00542.html

The issue is that tgmath.h includes complex.h unconditionally, but is
installed and tested on targets that don't provide complex.h.  This
includes most newlib targets, and Dave says that it included older
PA HPUX targets too:

    http://gcc.gnu.org/ml/gcc/2007-09/msg00546.html

Fleshing out the four suggestions in the original post, we could:

    (a) Restrict tgmath.h to scalar types when complex.h isn't provided,
        and skip the complex tgmath.h tests.

    (b) Continue installing tgmath.h as-is but skip the tests for
        !c99_runtime.

    (c) Stop installing tgmath.h on targets without complex.h
        and skip the tests for !c99_runtime.  (I think that's
        better than testing for tgmath.h, as part of the test
        is that tgmath.h is provided when it should be.)

    (d) Do something else.

However, Dave points out that (a) is only really a half measure,
as without full C99 support, not all scalar operations work properly
either.  So unless anyone can suggest something for (d), I'm assuming
it's a choice between (b) and (c).  I don't mind which we do.

The patch below implements (c), but just the testsuite part would
implement (b).  The test for complex.h is based on the test for limits.h,
and is always false for combined-tree newlib builds.  It would be possible
to get gcc to install tgmath.h for future C99 versions of newlib by
using --with-headers or some sysroot arrangement.

Bootstrapped & regression-tested on x86_64-linux-gnu, where the tests
still run.  Also regression-tested on mipsisa64-elf, where the tests
don't run.  As expected, neither target installs tgmath.h, but you can
force it for mipsisa64-elf by setting INSTALL_TGMATH_H=true.
OK to install?

Richard


gcc/
	* Makefile.in (INSTALL_TGMATH_H): New variable.
	(stmp-int-hdrs): Check it when deciding whether to copy tgmath.h.

gcc/testsuite/
	* gcc.dg/c99-tgmath-1.c: Require c99_runtime and add the associated
	options.
	* gcc.dg/c99-tgmath-2.c: Likewise.
	* gcc.dg/c99-tgmath-3.c: Likewise.
	* gcc.dg/c99-tgmath-4.c: Likewise.

Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	2007-09-25 09:32:44.000000000 +0100
+++ gcc/Makefile.in	2007-09-25 09:58:09.000000000 +0100
@@ -305,6 +305,9 @@ USER_H = $(srcdir)/ginclude/float.h \
 	 $(srcdir)/ginclude/stdfix.h \
 	 $(EXTRA_HEADERS)
 
+# Whether <tgmath.h> should be installed, if included in EXTRA_HEADERS.
+INSTALL_TGMATH_H = [ -f $(SYSTEM_HEADER_DIR)/complex.h ]
+
 UNWIND_H = $(srcdir)/unwind-generic.h
 
 # The GCC to use for compiling crt*.o.
@@ -3379,10 +3382,12 @@ stmp-int-hdrs: $(STMP_FIXINC) $(USER_H) 
 	for file in .. $(USER_H); do \
 	  if [ X$$file != X.. ]; then \
 	    realfile=`echo $$file | sed -e 's|.*/\([^/]*\)$$|\1|'`; \
-	    $(STAMP) include/$$realfile; \
-	    rm -f include/$$realfile; \
-	    cp $$file include; \
-	    chmod a+r include/$$realfile; \
+	    if test $$realfile != tgmath.h || $(INSTALL_TGMATH_H); then \
+	      $(STAMP) include/$$realfile; \
+	      rm -f include/$$realfile; \
+	      cp $$file include; \
+	      chmod a+r include/$$realfile; \
+	    fi; \
 	  fi; \
 	done
 	rm -f include/unwind.h
Index: gcc/testsuite/gcc.dg/c99-tgmath-1.c
===================================================================
--- gcc/testsuite/gcc.dg/c99-tgmath-1.c	2007-09-25 09:37:31.000000000 +0100
+++ gcc/testsuite/gcc.dg/c99-tgmath-1.c	2007-09-25 09:37:48.000000000 +0100
@@ -1,7 +1,8 @@
 /* Test for <tgmath.h> in C99. */
 /* Origin: Matt Austern <austern@apple.com>
-/* { dg-do preprocess } */
+/* { dg-do preprocess { target c99_runtime } } */
 /* { dg-options "-std=iso9899:1999" } */
+/* { dg-add-options c99_runtime } */
 
 /* Test that tgmath defines the macros it's supposed to. */
 #include <tgmath.h>
Index: gcc/testsuite/gcc.dg/c99-tgmath-2.c
===================================================================
--- gcc/testsuite/gcc.dg/c99-tgmath-2.c	2007-09-25 09:37:52.000000000 +0100
+++ gcc/testsuite/gcc.dg/c99-tgmath-2.c	2007-09-25 09:38:04.000000000 +0100
@@ -1,7 +1,8 @@
 /* Test for <tgmath.h> in C99. */
 /* Origin: Matt Austern <austern@apple.com>
-/* { dg-do compile } */
+/* { dg-do compile { target c99_runtime } } */
 /* { dg-options "-std=iso9899:1999" } */
+/* { dg-add-options c99_runtime } */
 
 /* Test that invoking type-generic sin on a float invokes sinf. */
 #include <tgmath.h>
Index: gcc/testsuite/gcc.dg/c99-tgmath-3.c
===================================================================
--- gcc/testsuite/gcc.dg/c99-tgmath-3.c	2007-09-25 09:38:25.000000000 +0100
+++ gcc/testsuite/gcc.dg/c99-tgmath-3.c	2007-09-25 09:38:34.000000000 +0100
@@ -1,7 +1,8 @@
 /* Test for <tgmath.h> in C99. */
 /* Origin: Matt Austern <austern@apple.com>
-/* { dg-do compile } */
+/* { dg-do compile { target c99_runtime } } */
 /* { dg-options "-std=iso9899:1999" } */
+/* { dg-add-options c99_runtime } */
 
 /* Test that invoking type-generic exp on a complex invokes cexp. */
 #include <tgmath.h>
Index: gcc/testsuite/gcc.dg/c99-tgmath-4.c
===================================================================
--- gcc/testsuite/gcc.dg/c99-tgmath-4.c	2007-09-25 09:38:41.000000000 +0100
+++ gcc/testsuite/gcc.dg/c99-tgmath-4.c	2007-09-25 09:38:48.000000000 +0100
@@ -1,7 +1,8 @@
 /* Test for <tgmath.h> in C99. */
 /* Origin: Matt Austern <austern@apple.com>
-/* { dg-do compile } */
+/* { dg-do compile { target c99_runtime } } */
 /* { dg-options "-std=iso9899:1999" } */
+/* { dg-add-options c99_runtime } */
 
 /* Test that invoking type-generic pow on complex float invokes cpowf. */
 #include <tgmath.h>


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