From 41fbc2ce16f9eb7a17adede62c79d7900ee817ed Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 13 Mar 2025 14:55:10 -0400 Subject: [PATCH] CMakeDetermineCompilerABI: Make ABI info string more robust Backport commit c0224f5aa1 (CMakeDetermineCompilerABI: Make ABI info string more robust, 2025-03-13, v4.1.0-rc1~499^2~4) to 3.31 and 4.0. --- Modules/CMakeCompilerABI.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Modules/CMakeCompilerABI.h b/Modules/CMakeCompilerABI.h index c5ce4dd9ab..8c9ab8f365 100644 --- a/Modules/CMakeCompilerABI.h +++ b/Modules/CMakeCompilerABI.h @@ -40,6 +40,12 @@ static unsigned short const info_byte_order_little_endian[] = { # define ABI_ID "ELF" #endif +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ #if defined(ABI_ID) -static char const info_abi[] = "INFO:abi[" ABI_ID "]"; +static char const* info_abi = "INFO" + ":" + "abi[" ABI_ID "]"; #endif