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

gcc compiles assert() to code that requires linking with gcc


I cannot create a static library that includes a call to assert() and
that is intended for use with the native compiler as well as with gcc.

As you can see in the shell output below, a .a file created by `cc'
can be used by `cc' (either the native compiler on DEC OSF 4.0E, or
the "Forte" (aka. Sun WorkShop 6.0) native compiler for Solaris 2.6),
while a .a file created using gcc 2.95.2 can only be used by gcc.  I
only seem to have this problem (at least on this platform) with
`assert'.

I believe `assert' should be implemented without using libgcc.  After
all, the native compilers on two platforms do it right.  How would you
feel if the native compilers were modified so that vendor libraries
created by that compiler required linking with that compiler as well?

On DEC OSF 4.0E

(martin@tru64) ~/src $ test_binary_compatibility () { rm -f assert.a; $1 -c assert.c; ar cr assert.a assert.o; $2 call-foo.c assert.a ; }
(martin@tru64) ~/src $ test_binary_compatibility gcc29 gcc29
(martin@tru64) ~/src $ test_binary_compatibility gcc29 cc
ld:
Unresolved:
__eprintf
(martin@tru64) ~/src $ test_binary_compatibility cc gcc29
(martin@tru64) ~/src $ test_binary_compatibility cc cc
(martin@tru64) ~/src $ gcc29 --version
2.95.2
(martin@tru64) ~/src $ uname -a
OSF1 tru64.m17n.org V4.0 1091 alpha
(martin@tru64) ~/src $ cat assert.c
#include <assert.h>
void foo (int arg) { assert (arg); }
(martin@tru64) ~/src $ cat call-foo.c
int main (int argc, char *argv[]) { foo (argc); }


Similarily, on Solaris 2.6:

(martin@miho) ~/src $ test_binary_compatibility () { rm -f assert.a; $1 -c assert.c; ar cr assert.a assert.o; $2 call-foo.c assert.a ; }
(martin@miho) ~/src $ test_binary_compatibility gcc29 gcc29
(martin@miho) ~/src $ test_binary_compatibility gcc29 cc
Undefined			first referenced
 symbol  			    in file
__eprintf                           assert.a(assert.o)
ld: fatal: Symbol referencing errors. No output written to a.out
(martin@miho) ~/src $ test_binary_compatibility cc gcc29
(martin@miho) ~/src $ test_binary_compatibility cc cc
(martin@miho) ~/src $ uname -a
SunOS miho 5.6 Generic_105181-05 sun4u sparc SUNW,Ultra-5_10
(martin@miho) ~/src $ cc -V
cc: Sun WorkShop 6 2000/04/07 C 5.1
usage: cc [ options] files.  Use 'cc -flags' for details

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