Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@ jobs:
ccache -s
make GEN=Ninja nodejs && ccache -s

- name: Verify node.exe delay-load (Windows)
if: ${{ matrix.platform == 'win32' }}
shell: pwsh
working-directory: tools/nodejs_api
run: |
# The prebuilt binary must delay-load node.exe so it resolves its
# Node imports against whichever host process loads it (node.exe or
# e.g. Electron's electron.exe). Fail if node.exe is eagerly linked.
$imports = dumpbin /DEPENDENTS build/lbugjs.node | Out-String
Write-Host $imports
if ($imports -notmatch 'delay load dependencies') {
throw 'lbugjs.node has no delay-load dependencies; node.exe must be delay-loaded (see LadybugDB/ladybug#1708).'
}
if ($imports -notmatch 'node\.exe') {
throw 'node.exe not found in the delay-load dependencies of lbugjs.node.'
}

- name: Install OpenSSL 3 (macOS)
if: ${{ matrix.mac_env }}
run: |
Expand Down
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,22 @@ set_target_properties(lbugjs
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build")
if(APPLE)
target_link_options(lbugjs PRIVATE -undefined dynamic_lookup)
else()
elseif(UNIX)
target_link_options(lbugjs PRIVATE -Wl,--export-dynamic)
endif()
target_link_libraries(lbugjs PRIVATE lbug ${NODEJS_LBUG_LINK_DEPS} ${CMAKE_JS_LIB})
# Windows (MSVC): delay-load node.exe so the same prebuilt binary loads under
# both Node (node.exe) and Electron (electron.exe). This requires
# win_delay_load_hook.cc from cmake-js (added via CMAKE_JS_SRC above), which
# resolves the node.exe imports against the running host process at load time
# (same approach as node-gyp's win_delay_load_hook).
if(MSVC)
if(NOT CMAKE_JS_SRC)
message(WARNING "lbugjs: CMAKE_JS_SRC (win_delay_load_hook.cc) is empty; the Electron delay-load hook will be missing.")
endif()
target_link_libraries(lbugjs PRIVATE delayimp)
target_link_options(lbugjs PRIVATE "/DELAYLOAD:node.exe")
endif()
if(LBUG_NODEJS_EXTRA_LINK_LIBS)
target_link_libraries(lbugjs PRIVATE ${LBUG_NODEJS_EXTRA_LINK_LIBS})
endif()
Expand Down
Loading