Error running node-gyp for build on windows using Github Actions
- Node Version: 18
- Platform: Windows 10
- Compiler: msbuild
- Module: Custom module
Hello I'm trying to build a custom native module on windows. I can get my build to run on mac m1 and x64 using the same binding.gyp file (I have that config below). But on windows it is failing with the error shown.
52s
Run npm run build:node
> @archwayhq/keyring-go@[1](https://github.com/archway-network/keyring-go/actions/runs/4365823351/jobs/7634981598#step:9:1).0.0 build:node
> node-gyp configure build
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 3.10.10 found at "C:\hostedtoolcache\windows\Python\3.10.10\x64\python3.exe"
gyp http GET https://nodejs.org/download/release/v18.14.2/node-v18.14.2-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v18.14.2/node-v18.14.2-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v18.14.2/SHASUMS256.txt
gyp http GET https://nodejs.org/download/release/v18.14.2/win-x86/node.lib
gyp http GET https://nodejs.org/download/release/v18.14.2/win-x64/node.lib
gyp http GET https://nodejs.org/download/release/v18.14.2/win-arm64/node.lib
gyp http 200 https://nodejs.org/download/release/v18.14.2/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v18.14.2/win-x64/node.lib
gyp http 200 https://nodejs.org/download/release/v18.14.2/win-x86/node.lib
gyp http 404 https://nodejs.org/download/release/v18.14.2/win-arm64/node.lib
gyp info find VS using VS2022 (17.5.33414.496) found at:
gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:\hostedtoolcache\windows\Python\3.10.10\x64\python3.exe
gyp info spawn args [
gyp info spawn args 'D:\\a\\keyring-go\\keyring-go\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-I',
gyp info spawn args 'D:\\a\\keyring-go\\keyring-go\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'D:\\a\\keyring-go\\keyring-go\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\runneradmin\\AppData\\Local\\node-gyp\\Cache\\18.14.2\\include\\node\\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\\Users\\runneradmin\\AppData\\Local\\node-gyp\\Cache\\18.14.2',
gyp info spawn args '-Dnode_gyp_dir=D:\\a\\keyring-go\\keyring-go\\node_modules\\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\\\\Users\\\\runneradmin\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\18.14.2\\\\<(target_arch)\\\\node.lib',
gyp info spawn args '-Dmodule_root_dir=D:\\a\\keyring-go\\keyring-go',
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 'D:\\a\\keyring-go\\keyring-go\\build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
nothing.c
win_delay_load_hook.cc
nothing.vcxproj -> D:\a\keyring-go\keyring-go\build\Release\\nothing.lib
keyring.cc
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\ccomplex(22,52): warning C4996: '_Header_ccomplex': warning STL4004: <ccomplex>, <cstdalign>, <cstdbool>, and <ctgmath> are deprecated in C++17. You can define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this warning. [D:\a\keyring-go\keyring-go\build\keyring-go.vcxproj]
D:\a\keyring-go\keyring-go\build\cgo-gcc-export-header-prolog(20,30): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [D:\a\keyring-go\keyring-go\build\keyring-go.vcxproj]
D:\a\keyring-go\keyring-go\build\cgo-gcc-export-header-prolog(20,19): error C2146: syntax error: missing ';' before identifier 'GoComplex64' [D:\a\keyring-go\keyring-go\build\keyring-go.vcxproj]
D:\a\keyring-go\keyring-go\build\cgo-gcc-export-header-prolog(21,31): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [D:\a\keyring-go\keyring-go\build\keyring-go.vcxproj]
D:\a\keyring-go\keyring-go\build\cgo-gcc-export-header-prolog(21,19): error C2146: syntax error: missing ';' before identifier 'GoComplex[12](https://github.com/archway-network/keyring-go/actions/runs/4365823351/jobs/7634981598#step:9:13)8' [D:\a\keyring-go\keyring-go\build\keyring-go.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (D:\a\keyring-go\keyring-go\node_modules\node-gyp\lib\build.js:203:23)
gyp ERR! stack at ChildProcess.emit (node:events:5[13](https://github.com/archway-network/keyring-go/actions/runs/4365823351/jobs/7634981598#step:9:14):28)
gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Windows_NT 10.0.20348
gyp ERR! command "C:\\hostedtoolcache\\windows\\node\\18.[14](https://github.com/archway-network/keyring-go/actions/runs/4365823351/jobs/7634981598#step:9:15).2\\x64\\node.exe" "D:\\a\\keyring-go\\keyring-go\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "build"
gyp ERR! cwd D:\a\keyring-go\keyring-go
gyp ERR! node -v v[18](https://github.com/archway-network/keyring-go/actions/runs/4365823351/jobs/7634981598#step:9:19).14.2
gyp ERR! node-gyp -v v9.3.1
gyp ERR! not ok
Error: Process completed with exit code 1.
This is happening inside of a Github Action Workflow run. I've installed the compiler using msys2/setup-msys2@v2, which installs mingw64 as the default compiler. I've included both the gyp and yml file below.
// gyp file
{
'targets': [
{
'target_name': 'keyring-go',
'sources': [ 'src/keyring.cc' ],
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"],
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],
'cflags!': [ '-fno-exceptions' ],
'cflags_cc!': [ '-fno-exceptions' ],
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '12'
},
'msvs_settings': {
'VCCLCompilerTool': {
'ExceptionHandling': 1,
'RuntimeLibrary': 2
},
},
"libraries": [
"<!(pwd)/keyring.so"
]
}
]
}
// yml file
name: test-keyring-win-x64
on: [push]
jobs:
build-native-node-module-on-win:
runs-on: windows-latest
environment: dev
steps:
- uses: actions/checkout@v3
- uses: msys2/setup-msys2@v2
- uses: actions/setup-node@v3
with:
node-version: '18'
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: actions/setup-go@v3
with:
go-version: '1.20.1'
- run: npm install --ignore-scripts
- run: npm run build:go:win
- run: npm run build:node
- run: npm run test:file
Please examine line 20 of D:\a\keyring-go\keyring-go\build\cgo-gcc-export-header-prolog ?
If you can not figure it out, please consider pasting that one line here.
D:\a\keyring-go\keyring-go\build\cgo-gcc-export-header-prolog(20,30): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [D:\a\keyring-go\keyring-go\build\keyring-go.vcxproj]
D:\a\keyring-go\keyring-go\build\cgo-gcc-export-header-prolog(20,19): error C2146: syntax error: missing ';' before identifier 'GoComplex64' [D:\a\keyring-go\keyring-go\build\keyring-go.vcxproj]
D:\a\keyring-go\keyring-go\build\cgo-gcc-export-header-prolog(21,31): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [D:\a\keyring-go\keyring-go\build\keyring-go.vcxproj]
D:\a\keyring-go\keyring-go\build\cgo-gcc-export-header-prolog(21,19): error C2146: syntax error: missing ';' before identifier 'GoComplex[12](https://github.com/archway-network/keyring-go/actions/runs/4365823351/jobs/7634981598#step:9:13)8' [D:\a\keyring-go\keyring-go\build\keyring-go.vcxproj]
I can see its using msbuild instead of mingw, but that's fine since mingw seems unsupported by node-gyp anyway. But not sure why these types are not accepted. Is it possible that msbuild does not use C99 by default? How can I try that?
Surprised but I added defines _MSC_VER into the binding.gyp file but that did nothing still getting same errors.
{
'targets': [
{
'target_name': 'keyring-go',
'sources': [ 'src/keyring.cc' ],
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"],
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],
'cflags!': [ '-fno-exceptions' ],
'cflags_cc!': [ '-fno-exceptions' ],
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '12'
},
'msvs_settings': {
'VCCLCompilerTool': {
'ExceptionHandling': 1,
'RuntimeLibrary': 2
},
},
"libraries": [
"<!(pwd)/keyring.so"
],
'conditions': [
['OS=="win"', {
'defines': [
'_MSC_VER=1935',
],
}
]
]
}
]
}
This issue seems no longer relevant as it has been stale for a long time. If there are no objections, I will close this issue next Mon-Tue. In case something similar happens again please open a new issue.