[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openbsd-tech
Subject:    Re: Fix: take main.c out of libg2c.so
From:       Peter Valchev <pvalchev () sightly ! net>
Date:       2002-05-30 18:35:16
[Download RAW message or body]

> Couldn't get an answer out of a few people...
> If you have an opinion, now is the time.
> otherwise, I will commit this shortly.

I have faced this problem several times, and this diff does allow me to
remove the workarounds.  I say, go ahead.

> Turns out this can prevent linking fortran code with non-fortran code:
> on ELF machines, the reference to MAIN__ from main.c will fall on its
> face, unless you add a (bogus) MAIN__ to the linked code.
> 
> This fix is taken from gcc-current, where they officially support a shared
> libg2c.
> 
> Bump of libg2c.so version number for obvious reasons.
> 
> Index: libf2c/Makefile.bsd-wrapper
> ===================================================================
> RCS file: /cvs/src/gnu/egcs/libf2c/Makefile.bsd-wrapper,v
> retrieving revision 1.4
> diff -u -p -r1.4 Makefile.bsd-wrapper
> --- libf2c/Makefile.bsd-wrapper	15 May 2000 06:10:20 -0000	1.4
> +++ libf2c/Makefile.bsd-wrapper	29 May 2002 11:28:56 -0000
> @@ -12,6 +12,8 @@ EGCS_OBJDIR!=	if [ -d $(EGCS_DIR)/$(OBJD
>  			echo $(EGCS_DIR); \
>  		fi
>  
> +# for libfrtbegin
> +SUBDIR=libF77
>  #SUBDIR=libF77 libI77 libU77
>  LIB=g2c
>  
> @@ -37,7 +39,7 @@ DEFS=-DAllow_TYQUAD -DSTDC_HEADERS=1 -D_
>  -DRETSIGTYPE=void -DIEEE_drem=1 -DHAVE_CONFIG_H \
>  -IlibU77 -I${.CURDIR}/libI77 -I${.OBJDIR} -I${.CURDIR}
>  
> -MISC =	F77_aloc.c main.c s_rnge.c abort_.c getarg_.c iargc_.c\
> +MISC =	F77_aloc.c s_rnge.c abort_.c getarg_.c iargc_.c\
>  	getenv_.c signal_.c s_stop.c s_paus.c system_.c cabs.c\
>  	derf_.c derfc_.c erf_.c erfc_.c sig_die.c exit_.c setarg.c setsig.c
>  POW =	pow_ci.c pow_dd.c pow_di.c pow_hh.c pow_ii.c  pow_ri.c pow_zi.c pow_zz.c \
> Index: libf2c/shlib_version
> ===================================================================
> RCS file: /cvs/src/gnu/egcs/libf2c/shlib_version,v
> retrieving revision 1.1
> diff -u -p -r1.1 shlib_version
> --- libf2c/shlib_version	26 May 1999 15:47:00 -0000	1.1
> +++ libf2c/shlib_version	29 May 2002 11:28:56 -0000
> @@ -1,2 +1,2 @@
> -major=5
> -minor=24
> +major=6
> +minor=0
> Index: libf2c/libF77/Makefile.bsd-wrapper
> ===================================================================
> RCS file: libf2c/libF77/Makefile.bsd-wrapper
> diff -N libf2c/libF77/Makefile.bsd-wrapper
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ libf2c/libF77/Makefile.bsd-wrapper	29 May 2002 11:28:56 -0000
> @@ -0,0 +1,8 @@
> +# $OpenBSD$
> +
> +# This needs to be separate from libg2c to allow for  mixed
> +# Fortran/other language programs.
> +LIB=frtbegin
> +SRCS=main.c
> +
> +.include <bsd.lib.mk>
> Index: gcc/f/g77spec.c
> ===================================================================
> RCS file: /cvs/src/gnu/egcs/gcc/f/g77spec.c,v
> retrieving revision 1.1.1.4
> diff -u -p -r1.1.1.4 g77spec.c
> --- gcc/f/g77spec.c	5 Jun 2000 22:16:19 -0000	1.1.1.4
> +++ gcc/f/g77spec.c	29 May 2002 11:28:56 -0000
> @@ -52,6 +52,10 @@ Boston, MA 02111-1307, USA.  */
>  #define MATH_LIBRARY "-lm"
>  #endif
>  
> +#ifndef FORTRAN_INIT
> +#define FORTRAN_INIT "-lfrtbegin"
> +#endif
> +
>  #ifndef FORTRAN_LIBRARY
>  #define FORTRAN_LIBRARY "-lg2c"
>  #endif
> @@ -286,6 +290,10 @@ lang_specific_driver (fn, in_argc, in_ar
>       2 => last two args were -l<library> -lm.  */
>    int saw_library = 0;
>  
> +  /* 0 => initial/reset state
> +     1 => FORTRAN_INIT linked in */
> +  int use_init = 0;
> +
>    /* By default, we throw on the math library if we have one.  */
>    int need_math = (MATH_LIBRARY[0] != '\0');
>  
> @@ -519,7 +527,14 @@ For bug reporting instructions, please s
>  	      if (saw_library == 1)
>  		saw_library = 2;	/* -l<library> -lm. */
>  	      else
> -		append_arg (FORTRAN_LIBRARY);
> +		{
> +		  if (0 == use_init)
> +		    {
> +		      append_arg (FORTRAN_INIT);
> +		      use_init = 1;
> +		    }
> +		  append_arg (FORTRAN_LIBRARY);
> +		}
>  	    }
>  	  else if (strcmp (argv[i], FORTRAN_LIBRARY) == 0)
>  	    saw_library = 1;	/* -l<library>. */
> @@ -543,6 +558,11 @@ For bug reporting instructions, please s
>        switch (saw_library)
>  	{
>  	case 0:
> +	  if (0 == use_init)
> +	    {
> +	      append_arg (FORTRAN_INIT);
> +	      use_init = 1;
> +	    }
>  	  append_arg (library);
>  	case 1:
>  	 if (need_math)

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic