This is an automated email from the ASF dual-hosted git repository. okislal pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/madlib.git
The following commit(s) were added to refs/heads/master by this push: new 10e3349 Use uname to determine architecture 10e3349 is described below commit 10e334914314338d32dd205a95126065f1244f4d Author: Orhan Kislal <okis...@apache.org> AuthorDate: Fri Feb 14 14:56:15 2020 -0500 Use uname to determine architecture JIRA: MADLIB-1410 Use 'uname' instead of 'file' in Utils.cmake to determine architecture. 'uname -m' produces output that contains only architecture ("machine") name, while 'file' includes extra data in its output, thus the latter must be parsed. In addition, 'uname' returns the architecture name in a shorter and more "unified" format (although this depends on how the kernel was built). This commit changes 'architecture()' and redefines 'word_length()' cmake macros in order to use 'uname'. As 'architecture()' signature is changed, its usages are updated accordingly. Closes #479 --- cmake/Utils.cmake | 47 +++++++++------------------ src/ports/postgres/cmake/FindPostgreSQL.cmake | 2 +- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake index 6e164ad..4a6e496 100644 --- a/cmake/Utils.cmake +++ b/cmake/Utils.cmake @@ -68,40 +68,23 @@ macro(get_dir_name OUT_DIR IN_PATH) endif(${IN_PATH} MATCHES "^.+/[^/]*\$") endmacro(get_dir_name) -macro(architecture FILENAME OUT_ARCHITECTURE) - if (APPLE) - # On Mac OS X, "lipo" is a more reliable way of finding out the - # architecture of an executable - osx_archs("${FILENAME}" _ARCHITECTURE) - else(APPLE) - execute_process( - COMMAND file "${FILENAME}" - OUTPUT_VARIABLE _FILE_OUTPUT - OUTPUT_STRIP_TRAILING_WHITESPACE) - - # Filter out known architectures - string(REGEX MATCHALL "x86[-_]64|i386|ppc|ppc64" _ARCHITECTURE "${_FILE_OUTPUT}") - - # Normalize (e.g., some vendors use x86-64 instead of x86_64) - string(REGEX REPLACE "x86[-_]64" "x86_64" _ARCHITECTURE "${_ARCHITECTURE}") - endif(APPLE) - - list(REMOVE_DUPLICATES _ARCHITECTURE) - list(LENGTH _ARCHITECTURE _ARCHITECTURE_LENGTH) - if(_ARCHITECTURE_LENGTH GREATER 1) - join_strings(_ARCHITECTURES_STRING ", " "${_ARCHITECTURE}") - message(FATAL_ERROR "Unique word length requested, but " - "${FILENAME} is fat binary (${_ARCHITECTURES_STRING}).") - endif(_ARCHITECTURE_LENGTH GREATER 1) - set(${OUT_ARCHITECTURE} ${_ARCHITECTURE}) +macro(architecture OUT_ARCHITECTURE) + execute_process( + COMMAND uname -m + OUTPUT_VARIABLE ${OUT_ARCHITECTURE} + OUTPUT_STRIP_TRAILING_WHITESPACE + ) endmacro(architecture) -macro(word_length FILENAME OUT_WORD_LENGTH) - architecture(${FILENAME} _ARCHITECTURE) - string(REPLACE "ppc" 32 _${OUT_WORD_LENGTH} "${_ARCHITECTURE}") - string(REPLACE "ppc64" 64 ${OUT_WORD_LENGTH} "${_ARCHITECTURE}") - string(REPLACE "i386" 32 ${OUT_WORD_LENGTH} "${_ARCHITECTURE}") - string(REPLACE "x86_64" 64 ${OUT_WORD_LENGTH} "${_ARCHITECTURE}") +macro(word_length OUT_WORD_LENGTH) + architecture(_ARCHITECTURE) + if(${_ARCHITECTURE} MATCHES "ppc$|ppcle|i[3456]86") + set(${OUT_WORD_LENGTH} 32) + elseif(${_ARCHITECTURE} MATCHES "ppc64|ppc64le|x86_64") + set(${OUT_WORD_LENGTH} 64) + else() + message(FATAL_ERROR "Unable to determine word length for unknown architecture '${_ARCHITECTURE}'") + endif() endmacro(word_length) # Given the length of the parameter list, we require named arguments. diff --git a/src/ports/postgres/cmake/FindPostgreSQL.cmake b/src/ports/postgres/cmake/FindPostgreSQL.cmake index 0f9663d..a1ff042 100644 --- a/src/ports/postgres/cmake/FindPostgreSQL.cmake +++ b/src/ports/postgres/cmake/FindPostgreSQL.cmake @@ -189,7 +189,7 @@ if(${PKG_NAME}_PG_CONFIG AND ${PKG_NAME}_SERVER_INCLUDE_DIR) OUTPUT_STRIP_TRAILING_WHITESPACE ) - architecture("${${PKG_NAME}_EXECUTABLE}" ${PKG_NAME}_ARCHITECTURE) + architecture(${PKG_NAME}_ARCHITECTURE) else() if(${PACKAGE_FIND_VERSION}) message(FATAL_ERROR "Found \"${${PKG_NAME}_PG_CONFIG}\", "