-
Notifications
You must be signed in to change notification settings - Fork 132
fix(c): Generate versioned DLLs and import LIBs when building with MSVC #2858
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
base: main
Are you sure you want to change the base?
Conversation
Thanks for figuring this out. Overall this looks reasonable. If you don't mind I can attempt to push a Windows pipeline to this PR so we can test it. |
c/cmake_modules/version.rc.in
Outdated
FILEFLAGS 0x0L | ||
FILEOS VOS__WINDOWS32 | ||
FILETYPE VFT_DLL | ||
FILESUBTYPE VFT2_UNKNOWN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to specify this with VFT_DLL
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the main file type value that makes sense for the produced files (DLLs). The rest are unrelated to the DLL file type
Co-authored-by: Sutou Kouhei <[email protected]>
Co-authored-by: Sutou Kouhei <[email protected]>
Yes please @lidavidm that would be helpful. |
Got it - I'll try to get to it soon |
pre-commit issues addressed |
Hmm not sure why the pre-commit is still failing. Is it because I've run mine on a Windows machine so it's not capturing everything the CI does (which runs on Ubuntu from the looks of it)? 🤔 |
How are you running it? |
Using this command: |
I don't see a problem. I guess it could be Windows. |
It looks like tests might not fully build:
I'm OK disabling tests for time time being if we can just get DLLs to build properly (we could perhaps just verify that DLLs and implibs exist) |
Also I see |
Oh wait - is the |
Yeah that's needed to generate the DEF file, which is then used to create the lib import
Hmm interesting, I didn't encounter this. Suggests the DEF/Lib is not getting generated?
Unfortunately the DLL by itself is not sufficient, as on Windows the LIB import file is needed in order to link at build time. So without the LIB file the test projects don't build. |
Yeah, I ask because it seems the
|
I'm guessing it just doesn't know where to look; either that or the steps aren't getting sequenced right |
Are the 2 required msys64 tools (gendef and dlltool) installed? Is this warning getting generated?
|
I don't see that in the log: https://github.com/apache/arrow-adbc/actions/runs/15340229681/job/43164905567?pr=2858 |
The issue is down to the commands in GitHub action not simulating Visual Studio. Pushed these changes to the GitHub flow:
Tested the above from PowerShell locally and works as expected. Let's see if the GitHub action passes now. This is also with tests enabled. |
@@ -63,6 +63,18 @@ if(ADBC_BUILD_TESTS) | |||
adbc_driver_common | |||
adbc_validation | |||
${TEST_LINK_LIBS}) | |||
|
|||
if(ADBC_TEST_LINKAGE STREQUAL "shared") | |||
# The go build is not copying the DLL to the test location, causing the test to fail on Windows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, how is this handled for the C/C++ builds? I wouldn't think CMake copies the DLL over...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems by default cmake copies the dll when it is referenced as a library by another cmake project (the test one in this case). However, because the flightsql and snowflake ones are generated manually via GoUtils, they are not getting copied to the test bin folder.
"${LIBOUT_SHARED}.${ADBC_SO_VERSION}.0.h" | ||
COMMENT "Building Go Shared lib ${GO_LIBNAME}" | ||
COMMAND_EXPAND_LISTS) | ||
if(WIN32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're now fully duplicating the build paths...if Windows doesn't want the version suffix, can it just rename the file afterwards instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes ideally the Windows files don't need the version in the file name, as that makes copying them during build events in Visual Studio difficult. Where is the duplication happening? The main change was to remove ${ADBC_FULL_SO_VERSION}
and ${ADBC_SO_VERSION}
suffixes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build commands are effectively the same, though. If it's just a matter of filename, can we either (1) introduce a variable to hold the filename, or (2) just rename it after build?
Also ping @zeroshade |
I have another concern in that we seem to be installing gmock/gtest, but that should be unrelated to this PR
|
Hi.
This is to address building binaries and LIBs on Windows. The PR is mainly for consideration purposes, as it's my first PR against this repo so not necessarily a complete one. Following are the changes I needed to make:
vcpkg
root is expected so that third party packages (sqlite, postgres etc) can be installed and found via vcpkg.GoUtils.cmake
is not automatically copying the driver DLLs to the location of the test executables, causing the tests for those drivers to fail. Added a post build command to ensure the DLLs are copied.2
to the second variable name.What I haven't done is update the GitHub actions to verify a complete build on a Windows machine as I'm not too familiar with the CI/CD pipeline in this repo.
Hopefully this is a good start to get everything building successfully and Windows.
Closes #2846