[CMake] faq update?

Goswin von Brederlow brederlo at informatik.uni-tuebingen.de
Fri Sep 14 06:29:40 EDT 2007


"Brandon Van Every" <bvanevery at gmail.com> writes:

> On 9/13/07, Goswin von Brederlow <brederlo at informatik.uni-tuebingen.de> wrote:
>>
>> For dynamic code (in C/C++/obj-c/fortran/anythign with C linkage) you
>> must use -fPIC or variant thereof because otherwise your jump labels
>> will be too small and linking will fail sometimes on x86, nearly
>> always on amd64, ppc, always on ia64, hppa, ...
>>
>> And if you build static code with -fPIC then you get the reverse on
>> some archs and loose, some claim up to 30%, speed on x86 and amd64.
>
> Great.  I just took a stab at redrafting the new FAQ material for
> clarity, not accuracy.  So now I will ask, is what's described
> actually correct, at least for Linux and GCC?
> http://www.cmake.org/Wiki/CMake_FAQ#Library_questions
> If it's all YMMV for different Unixes or compilers, then we need
> strong warnings about trying to apply this trick cross-platform.  As
> well as performance consequences you mention.

What your hack builds there is the *.so and *_pic.a. You build a
static library suitable for use in a dynamic library. Afaik no common
architecture has problems with using -fPIC for a static lib but as
mentioned you loose the speed gain associated with static code.

As to functionality I think it should work on other unix systems too
and other compilers as well provided the two options you used exist.
Don't ask me about windows dlls though.

MfG
        Goswin


More information about the CMake mailing list