Switching compiler between glib and an application/library



  If we buil/install glib (1.1.12) with a compiler (say gcc) some
particularities specific to the compiler are recorded in glibconfig.h file
(which is included by glib.h). As a consequence, it is (right now) not
possible to use another compiler to build an application which uses glib.
It is really a big constraint.
  I may have an application without configure/autoconf setup and only a
Makefile and sources targeted to a native C compiler for example; the make
will fail if glib was built with gcc.

  Moreover, any configure script of an application using glib (or gtk, that
is quite a few applications) will fail if called :
CC=cc ./configure

  In the case of a glib compiled with gcc, I have modified the
/usr/local/lib/glib/include/glibconfig.h installed by make install of
glib1.1.12 following way (handling of inline stuff)

#ifdef   __cplusplus
#define  G_HAVE_INLINE  1
/* #else */ /* !__cplusplus */
#elif  defined(__GNUC__)

#define G_HAVE___INLINE 1
#define G_HAVE___INLINE__ 1

#else
#undef   G_HAVE_INLINE
#undef G_HAVE___INLINE
#undef G_HAVE___INLINE__

#endif   /* !__cplusplus */

With this modification, I can configure and compile a gtk application with
the native C compiler of a Solaris 2.5 computer.

  Hereafter are included some mails I have exchange with TimJ
(timj@gtk.org):
I send following mail to gtk-bugs@gtk.org
---------------------------------------------------------------------------
----------------------
Objet:   A small glitch in installing glib-1.1.12 on Solaris 2.5

  Dear sirs,

