leskin-in commented on a change in pull request #479: Build: Determine 
architecture on Linux machines properly
URL: https://github.com/apache/madlib/pull/479#discussion_r379273521
 
 

 ##########
 File path: cmake/Utils.cmake
 ##########
 @@ -74,16 +74,34 @@ macro(architecture FILENAME OUT_ARCHITECTURE)
         # architecture of an executable
         osx_archs("${FILENAME}" _ARCHITECTURE)
     else(APPLE)
+        # On linux, 'file' is used to determine the architecture. However, its
+        # output is kernel-dependent. http://www.darwinsys.com/file/ is the
+        # widest used implementation. Its outputs for most recent version are
+        # defined in
+        # https://github.com/file/file/blob/master/magic/Magdir/elf
         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}")
+        string(
+            REGEX MATCH
+            "x86-64|Intel 80386|PowerPC or cisco 4500|64-bit PowerPC or cisco 
7500"
+            _FILE_OUTPUT_MATCHED "${_FILE_OUTPUT}"
+        )
+        # Convert the result to Mac OS X lipo format
+        if(_FILE_OUTPUT_MATCHED STREQUAL "x86-64")
+            set(_ARCHITECTURE "x86_64")
 
 Review comment:
   It may be required by the `if(APPLE)` case. The check in question was 
introduced outside of the if-else construct by 
https://github.com/apache/madlib/commit/91f8f67aa192b13b87171130523cc4c96dc0b9d2#diff-5339764dc1c331c74d366bd06bc5cb58R22
 (for some reason, the check was not placed exclusively in `else(APPLE)` 
branch).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to