summaryrefslogtreecommitdiff
path: root/Modules/CMakeCXXCompilerABI.cpp
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-08-07 09:09:45 -0400
committerBrad King <brad.king@kitware.com>2008-08-07 09:09:45 -0400
commitb8fc8b324d2e1b892d0b41cf3581226c210131d0 (patch)
tree5e36ef6e4586c5304ad69acc64e26779b426c842 /Modules/CMakeCXXCompilerABI.cpp
parente58fab841fff0570d686200b916439cabe4deb83 (diff)
downloadcmake-b8fc8b324d2e1b892d0b41cf3581226c210131d0.tar.gz
ENH: Improve robustness of compiler INFO strings
Compiler INFO strings built at preprocessing time encode information that must appear as a string literal in the resulting binary. We must make sure the strings appear in the final binary no matter what compiler and flags are used. The previous implementation worked in most places but failed with the GNU linker's --gc-sections option which managed to discard the string. Instead we make the program return value depend on an element of the string indexed by a runtime program parameter, which absolutely requires the string to be present.
Diffstat (limited to 'Modules/CMakeCXXCompilerABI.cpp')
-rw-r--r--Modules/CMakeCXXCompilerABI.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/Modules/CMakeCXXCompilerABI.cpp b/Modules/CMakeCXXCompilerABI.cpp
index 7fb3618870..c9b0440b8e 100644
--- a/Modules/CMakeCXXCompilerABI.cpp
+++ b/Modules/CMakeCXXCompilerABI.cpp
@@ -8,17 +8,13 @@
/*--------------------------------------------------------------------------*/
-/* Make sure the information strings are referenced. */
-#define REQUIRE(x) (&x[0] != &require)
-
-int main()
+int main(int argc, char* argv[])
{
- const char require = 0;
- return
- (
- REQUIRE(info_sizeof_dptr)
+ int require = 0;
+ require += info_sizeof_dptr[argc];
#if defined(ABI_ID)
- && REQUIRE(info_abi)
+ require += info_abi[argc];
#endif
- );
+ (void)argv;
+ return require;
}