Workaround for short jump tables on PA-RISC.

The PA-RISC architecture requires special options for GCC to prevent
linker errors when libraries reach a certain size and / or complexity.
See http://mraw.org/blog/2007/10/10/Linking_on_hppa and gcc
documentation on -mlong-calls.
This commit is contained in:
Chuck Atkins 2014-11-04 11:01:56 -05:00 committed by Brad King
parent 0c3ddf8b65
commit 04f442f755
2 changed files with 38 additions and 17 deletions

View File

@ -65,6 +65,16 @@ if(CMAKE_SYSTEM_NAME MATCHES "HP-UX" AND CMAKE_CXX_COMPILER_ID MATCHES "HP")
endif() endif()
endif() endif()
# Workaround for short jump tables on PA-RISC
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^parisc")
if(CMAKE_COMPILER_IS_GNUC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlong-calls")
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-calls")
endif()
endif()
# use the ansi CXX compile flag for building cmake # use the ansi CXX compile flag for building cmake
if (CMAKE_ANSI_CXXFLAGS) if (CMAKE_ANSI_CXXFLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}")
@ -74,10 +84,4 @@ if (CMAKE_ANSI_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
endif () endif ()
# avoid binutils problem with large binaries, e.g. when building CMake in debug mode
# See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50230
if (CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL parisc)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--unique=.text._*")
endif ()
include (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityCXX.cmake) include (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityCXX.cmake)

View File

@ -122,17 +122,32 @@ else
cmake_system_openvms=false cmake_system_openvms=false
fi fi
# Determine whether this is HP-UX
if echo "${cmake_system}" | grep HP-UX >/dev/null 2>&1; then
cmake_system_hpux=true
else
cmake_system_hpux=false
fi
# Determine whether this is Linux # Determine whether this is Linux
if echo "${cmake_system}" | grep Linux >/dev/null 2>&1; then if echo "${cmake_system}" | grep Linux >/dev/null 2>&1; then
cmake_system_linux=true cmake_system_linux=true
# find out if it is a HP PA-RISC machine
if uname -m | grep parisc >/dev/null 2>&1; then
cmake_machine_parisc=true
else
cmake_machine_parisc=false
fi
else else
cmake_system_linux=false cmake_system_linux=false
fi
# Determine whether this is a PA-RISC machine
# This only works for Linux or HP-UX, not other PA-RISC OSs (BSD maybe?). Also
# may falsely detect parisc on HP-UX m68k
cmake_machine_parisc=false
if ${cmake_system_linux}; then
if uname -m | grep parisc >/dev/null 2>&1; then
cmake_machine_parisc=true
fi
elif ${cmake_system_hpux}; then
if !(uname -m | grep ia64 >/dev/null 2>&1); then
cmake_machine_parisc=true
fi
fi fi
# Choose the generator to use for bootstrapping. # Choose the generator to use for bootstrapping.
@ -744,11 +759,13 @@ if ${cmake_system_haiku}; then
cmake_ld_flags="${LDFLAGS} -lroot -lbe" cmake_ld_flags="${LDFLAGS} -lroot -lbe"
fi fi
if ${cmake_system_linux}; then # Workaround for short jump tables on PA-RISC
# avoid binutils problem with large binaries, e.g. when building CMake in debug mode if ${cmake_machine_parisc}; then
# See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50230 if ${cmake_c_compiler_is_gnu}; then
if ${cmake_machine_parisc}; then cmake_c_flags="${CFLAGS} -mlong-calls"
cmake_ld_flags="${LDFLAGS} -Wl,--unique=.text._*" fi
if ${cmake_cxx_compiler_is_gnu}; then
cmake_cxx_flags="${CXXFLAGS} -mlong-calls"
fi fi
fi fi