[CMake] CHECK_TYPE_SIZE works incorrectly with LDFLAGS="-Wl, --gc-sections"
Brad King
brad.king at kitware.com
Thu Aug 7 09:11:18 EDT 2008
Arfrever Frehtes Taifersar Arahesis wrote:
> 2008-08-06 21:05:50 Brad King napisa?(a):
>> The trick is to convince the compiler to put the string in the final
>> binary. Getting this to happen on all compilers has required a few
>> iterations. Basically we have to make sure the program return value
>> depends on the data. It looks like we still need a better method to
>> prevent the string from being removed by --gc-sections. Try editing
>> CheckTypeSizeC.c.in in your CMake installation, and replace the line
>>
>> return (&info_sizeof[0] != &info_sizeof[0]);
>>
>> with
>>
>> return info_sizeof[0];
>>
>> Then try building your project again.
>
> It seems to work correctly.
> Please include this change in the next version of CMake.
Okay, thanks. I've committed a change that should absolutely require
the strings to be present on all platforms. Now I make the program
return value depend on an element of the string indexed by a runtime
parameter (argc). Even though the program will never really be run this
makes the compiler and linker put the string in the binary.
-Brad
More information about the CMake
mailing list