[CMake] CHECK_TYPE_SIZE works incorrectly with LDFLAGS="-Wl, --gc-sections"

Arfrever Frehtes Taifersar Arahesis arfrever.fta at gmail.com
Mon Aug 4 16:03:57 EDT 2008


CHECK_TYPE_SIZE returns incorrect (empty) values of types sizes when
the LDFLAGS variable contains "-Wl,--gc-sections".

This bug causes compilation failures in probably all packages which
use CHECK_TYPE_SIZE.

I'm attaching 2 files which help to reproduce this bug.

Steps to reproduce:
1. Save the attachments to ${PROJECT_SOURCE_DIR}
2. Run: export LDFLAGS="-Wl,--gc-sections"
3. Run: cmake ${PROJECT_SOURCE_DIR}
4. Read ${PROJECT_BINARY_DIR}/config.h

I use CMake 2.6.0.

-- 
Arfrever Frehtes Taifersar Arahesis
-------------- next part --------------
cmake_minimum_required(VERSION 2.6.0)

include(CheckTypeSize)

CHECK_TYPE_SIZE("char" SIZE_OF_CHAR)
CHECK_TYPE_SIZE("wchar_t" SIZE_OF_WCHAR_T)

CHECK_TYPE_SIZE("short" SIZE_OF_SHORT)
CHECK_TYPE_SIZE("int" SIZE_OF_INT)
CHECK_TYPE_SIZE("long" SIZE_OF_LONG)
CHECK_TYPE_SIZE("long long" SIZE_OF_LONG_LONG)

CHECK_TYPE_SIZE("float" SIZE_OF_FLOAT)
CHECK_TYPE_SIZE("double" SIZE_OF_DOUBLE)
CHECK_TYPE_SIZE("long double" SIZE_OF_LONG_DOUBLE)

configure_file(${PROJECT_SOURCE_DIR}/config.h.in ${PROJECT_BINARY_DIR}/config.h)
-------------- next part --------------
#ifndef CONFIG_H
#define CONFIG_H

#define SIZE_OF_CHAR ${SIZE_OF_CHAR}
#define SIZE_OF_WCHAR_T ${SIZE_OF_WCHAR_T}

#define SIZE_OF_SHORT ${SIZE_OF_SHORT}
#define SIZE_OF_INT ${SIZE_OF_INT}
#define SIZE_OF_LONG ${SIZE_OF_LONG}
#define SIZE_OF_LONG_LONG ${SIZE_OF_LONG_LONG}

#define SIZE_OF_FLOAT ${SIZE_OF_FLOAT}
#define SIZE_OF_DOUBLE ${SIZE_OF_DOUBLE}
#define SIZE_OF_LONG_DOUBLE ${SIZE_OF_LONG_DOUBLE}

#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080804/052ab197/attachment.pgp>


More information about the CMake mailing list