mirror of
https://github.com/MariaDB/server.git
synced 2025-07-23 00:55:06 +00:00
MDEV-31605 cmake/stack_direction.c does not work correctly on clang 16
According to commit ea56841997
the stack normally grows downwards, except on HP PA-RISC where
it grows upwards. Because determining the stack direction is not
possible in a portable way, let us determine the default STACK_DIRECTION
in CMake based on the ISA.
On clang 16.0.6 running on and targeting AMD64, STACK_DIRECTION=1 is
being incorrectly detected, causing the failure of a number of tests.
This commit is contained in:
@ -672,25 +672,11 @@ int main()
|
||||
}
|
||||
" HAVE_PTHREAD_YIELD_ZERO_ARG)
|
||||
|
||||
IF(NOT STACK_DIRECTION)
|
||||
IF(CMAKE_CROSSCOMPILING)
|
||||
MESSAGE(FATAL_ERROR
|
||||
"STACK_DIRECTION is not defined. Please specify -DSTACK_DIRECTION=1 "
|
||||
"or -DSTACK_DIRECTION=-1 when calling cmake.")
|
||||
ELSE()
|
||||
TRY_RUN(STACKDIR_RUN_RESULT STACKDIR_COMPILE_RESULT
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/cmake/stack_direction.c
|
||||
)
|
||||
# Test program returns 0 (down) or 1 (up).
|
||||
# Convert to -1 or 1
|
||||
IF(STACKDIR_RUN_RESULT EQUAL 0)
|
||||
SET(STACK_DIRECTION -1 CACHE INTERNAL "Stack grows direction")
|
||||
ELSE()
|
||||
SET(STACK_DIRECTION 1 CACHE INTERNAL "Stack grows direction")
|
||||
ENDIF()
|
||||
MESSAGE(STATUS "Checking stack direction : ${STACK_DIRECTION}")
|
||||
ENDIF()
|
||||
IF(STACK_DIRECTION)
|
||||
ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)")
|
||||
SET(STACK_DIRECTION 1 CACHE INTERNAL "Stack grows direction")
|
||||
ELSE()
|
||||
SET(STACK_DIRECTION -1 CACHE INTERNAL "Stack grows direction")
|
||||
ENDIF()
|
||||
|
||||
#
|
||||
|
Reference in New Issue
Block a user