Including cpuinfo_arm.h from an Apple M1 target.
Gio-Jimdo opened this issue · 4 comments
While installing some other node dependencies, one of them attempts to build cpu_features
using node-gyp
and fails with the following message. Is there an environment variable the code will look for to control this, or is it simply an issue on Apple M1
or am I jus totally off-base?
Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /Users/gio/Code/devex-backstage/node_modules/cpu-features
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@7.1.2
gyp info using node@14.17.6 | darwin | arm64
gyp info find Python using Python version 3.9.7 found at \"/Users/gio/.pyenv/versions/3.9.7/bin/python\"
gyp info spawn /Users/gio/.pyenv/versions/3.9.7/bin/python
gyp info spawn args [
gyp info spawn args '/Users/gio/Code/devex-backstage/node_modules/@npmcli/run-script/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/gio/Code/devex-backstage/node_modules/cpu-features/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/gio/Code/devex-backstage/node_modules/@npmcli/run-script/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/gio/Library/Caches/node-gyp/14.17.6/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/gio/Library/Caches/node-gyp/14.17.6',
gyp info spawn args '-Dnode_gyp_dir=/Users/gio/Code/devex-backstage/node_modules/@npmcli/run-script/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/gio/Library/Caches/node-gyp/14.17.6/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/gio/Code/devex-backstage/node_modules/cpu-features',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
ACTION Configuring dependencies /Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build/Makefile
-- The C compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for dlfcn.h
-- Looking for dlfcn.h - found
-- Looking for getauxval
-- Looking for getauxval - not found
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build
TOUCH Release/obj.target/config_deps.stamp
ACTION Building dependencies /Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build/libcpu_features.a
gmake[1]: Entering directory '/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build'
gmake[2]: Entering directory '/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build'
gmake[3]: Entering directory '/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build'
gmake[3]: Leaving directory '/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build'
gmake[3]: Entering directory '/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build'
[ 11%] Building C object CMakeFiles/utils.dir/src/filesystem.c.o
[ 22%] Building C object CMakeFiles/utils.dir/src/stack_line_reader.c.o
[ 33%] Building C object CMakeFiles/utils.dir/src/string_view.c.o
gmake[3]: Leaving directory '/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build'
[ 33%] Built target utils
gmake[3]: Entering directory '/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build'
gmake[3]: Leaving directory '/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build'
gmake[3]: Entering directory '/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build'
[ 44%] Building C object CMakeFiles/unix_based_hardware_detection.dir/src/hwcaps.c.o
[ 55%] Building C object CMakeFiles/unix_based_hardware_detection.dir/src/unix_features_aggregator.c.o
gmake[3]: Leaving directory '/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build'
[ 55%] Built target unix_based_hardware_detection
gmake[3]: Entering directory '/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build'
gmake[3]: Leaving directory '/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build'
gmake[3]: Entering directory '/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build'
[ 66%] Building C object CMakeFiles/cpu_features.dir/src/cpuinfo_arm.c.o
In file included from /Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/src/cpuinfo_arm.c:15:
/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_arm.h:118:2: error: \"Including cpuinfo_arm.h from a non-arm target.\"
#error \"Including cpuinfo_arm.h from a non-arm target.\"
^
1 error generated.
gmake[3]: *** [CMakeFiles/cpu_features.dir/build.make:76: CMakeFiles/cpu_features.dir/src/cpuinfo_arm.c.o] Error 1
gmake[3]: Leaving directory '/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build'
gmake[2]: *** [CMakeFiles/Makefile2:90: CMakeFiles/cpu_features.dir/all] Error 2
gmake[2]: Leaving directory '/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build'
gmake[1]: *** [Makefile:136: all] Error 2
gmake[1]: Leaving directory '/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build'
make: *** [/Users/gio/Code/devex-backstage/node_modules/cpu-features/deps/cpu_features/build/libcpu_features.a] Error 2
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/gio/Code/devex-backstage/node_modules/@npmcli/run-script/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:400:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Darwin 20.6.0
gyp ERR! command \"/Users/gio/.nvm/versions/node/v14.17.6/bin/node\" \"/Users/gio/Code/devex-backstage/node_modules/.bin/node-gyp\" \"rebuild\"
gyp ERR! cwd /Users/gio/Code/devex-backstage/node_modules/cpu-features
seem related to #121
cpu_features/include/cpuinfo_arm.h
Lines 117 to 119 in 628c50e
cpu_features/include/cpu_features_macros.h
Lines 38 to 40 in 1199437
seem related to #121
cpu_features/include/cpuinfo_arm.h
Lines 117 to 119 in 628c50e
cpu_features/include/cpu_features_macros.h
Lines 38 to 40 in 1199437
... and how would one set an environment variable that un-sets these flags?
Sorry I mean it is a two folds problem:
First CMake detect (at configure time) your current host platform as arm
(and not arm64/aarch64
)
Lines 57 to 58 in 628c50e
then we add the corresponding file to the source list
Lines 73 to 75 in 628c50e
then in each
cpuinfo_*.h
file we check (at compile time i.e. cmake build time) if we support the currently compiler detected arm flavor...
Questions:
-
Is is legit to suppose your machine is an arm ? (again without any M1 available I can't test ;( )
note: IIRC we also have an arm64.cc file which could be more appropriate for an M1 mac -> Does our cmake detection wrong ?
EDIT: last comment in https://github.com/google/cpu_features/pull/150/files seems useful (CMake 3.21, the arm/aarch64ifelse
swap and the new match(^aarch64)|(arm64)
) -
Could you give us the value of
CMAKE_SYSTEM_PROCESSOR
on your system ?
(by adding anmessage(FATAL_ERROR "value: ${CMAKE_SYSTEM_PROCESSOR}")
should do it) -
Supposing M1 should compile this arm file then we should search instead which define we must add...
note: for this could you send us the output of your compiler flag, should beclang -dM -E -x c /dev/null
ref1: https://web.archive.org/web/20190803041507/http://nadeausoftware.com/articles/2011/12/c_c_tip_how_list_compiler_predefined_macros
ref2: https://blog.kowalczyk.info/article/j/guide-to-predefined-macros-in-c-compilers-gcc-clang-msvc-etc..html
note: Our current CMake implementation suppose it is also the target platform otherwise you'll need a CMake Toolchain file with CMAKE_SYSTEM_PROCESSOR
https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling
EDIT: To answer your question you don't "set an environment variable that un-sets these flags", actually there are given by your compiler x platform x OS and you do your best as the developer to deal with it. So to summary since we still don't have an M1 to test/adapt the source code and the CMake build, the current support is on a best effort basis with the help of the community.