[Cmake-commits] [cmake-commits] king committed CMakeCCompilerABI.c 1.1 1.2 CMakeCCompilerId.c.in 1.3 1.4 CMakeCXXCompilerABI.cpp 1.1 1.2 CMakeCXXCompilerId.cpp.in 1.2 1.3 CheckTypeSizeC.c.in 1.3 1.4 TestEndianess.c.in 1.1 1.2

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Aug 7 09:09:48 EDT 2008


Update of /cvsroot/CMake/CMake/Modules
In directory public:/mounts/ram/cvs-serv3460/Modules

Modified Files:
	CMakeCCompilerABI.c CMakeCCompilerId.c.in 
	CMakeCXXCompilerABI.cpp CMakeCXXCompilerId.cpp.in 
	CheckTypeSizeC.c.in TestEndianess.c.in 
Log Message:
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.


Index: CMakeCXXCompilerABI.cpp
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CMakeCXXCompilerABI.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C 2 -d -r1.1 -r1.2
*** CMakeCXXCompilerABI.cpp	21 Jan 2008 23:30:17 -0000	1.1
--- CMakeCXXCompilerABI.cpp	7 Aug 2008 13:09:45 -0000	1.2
***************
*** 9,24 ****
  /*--------------------------------------------------------------------------*/
  
! /* Make sure the information strings are referenced.  */
! #define REQUIRE(x) (&x[0] != &require)
! 
! int main()
  {
!   const char require = 0;
!   return
!     (
!       REQUIRE(info_sizeof_dptr)
  #if defined(ABI_ID)
!       && REQUIRE(info_abi)
  #endif
!       );
  }
--- 9,20 ----
  /*--------------------------------------------------------------------------*/
  
! int main(int argc, char* argv[])
  {
!   int require = 0;
!   require += info_sizeof_dptr[argc];
  #if defined(ABI_ID)
!   require += info_abi[argc];
  #endif
!   (void)argv;
!   return require;
  }

Index: CMakeCCompilerABI.c
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CMakeCCompilerABI.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C 2 -d -r1.1 -r1.2
*** CMakeCCompilerABI.c	21 Jan 2008 23:30:17 -0000	1.1
--- CMakeCCompilerABI.c	7 Aug 2008 13:09:45 -0000	1.2
***************
*** 13,28 ****
  /*--------------------------------------------------------------------------*/
  
! /* Make sure the information strings are referenced.  */
! #define REQUIRE(x) (&x[0] != &require)
! 
! int main()
  {
!   const char require = 0;
!   return
!     (
!       REQUIRE(info_sizeof_dptr)
  #if defined(ABI_ID)
!       && REQUIRE(info_abi)
  #endif
!       );
  }
--- 13,28 ----
  /*--------------------------------------------------------------------------*/
  
! #ifdef __CLASSIC_C__
! int main(argc, argv) int argc; char *argv[];
! #else
! int main(int argc, char *argv[])
! #endif
  {
!   int require = 0;
!   require += info_sizeof_dptr[argc];
  #if defined(ABI_ID)
!   require += info_abi[argc];
  #endif
!   (void)argv;
!   return require;
  }

Index: TestEndianess.c.in
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/TestEndianess.c.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -C 2 -d -r1.1 -r1.2
*** TestEndianess.c.in	10 Aug 2007 17:14:00 -0000	1.1
--- TestEndianess.c.in	7 Aug 2008 13:09:45 -0000	1.2
***************
*** 11,20 ****
  
  #ifdef __CLASSIC_C__
! int main(){
!   int ac;
!   char*av[];
  #else
! int main(int ac, char*av[]){
  #endif
!    return (&info_little[0] != &info_big[0]);
  }
--- 11,23 ----
  
  #ifdef __CLASSIC_C__
! int main(argc, argv) int argc; char *argv[];
  #else
! int main(int argc, char *argv[])
  #endif
! {
!   int require = 0;
!   require += info_little[argc];
!   require += info_big[argc];
!   (void)argv;
!   return require;
  }

Index: CheckTypeSizeC.c.in
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CheckTypeSizeC.c.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -C 2 -d -r1.3 -r1.4
*** CheckTypeSizeC.c.in	5 Jun 2007 14:20:21 -0000	1.3
--- CheckTypeSizeC.c.in	7 Aug 2008 13:09:45 -0000	1.4
***************
*** 30,42 ****
    ']','\0'};
  
- 
  #ifdef __CLASSIC_C__
! int main(){
!   int ac;
!   char*av[];
  #else
! int main(int ac, char*av[]){
  #endif
!   return (&info_sizeof[0] != &info_sizeof[0]);
  }
  
--- 30,43 ----
    ']','\0'};
  
  #ifdef __CLASSIC_C__
! int main(argc, argv) int argc; char *argv[];
  #else
! int main(int argc, char *argv[])
  #endif
! {
!   int require = 0;
!   require += info_sizeof[argc];
!   (void)argv;
!   return require;
  }
  

Index: CMakeCCompilerId.c.in
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CMakeCCompilerId.c.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -C 2 -d -r1.3 -r1.4
*** CMakeCCompilerId.c.in	10 Mar 2008 13:32:25 -0000	1.3
--- CMakeCCompilerId.c.in	7 Aug 2008 13:09:45 -0000	1.4
***************
*** 3,15 ****
  #endif
  
- /* Provide main() so the program can link.  */
  #if defined(__18CXX)
  # define ID_VOID_MAIN
  #endif
- #ifdef ID_VOID_MAIN
- void main() {}
- #else
- int main() { return 0; }
- #endif
  
  #if defined(__INTEL_COMPILER) || defined(__ICC)
--- 3,9 ----
***************
*** 83,84 ****
--- 77,93 ----
  
  @CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@
+ 
+ /*--------------------------------------------------------------------------*/
+ 
+ #ifdef ID_VOID_MAIN
+ void main() {}
+ #else
+ int main(int argc, char* argv[])
+ {
+   int require = 0;
+   require += info_compiler[argc];
+   require += info_platform[argc];
+   (void)argv;
+   return require;
+ }
+ #endif

Index: CMakeCXXCompilerId.cpp.in
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CMakeCXXCompilerId.cpp.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -C 2 -d -r1.2 -r1.3
*** CMakeCXXCompilerId.cpp.in	10 Mar 2008 13:32:25 -0000	1.2
--- CMakeCXXCompilerId.cpp.in	7 Aug 2008 13:09:45 -0000	1.3
***************
*** 6,12 ****
  #endif
  
- /* Provide main() so the program can link.  */
- int main() { return 0; }
- 
  #if defined(__COMO__)
  # define COMPILER_ID "Comeau"
--- 6,9 ----
***************
*** 71,72 ****
--- 68,80 ----
  
  @CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT@
+ 
+ /*--------------------------------------------------------------------------*/
+ 
+ int main(int argc, char* argv[])
+ {
+   int require = 0;
+   require += info_compiler[argc];
+   require += info_platform[argc];
+   (void)argv;
+   return require;
+ }



More information about the Cmake-commits mailing list