Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clangd complains for Unknown argument: '-arch arm64' [drv_unknown_argument] #2858

Closed
vcargats opened this issue May 27, 2023 · 3 comments · Fixed by nodejs/gyp-next#223
Closed
Labels

Comments

@vcargats
Copy link

vcargats commented May 27, 2023

Running this to create compile_commands.json:

node-gyp -- configure -f=gyp.generator.compile_commands_json.py

clangd complains for Unknown argument: '-arch arm64' [drv_unknown_argument]

The reason is that this c flag: "-arch arm64" is quoted in the generated compile_commands.json (as specified in common.py as it contains space). Clang compiler expects two separate argvs elements, not just single element quoted.
The possible solution to this is not to apply gyp.common.EncodePOSIXShellList function for c/cc flags in gyp/pylib/gyp/generator/compile_commands_json.py. I guess that should be fine, do we ever need to quote/escape compiler flags?

  • Node Version: v20.0.0
  • Platform: Darwin THEUSER-M-FHVK 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000 arm64
  • Compiler:
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
  • Module: node-gyp -- configure -f=gyp.generator.compile_commands_json.py
Verbose output (from npm or node-gyp):
THEUSER-M-FHVK:node-binding theuser$ node-gyp -- configure -f=gyp.generator.compile_commands_json.py
gyp info it worked if it ends with ok
gyp info using node-gyp@9.3.1
gyp info using node@20.2.0 | darwin | arm64
gyp info find Python using Python version 3.11.3 found at "/opt/homebrew/opt/python@3.11/bin/python3.11"
gyp http GET https://nodejs.org/download/release/v20.2.0/node-v20.2.0-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v20.2.0/node-v20.2.0-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v20.2.0/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v20.2.0/SHASUMS256.txt
gyp info spawn /opt/homebrew/opt/python@3.11/bin/python3.11
gyp info spawn args [
gyp info spawn args   '/opt/homebrew/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f=gyp.generator.compile_commands_json.py',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/theuser/Documents/node-binding/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/opt/homebrew/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/theuser/Library/Caches/node-gyp/20.2.0/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/theuser/Library/Caches/node-gyp/20.2.0',
gyp info spawn args   '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/theuser/Library/Caches/node-gyp/20.2.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/theuser/Documents/node-binding',
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 ok

This is the file generated:

THEUSER-M-FHVK:node-binding theuser$ cat Release/compile_commands.json
[
{
"command": "c++ \"-DNODE_GYP_MODULE_NAME=greet\" \"-DUSING_UV_SHARED=1\" \"-DUSING_V8_SHARED=1\" \"-DV8_DEPRECATION_WARNINGS=1\" -DV8_DEPRECATION_WARNINGS -DV8_IMMINENT_DEPRECATION_WARNINGS \"-D_GLIBCXX_USE_CXX11_ABI=1\" \"-D_DARWIN_USE_64_BIT_INODE=1\" -D_LARGEFILE_SOURCE \"-D_FILE_OFFSET_BITS=64\" -DNAPI_DISABLE_CPP_EXCEPTIONS -DBUILDING_NODE_EXTENSION -I/Users/theuser/Library/Caches/node-gyp/20.2.0/include/node -I/Users/theuser/Library/Caches/node-gyp/20.2.0/src -I/Users/theuser/Library/Caches/node-gyp/20.2.0/deps/openssl/config -I/Users/theuser/Library/Caches/node-gyp/20.2.0/deps/openssl/openssl/include -I/Users/theuser/Library/Caches/node-gyp/20.2.0/deps/uv/include -I/Users/theuser/Library/Caches/node-gyp/20.2.0/deps/zlib -I/Users/theuser/Library/Caches/node-gyp/20.2.0/deps/v8/include -I/Users/theuser/Documents/node-binding/node_modules/node-addon-api -O3 -gdwarf-2 -flto \"-mmacosx-version-min=10.15\" \"-arch arm64\" -Wall -Wendif-labels -W -Wno-unused-parameter \"-std=gnu++17\" \"-stdlib=libc++\" -fno-rtti -fno-exceptions -fno-strict-aliasing -c /Users/theuser/Documents/node-binding/src/fb.cpp",
"directory": ".",
"file": "/Users/theuser/Documents/node-binding/src/fb.cpp"
},
{
"command": "c++ \"-DNODE_GYP_MODULE_NAME=greet\" \"-DUSING_UV_SHARED=1\" \"-DUSING_V8_SHARED=1\" \"-DV8_DEPRECATION_WARNINGS=1\" -DV8_DEPRECATION_WARNINGS -DV8_IMMINENT_DEPRECATION_WARNINGS \"-D_GLIBCXX_USE_CXX11_ABI=1\" \"-D_DARWIN_USE_64_BIT_INODE=1\" -D_LARGEFILE_SOURCE \"-D_FILE_OFFSET_BITS=64\" -DNAPI_DISABLE_CPP_EXCEPTIONS -DBUILDING_NODE_EXTENSION -I/Users/theuser/Library/Caches/node-gyp/20.2.0/include/node -I/Users/theuser/Library/Caches/node-gyp/20.2.0/src -I/Users/theuser/Library/Caches/node-gyp/20.2.0/deps/openssl/config -I/Users/theuser/Library/Caches/node-gyp/20.2.0/deps/openssl/openssl/include -I/Users/theuser/Library/Caches/node-gyp/20.2.0/deps/uv/include -I/Users/theuser/Library/Caches/node-gyp/20.2.0/deps/zlib -I/Users/theuser/Library/Caches/node-gyp/20.2.0/deps/v8/include -I/Users/theuser/Documents/node-binding/node_modules/node-addon-api -O3 -gdwarf-2 -flto \"-mmacosx-version-min=10.15\" \"-arch arm64\" -Wall -Wendif-labels -W -Wno-unused-parameter \"-std=gnu++17\" \"-stdlib=libc++\" -fno-rtti -fno-exceptions -fno-strict-aliasing -c /Users/theuser/Documents/node-binding/src/index.cpp",
"directory": ".",
"file": "/Users/theuser/Documents/node-binding/src/index.cpp"
}
]
@cclauss cclauss added the Arm label May 27, 2023
@XadillaX
Copy link
Contributor

I met the same error too.

@mohd-akram
Copy link

It seems this was added to node-gyp in #3039. Hope we can get a new release soon.

@cclauss
Copy link
Contributor

cclauss commented Jun 21, 2024

Should this be minus-minus-arch?

- -arch arm64
+ --arch arm64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants