nodejs / nodejs/gyp-next

c++ called by gyp on macos don't respect cflags.

Open
#273 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
155
Forks
101
Avg merge
6d 2h
Merged PRs (30d)
4

Description

I have a project which needs pkg-config --cflags rime so I add

            "cflags": [
                "<!@(pkg-config --cflags rime)",
            ],

to binding.gyp

In linux, it work well. make -Cbuild V=1 tell:

  g++ -o Release/obj.target/rime/binding.o ../binding.cc '-DNODE_GYP_MODULE_NAME=rime' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DNAPI_DISABLE_CPP_EXCEPTIONS' '-DNODE_ADDON_API_DISABLE_DEPRECATED' '-DBUILDING_NODE_EXTENSION' -I/home/wzy/.cache/node-gyp/20.18.0/include/node -I/home/wzy/.cache/node-gyp/20.18.0/src -I/home/wzy/.cache/node-gyp/20.18.0/deps/openssl/config -I/home/wzy/.cache/node-gyp/20.18.0/deps/openssl/openssl/include -I/home/wzy/.cache/node-gyp/20.18.0/deps/uv/include -I/home/wzy/.cache/node-gyp/20.18.0/deps/zlib -I/home/wzy/.cache/node-gyp/20.18.0/deps/v8/include -I/home/wzy/Desktop/coc-rime/node_modules/node-addon-api  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -I/nix/store/r4d1aphfpvpfj9g2lw6qsnxz42adfc61-librime-1.12.0/include -m64 -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++17 -MMD -MF ./Release/.deps/Release/obj.target/rime/binding.o.d.raw   -c

where pkg-config --cflags rime is -I/nix/store/r4d1aphfpvpfj9g2lw6qsnxz42adfc61-librime-1.12.0/include.

In macos, pkg-config can search rime, however, make -Cbuild V=1 don't use it.

c++ -o Release/obj.target/rime/binding.o ../binding.cc '-DNODE_GYP_MODULE_NAME=rime' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DNAPI_DISABLE_CPP_EXCEPTIONS' '-DNODE_ADDON_API_DISABLE_DEPRECATED' '-DBUILDING_NODE_EXTENSION' -I/Users/runner/Library/Caches/node-gyp/23.3.0/include/node -I/Users/runner/Library/Caches/node-gyp/23.3.0/src -I/Users/runner/Library/Caches/node-gyp/23.3.0/deps/openssl/config -I/Users/runner/Library/Caches/node-gyp/23.3.0/deps/openssl/openssl/include -I/Users/runner/Library/Caches/node-gyp/23.3.0/deps/uv/include -I/Users/runner/Library/Caches/node-gyp/23.3.0/deps/zlib -I/Users/runner/Library/Caches/node-gyp/23.3.0/deps/v8/include -I/Users/runner/work/coc-rime/coc-rime/node_modules/node-addon-api  -O3 -gdwarf-2 -fno-strict-aliasing -mmacosx-version-min=11.0 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++20 -stdlib=libc++ -fno-rtti -fno-exceptions -MMD -MF ./Release/.deps/Release/obj.target/rime/binding.o.d.raw   -c
../binding.cc:2:10: fatal error: 'rime_api.h' file not found
#include <rime_api.h>
         ^~~~~~~~~~~~
1 error generated.

only add pkg-config --variables includedir rime to include_dirs can make it work.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the macOS build with binding.gyp and make -Cbuild V=1, comparing it with the Linux command output. Trace how gyp handles the cflags command substitution and include_dirs; done means the generated macOS compile command includes the rime include path without requiring a separate include_dirs entry.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.