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

Getting glibfortran to build on newlib targets aka. missing stdint.h(PR 14325)


I'd like to be able to build libgfortran on cross targets that
use newlib, not see a build breakage like now, whenever MPFR
and gmp are present:
/home/hp/combined/mmixware-sim/gcc/xgcc
-B/home/hp/combined/mmixware-sim/gcc/ -nostdinc
-B/home/hp/combined/mmixware-sim/mmix-knuth-mmixware/newlib/ -isystem
/home/hp/combined/mmixware-sim/mmix-knuth-mmixware/newlib/targ-include
-isystem /home/hp/combined/combined/newlib/libc/include -B/usr/local/mmix-knuth-mmixware/bin/
-B/usr/local/mmix-knuth-mmixware/lib/ -isystem
/usr/local/mmix-knuth-mmixware/include -isystem
/usr/local/mmix-knuth-mmixware/sys-include
-L/home/hp/combined/mmixware-sim/ld -DHAVE_CONFIG_H -I.\
 -I/home/hp/combined/combined/libgfortran -I.
-I/home/hp/combined/combined/libgfortran/io -O2 -g -O2
-std=gnu99 -O2 -g -O2 -c /home/hp/combined/combined/libgfortran/runtime/environ.c -o
environ.o
In file included from
/home/hp/combined/combined/libgfortran/runtime/environ.c:26:
/home/hp/combined/combined/libgfortran/libgfortran.h:79: error:
syntax error before 'GFC_INTEGER_4'
/home/hp/combined/combined/libgfortran/libgfortran.h:79:
warning: type defaults to 'int' in declaration of
'GFC_INTEGER_4'
/home/hp/combined/combined/libgfortran/libgfortran.h:79:
warning: data definition has no type or storage class
...

It's also a problem that I can't find a way to turn off
libgfortran without hacking configure.in in this case.

The issue is use of stdint.h types like int32_t, as noted in
PR libfortran/14325.

Three ways to fix this:

1 Provide stdint.h in newlib
  The issue has been discussed there, and turned down
  because it was seen as a job for GCC (FWIW, I agree).

2 Provide stdint.h from GCC.  Maybe too late for stage3?

3 configure machinery in libgfortran.  See below.

I prefer 2, with a stdint.h provided by gcc as it does with the
files in ginclude, for example float.h, *but only for those
target systems known not to provide a stdint.h today*.  If I
hear "ok" from a person willing to approve such a change, I can
do that; I have a copy of the C99 standard at work, at least.

Meanwhile, here's a patch to libgfortran, which I hope can be
accepted regardless of any stdint.h decision.
Bootstrapped a couple of times on i686-pc-linux-gnu (FC2) and
cross to mmix-knuth-mmixware, arm-elf, mips-elf.

Unfortunately, most link and execute newlib tests fail,
generally due to lack of the functions dup, access and ftruncate
in newlib.  But that's a different story; now builds *succeed*.

Ok to commit?

libgfortran:

	* acinclude.m4 (LIBGFOR_INTTYPE): New macro.
	* configure.ac: Use LIBGFOR_INTTYPE to get fallback types for
	int64_t, uint64_t, int32_t, uint32_t, int16_t, uint16_t, int8_t
	and uint8_t.
	* config.h.in, configure: Regenerate.

Index: acinclude.m4
===================================================================
RCS file: /mnt/auto/localgcccvs/gcc/libgfortran/acinclude.m4,v
retrieving revision 1.3
diff -p -c -r1.3 acinclude.m4
*** acinclude.m4	5 Nov 2004 03:49:25 -0000	1.3
--- acinclude.m4	6 Nov 2004 19:10:20 -0000
*************** AC_DEFUN([AC_LIBTOOL_DLOPEN])
*** 83,85 ****
--- 83,100 ----
  AC_DEFUN([AC_PROG_LD])
  ])

+ # If typename exists as a type, all ok.  Else, replace with alt1 if it
+ # exists.  If it doesn't, check size of alt2 and use that, else emit error.
+ # $1=typename, $2=alt1, $3=alt2, $4=cachevarsizename, $5=sizeof, $6=msgfrag.
+ AC_DEFUN([LIBGFOR_INTTYPE], [
+ 	AC_CHECK_TYPES([$1],,
+ 		[AC_CHECK_TYPES([$2],
+ 		        [ac_cv_gforlib_$1=$2],
+ 			[AC_CHECK_SIZEOF([$3])
+ 			 if test "$$4" != $5; then
+ 			   AC_MSG_ERROR([No suitable $6 integer type found])
+ 			 else
+ 			   ac_cv_gforlib_$1="$3"
+ 			 fi])
+ 		 AC_DEFINE_UNQUOTED([$1],[$ac_cv_gforlib_$1],
+ 		 	  [Replacement for $1])])])
Index: configure.ac
===================================================================
RCS file: /mnt/auto/localgcccvs/gcc/libgfortran/configure.ac,v
retrieving revision 1.13
diff -p -c -r1.13 configure.ac
*** configure.ac	5 Nov 2004 12:50:53 -0000	1.13
--- configure.ac	6 Nov 2004 19:10:20 -0000
*************** AC_SYS_LARGEFILE
*** 148,153 ****
--- 148,170 ----
  AC_FUNC_MMAP
  AC_TYPE_OFF_T

+ LIBGFOR_INTTYPE([int64_t], [__int64_t], [long long],
+ 		[ac_cv_sizeof_long_long], 8, [64-bit])
+ LIBGFOR_INTTYPE([uint64_t], [__uint64_t], [unsigned long long],
+ 		[ac_cv_sizeof_unsigned_long_long], 8, [unsigned 64-bit])
+ LIBGFOR_INTTYPE([int32_t], [__int32_t], [int],
+ 		[ac_cv_sizeof_int], 4, [32-bit])
+ LIBGFOR_INTTYPE([uint32_t], [__uint32_t], [unsigned int],
+ 		[ac_cv_sizeof_unsigned_int], 4, [unsigned 32-bit])
+ LIBGFOR_INTTYPE([int16_t], [__int16_t], [short],
+ 		[ac_cv_sizeof_short], 2, [16-bit])
+ LIBGFOR_INTTYPE([uint16_t], [__uint16_t], [unsigned short],
+ 		[ac_cv_sizeof_unsigned_short], 2, [unsigned 16-bit])
+ LIBGFOR_INTTYPE([int8_t], [__int8_t], [signed char],
+ 		[ac_cv_sizeof_signed_char], 1, [8-bit])
+ LIBGFOR_INTTYPE([uint8_t], [__uint8_t], [unsigned char],
+ 		[ac_cv_sizeof_unsigned_char], 1, [unsigned 8-bit])
+
  # check header files
  AC_STDC_HEADERS
  AC_HAVE_HEADERS(stdlib.h stdio.h string.h stddef.h math.h unistd.h)

brgds, H-P


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