After installing glib-1.1.12 on a Solaris 2.5 computer with gcc 2.8.1 (very
easy) the configure script of a GTK application doesn't run if invoked as :
CC=cc ./configure. In fact, I found that the glibconfig.h file is not
copied by make install. Moreover, in glibconfig.h the lines numbered 99 to
105 which deal with INLINE stuff are processed whatever the current
compiler is. Then the sun compiler can't compile conftest.c which tries to
get the current GTK version (it receives in glib.h a bunch of __inline
which it doesn't understand). A possible fix (but I am not sure) would be
to replace line 101 of glibconfig.h :
#else   /* !__cpluplus */
by:
#elif defined( __GNUC__ )

  I hope that helps.

Regards
---------------------------------------------------------------------------
------
  and received :
---------------------------------------------------------------------------
------
On Wed, 6 Jan 1999 fpetitje@bureauveritas.com wrote:

>   Dear sirs,
>
> After installing glib-1.1.12 on a Solaris 2.5 computer with gcc 2.8.1
(very
> easy) the configure script of a GTK application doesn't run if invoked as
:
> CC=cc ./configure. In fact, I found that the glibconfig.h file is not
> copied by make install.

it gets installed in a different directory than glib.h but the glib-config
script should actually take care about that, what are your concrete
configure
problems?

> Moreover, in glibconfig.h the lines numbered 99 to
> 105 which deal with INLINE stuff are processed whatever the current
> compiler is.

that is intentional, due to several differences between compilers, glib
needs
to be reconfigured and reinstalled if you switch compilers.

> Then the sun compiler can't compile conftest.c which tries to
> get the current GTK version (it receives in glib.h a bunch of __inline
> which it doesn't understand). A possible fix (but I am not sure) would be
> to replace line 101 of glibconfig.h :
> #else   /* !__cpluplus */
> by :
> #elif defined( __GNUC__ )

no, the stuff that comes after #else /* !__cplusplus */ are special
definitions
that result from compiler dependant configure tests. checking for GCC is
already performed in the inlining capabilities tests.

>
>   I hope that helps.
>
> Regards.
>
>

---
ciaoTJ
---------------------------------------------------------------------------
------------------
 my response
---------------------------------------------------------------------------
------------------



> On Wed, 6 Jan 1999 fpetitje@bureauveritas.com wrote:

>>   Dear sirs,
>>
>> After installing glib-1.1.12 on a Solaris 2.5 computer with gcc 2.8.1
(very
>> easy) the configure script of a GTK application doesn't run if invoked
as:
>> CC=cc ./configure. In fact, I found that the glibconfig.h file is not
>> copied by make install.

> it gets installed in a different directory than glib.h but the
glib-config
> script should actually take care about that, what are your concrete
configure
> problems?

glib-config script is installed in /usr/local/bin, glib.h in
/usr/local/include and glibconfig.h was not copied, but an old glibconfig.h
from a previous installation remained in /usr/local/include; I manually
copied glibconfig.h. It is no big deal.

>> Moreover, in glibconfig.h the lines numbered 99 to
>> 105 which deal with INLINE stuff are processed whatever the current
>> compiler is.

> that is intentional, due to several differences between compilers, glib
needs
> to be reconfigured and reinstalled if you switch compilers.

  Right now :
  cd glib-x-y-z ; ./configure ; make ; make install
  cd gtk-x-y-z ; ./configure ; make ; make install
Good, simple and efficient.
  cd aGtkAppli ; CC=cc ./configure
  It fails. You argue that, for some technical reasons, the same compiler
must be used to configure and install glib and all code that depends on it.
IMHO this contradicts the fact that glib is a library (and a library which
depends on the C run-time environment only). To use it : #include <glib.h>
in the source code and -lglib in the list of libraries.
  I planned to use glib instead of parts of another library I had written
circa 1992. (arrays that expand automatically). It seems to me that using
the same compiler to compile my application as the one which was used to
compile glib is a big constraint. For example, on the AIX platforms, it may
be the system administrator who installs glib, and to know which compiler
he used, I have either to ask him or to peek at the shared object.
Moreover, the need of (re)configuring/installing of glib in order to use
another compiler reminds me of a RRR nightmare : reboot, reinstall
theApplication , reboot and reinstall Widows.

  Configuring of an application which uses glib is mostly automatic with
help of the glib-config script ( simple and great idea BTW). Perhaps a
--compiler or --preferred-compiler flag should be added to ease autoconf of
such an application. (configure would emit a meaningful error message ). I
think, nevertheless, that compiler's dependencies in glib.h and
glibconfig.h should be checked as to allow a different compiler (for the
application). A lot of logic which is used in configuring glib should be
kept in glib(config).h in order to be used later in configuring/compiling
an application which uses glib.
  Perhaps, while configuring glib, we should have a loop for different
compilers, and create a number of glib-config-NameOfCompiler.h files and
glib.h could begin with :
#if defined( GNUCC )
#include <glibconfig-gcc.h>
#elif defined( USE_XLC )   /* AIX xlc */
#include <glibconfig-xlc.h>
...
#endif
Another way would be to have a single glibconfig.h file with all the
compilers' dependencies.
  I know that such a super autoconf stuff is not trivia, but right now we
have a good configure script and we could write a
configure-for-other-compilers script which would loop over a number of
compilers ( given as arguments) and generate a generalized glibconfig.h
(and hopefully always the same glib-config script ). Instructions to
install glib :
[CC=gcc] configure
make
# if you want to use other compilers : configure-for-other-compilers
make install

  Best regards

PS. I am not a native english speaker and so I apologize if certain
sentences sound harsh, it was not my intention.
---------------------------------------------------------------------------
----------------
and Timj suggest me to post to the gtk-devel-list :
---------------------------------------------------------------------------
----------------


On Mon, 11 Jan 1999 fpetitje@bureauveritas.com wrote:

> >> Moreover, in glibconfig.h the lines numbered 99 to
> >> 105 which deal with INLINE stuff are processed whatever the current
> >> compiler is.
>
> > that is intentional, due to several differences between compilers, glib
> needs
> > to be reconfigured and reinstalled if you switch compilers.
>

[ bunch of good ideas deleted ]

i actually like your idea pretty much. we may not get around to get
compiler specific config headers for 1.2, but it's definitely a good idea
for 1.3. *please* be so nice as to forward this mail to
gtk-devel-list@redhat.com and/or gtk-list@redhat.com.

---
ciaoTJ
---------------------------------------------------------------------------
-----------------

François Petitjean   fpetitje@bureauveritas.com


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]