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_r379271818
##########
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}")
Review comment:
The reason for this is that `file` output cannot be `x86_64` if the
http://www.darwinsys.com/file/ implementation is used (according to a statement
on their website, it is used by "all known" Linux distributions). In that
implementation, `x86-64` was introduced in
https://github.com/file/file/commit/e7deb553507b03e6f54829882ae009e648870eea#diff-d55a8317b25513ddc5ca1e726dc3f794R88,
and since then always included a dash, not an underscore.
I suppose the regex (which was introduced in
https://github.com/apache/madlib/commit/eb933f7cec9ea62a082416910647c7d1e9afcc09#diff-5339764dc1c331c74d366bd06bc5cb58R37)
might be an analogy with `lipo` output parsing.
----------------------------------------------------------------
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