[Zlib-devel] CHOST option
Török Edwin
edwintorok at gmail.com
Sun May 2 12:59:22 EDT 2010
On 05/02/2010 07:24 PM, Enrico Weigelt wrote:
> * Török Edwin <edwintorok at gmail.com> schrieb:
>
>> A better way to check for a GCC compatible compiler is to check whether
>> the compiler defines __GNUC__.
>> Then it'll work with clang too (and probably Intel's C compiler which
>> defines __GNUC__).
>
> hmm, IMHO that only implies that it supports the GNU C dialect.
> but what about all the command line options ?
libtool has a long list of compilers, platforms and flags.
Certain versions of Intel's Compiler accepted -KPIC, newer versions
accept -fPIC.
Since nobody complained about Intel's Compiler not working with zlib I
assume that either nobody is using it on x86-64 (where PIC actually
leads to a linker error), or they patched it locally to work.
>
>> clang supports -fPIC (and most of the commandline flags that GCC does),
>
> Okay, the project claims to support GCC command line options. But
> I have no idea how reliable this is (especially when it comes to
> shared libraries, which might have different semantics on LLVM).
I've successfully used clang as a drop-in replacement for gcc by
specifying CC=clang.
In fact it works for zlib too, if I edit the makefile and add -fPIC.
Right now clang invokes the gcc driver (not compiler!) for linking on
Linux, and invokes the native assemblers and linkers on platforms where
such support was added (for example FreeBSD).
Right now the only problem with commandline that I am aware of is that
-Wp,-MD doesn't work on clang, and you should use -MD -MF (which works
on both gcc and clang). zlib doesn't use that, so its not an issue.
>
> And what about other compilers that define __GNUC__ ?
>
> Perhaps we should add explicit tests for them.
Intel's C/C++ Compiler is the other one I am aware of.
But I tend to agree with you, its better if we explicitly add support
for clang (and treat it as gcc), rather than assuming that __GNUC__ ==
full gcc compatibility for all compilers.
Here is clang's --version output:
clang version 1.1 (branches/release_27)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Or you can also identify it by checking whether __clang__ is defined.
Best regards,
--Edwin
More information about the Zlib-devel
mailing list