You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@madlib.apache.org by ok...@apache.org on 2020/02/14 20:00:09 UTC
[madlib] 01/02: Revert "Use uname to determine architecture"
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
commit 97adf6761a7430d7bb2cda5cea6f555363ad26b3
Author: Orhan Kislal <ok...@apache.org>
AuthorDate: Fri Feb 14 14:59:29 2020 -0500
Revert "Use uname to determine architecture"
This reverts commit 10e334914314338d32dd205a95126065f1244f4d.
---
cmake/Utils.cmake | 47 ++++++++++++++++++---------
src/ports/postgres/cmake/FindPostgreSQL.cmake | 2 +-
2 files changed, 33 insertions(+), 16 deletions(-)
diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake
index 4a6e496..6e164ad 100644
--- a/cmake/Utils.cmake
+++ b/cmake/Utils.cmake
@@ -68,23 +68,40 @@ macro(get_dir_name OUT_DIR IN_PATH)
endif(${IN_PATH} MATCHES "^.+/[^/]*\$")
endmacro(get_dir_name)
-macro(architecture OUT_ARCHITECTURE)
- execute_process(
- COMMAND uname -m
- OUTPUT_VARIABLE ${OUT_ARCHITECTURE}
- OUTPUT_STRIP_TRAILING_WHITESPACE
- )
+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})
endmacro(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()
+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}")
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 a1ff042..0f9663d 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}_ARCHITECTURE)
+ architecture("${${PKG_NAME}_EXECUTABLE}" ${PKG_NAME}_ARCHITECTURE)
else()
if(${PACKAGE_FIND_VERSION})
message(FATAL_ERROR "Found \"${${PKG_NAME}_PG_CONFIG}\", "