scons: Resolve backtrace implementation existence testing failure
authorHanhwi Jang <jang.hanhwi@gmail.com>
Tue, 30 Jan 2018 10:17:33 +0000 (19:17 +0900)
committerHanhwi Jang <jang.hanhwi@gmail.com>
Thu, 1 Feb 2018 03:45:16 +0000 (03:45 +0000)
Change backtrace implementation testing code not to have NULL pointer.

SCons fails to find backtrace implementation even if it exists.
The implementation testing code contains NULL pointers as a backtrace
buffer argument. Some compilers check the buffer is NULL pointed
or not, and generate a compilation error.

Change-Id: Icc5bc9a887b7a6bbc804b5b8a5a35a935c78a922
Reviewed-on: https://gem5-review.googlesource.com/7681
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>

SConstruct

index 09c3476d73feae03f65dee73bb8723f63b503661..df647e72584814b77c368d7cb4c0f7851464234c 100755 (executable)
@@ -814,11 +814,12 @@ if not GetOption('without_tcmalloc'):
 # list will be used by default.
 backtrace_impls = [ "none" ]
 
-if conf.CheckLibWithHeader(None, 'execinfo.h', 'C',
-                           'backtrace_symbols_fd((void*)0, 0, 0);'):
+backtrace_checker = 'char temp;' + \
+    ' backtrace_symbols_fd((void*)&temp, 0, 0);'
+if conf.CheckLibWithHeader(None, 'execinfo.h', 'C', backtrace_checker):
     backtrace_impls.append("glibc")
 elif conf.CheckLibWithHeader('execinfo', 'execinfo.h', 'C',
-                           'backtrace_symbols_fd((void*)0, 0, 0);'):
+                             backtrace_checker):
     # NetBSD and FreeBSD need libexecinfo.
     backtrace_impls.append("glibc")
     main.Append(LIBS=['execinfo'])