This is the mail archive of the
mailing list for the GCC project.
Re: gcc compiles assert() to code that requires linking withgcc
>>>>> "MM" == Mark Mitchell <email@example.com> writes:
MM> There are two issues here:
MM> - Should GCC compiled libraries have, under any circumstances,
MM> dependencies on libgcc?
MM> - Should using `assert' result in a dependency on libgcc?
MM> The answer to the first question is definitely yes. For example, GCC
MM> uses libgcc to provide floating point emulation for processors that do
MM> not support floating point. GCC uses libgcc to provide support for
MM> exception-handling and global initialization in C++ and Java, as
Agreed. Here I am only concerned with C. C++ is much harder, and I
can understand why achieving binary compatibility with C++ might not
be achievable. But C is much more important, because the prospect of
binary compatibility is one of the most important reasons for choosing
C over C++ in the first place (the other reason, C++ compilation
turning C warnings into errors, is an especial problem for free
software that needs to compile in hostile environments (like configure
scripts on strange machines)).
Many an author of a portable free software library chooses C, eschews
newfangled stuff like `long long', etc in the expectation that library
users be able to create binaries suitable for distribution to others
sharing the same platform. gcc's assert() should not be a hindrance.
MM> However, the fewer dependencies on libgcc the better, all things being
MM> If you can implement assert in a way that is not detrimental in
MM> other ways, but does provide the benefit that simply using
MM> `assert' does not pull in libgcc, that sounds fine to me. You
MM> still should not depend on being able to avoid linking in libgcc;
MM> it may well be needed for other purposes.
MM> You mention the practices of other compiler vendors. Many compiler
MM> vendors include functionality equivalent to libgcc in the OS C
MM> library. GCC cannot do that, in general, since the GCC developers
MM> have no control over the OS C library. So, a separate library is used
MM> In short, when you imply that the output of most compilers works
MM> without linking in a special library, you're incorrect; it's just that
MM> the library you must link in is the C library, which you probably
MM> wanted to link in anyhow.
A Solaris without libc is probably not Solaris - there was the option
of running Sparc-Linux, after all.