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

Add a static windows build to CI #4037

Merged
merged 8 commits into from
Feb 21, 2024
Merged

Conversation

eisenhauer
Copy link
Member

No description provided.

@eisenhauer eisenhauer changed the title Try to do a static windows build in CI WIP: Try to do a static windows build in CI Feb 18, 2024
@vicentebolea
Copy link
Collaborator

@vicentebolea
Copy link
Collaborator

I can see something in here: https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md . It appears that the default image ships something called: Microsoft.VisualStudio.Component.VC.TestAdapterForGoogleTest that might be injecting the wrong settings so that we produce a shared lib instead of a static for gtest as it seems that we are doing.

@vicentebolea
Copy link
Collaborator

How about trying to update google test to a newer version, maybe this was resolved later on. BTW I strongly recommend not to use main but tag releases (v1.14.0 Latest)

@eisenhauer
Copy link
Member Author

https://stackoverflow.com/a/7511679/2420872

OK, but this PR forces external GTest to OFF, which seems to result in the desire behavior, which is GTest being build in thirdparty and the use of the same compiler settings as the rest of the project, yes? So I'm not sure how to apply the information above.

I found a number of suggestions about modifying the flags specified in the visual studio project, bug of course this is CMake generating those, nothing that we've specified. We just did -DBUILD_SHARED=OFF. Could this be a cmake problem?

@vicentebolea
Copy link
Collaborator

hmm I think that they key issue is this: https://stackoverflow.com/questions/14714877/mismatch-detected-for-runtimelibrary.

Basically we need to set the same https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html in both gtest and ADIOS2

@vicentebolea
Copy link
Collaborator

Here is the excerpt from the CI of this PR:

2024-02-19T16:36:46.9549109Z   Generating Code...
2024-02-19T16:36:48.4067951Z   adios2_cxx11.vcxproj -> D:\a\ADIOS2\ADIOS2\win2022-vs2022-static-serial\lib\Debug\adios2_cxx11.lib
2024-02-19T16:36:48.4687841Z   Building Custom Rule D:/a/ADIOS2/ADIOS2/source/thirdparty/GTest/googletest/googletest/CMakeLists.txt
2024-02-19T16:36:48.5299357Z   gtest-all.cc
2024-02-19T16:36:50.4028311Z   gtest.vcxproj -> D:\a\ADIOS2\ADIOS2\win2022-vs2022-static-serial\lib\Debug\gtest.lib
2024-02-19T16:36:50.4520778Z   Building Custom Rule D:/a/ADIOS2/ADIOS2/source/testing/adios2/bindings/C/CMakeLists.txt
2024-02-19T16:36:50.5174694Z   TestNullWriteRead.cpp
2024-02-19T16:36:51.8200782Z gtest.lib(gtest-all.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in TestNullWriteRead.obj [D:\a\ADIOS2\ADIOS2\win2022-vs2022-static-serial\Testing\adios2\bindings\C\Test.Bindings.C.NullWriteRead.Serial.vcxproj]
2024-02-19T16:36:51.9833412Z msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: struct _Cvtvec __cdecl std::_Locinfo::_Getcvt(void)const " (?_Getcvt@_Locinfo@std@@QEBA?AU_Cvtvec@@XZ) already defined in gtest.lib(gtest-all.obj) [D:\a\ADIOS2\ADIOS2\win2022-vs2022-static-serial\Testing\adios2\bindings\C\Test.Bindings.C.NullWriteRead.Serial.vcxproj]
2024-02-19T16:36:52.0060454Z msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: bool __cdecl std::ios_base::good(void)const " (?good@ios_base@std@@QEBA_NXZ) already defined in gtest.lib(gtest-all.obj) [D:\a\ADIOS2\ADIOS2\win2022-vs2022-static-serial\Testing\adios2\bindings\C\Test.Bindings.C.NullWriteRead.Serial.vcxproj]

@eisenhauer
Copy link
Member Author

How about trying to update google test to a newer version, maybe this was resolved later on. BTW I strongly recommend not to use main but tag releases (v1.14.0 Latest)

I considered that too. The fly in the ointment there is that everything past v1.12 requires C++14 (which is more than the rest of ADIOS requires). Not a problem for a quick test, but potentially something to consider. I suppose we could also consider a win2019 static build to see if that was better, or at if it at least let us get to problems in ADIOS.

@eisenhauer
Copy link
Member Author

Here is the excerpt from the CI of this PR:

2024-02-19T16:36:46.9549109Z   Generating Code...
2024-02-19T16:36:48.4067951Z   adios2_cxx11.vcxproj -> D:\a\ADIOS2\ADIOS2\win2022-vs2022-static-serial\lib\Debug\adios2_cxx11.lib
2024-02-19T16:36:48.4687841Z   Building Custom Rule D:/a/ADIOS2/ADIOS2/source/thirdparty/GTest/googletest/googletest/CMakeLists.txt
2024-02-19T16:36:48.5299357Z   gtest-all.cc
2024-02-19T16:36:50.4028311Z   gtest.vcxproj -> D:\a\ADIOS2\ADIOS2\win2022-vs2022-static-serial\lib\Debug\gtest.lib
2024-02-19T16:36:50.4520778Z   Building Custom Rule D:/a/ADIOS2/ADIOS2/source/testing/adios2/bindings/C/CMakeLists.txt
2024-02-19T16:36:50.5174694Z   TestNullWriteRead.cpp
2024-02-19T16:36:51.8200782Z gtest.lib(gtest-all.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in TestNullWriteRead.obj [D:\a\ADIOS2\ADIOS2\win2022-vs2022-static-serial\Testing\adios2\bindings\C\Test.Bindings.C.NullWriteRead.Serial.vcxproj]
2024-02-19T16:36:51.9833412Z msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: struct _Cvtvec __cdecl std::_Locinfo::_Getcvt(void)const " (?_Getcvt@_Locinfo@std@@QEBA?AU_Cvtvec@@XZ) already defined in gtest.lib(gtest-all.obj) [D:\a\ADIOS2\ADIOS2\win2022-vs2022-static-serial\Testing\adios2\bindings\C\Test.Bindings.C.NullWriteRead.Serial.vcxproj]
2024-02-19T16:36:52.0060454Z msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: bool __cdecl std::ios_base::good(void)const " (?good@ios_base@std@@QEBA_NXZ) already defined in gtest.lib(gtest-all.obj) [D:\a\ADIOS2\ADIOS2\win2022-vs2022-static-serial\Testing\adios2\bindings\C\Test.Bindings.C.NullWriteRead.Serial.vcxproj]

Yeah, seeing this is why I tried forcing the use of the internal GTest. Didn't change anything though. Maybe find_package() is still picking up the external version despite us building one.

@vicentebolea
Copy link
Collaborator

Yeah, seeing this is why I tried forcing the use of the internal GTest. Didn't change anything though. Maybe find_package() is still picking up the external version despite us building one.

that is not true, if I check the cmakecache.txt I see this:


//Value Computed by CMake
googletest-distribution_BINARY_DIR:STATIC=D:/a/ADIOS2/ADIOS2/win2022-vs2022-static-serial/thirdparty/GTest/googletest

//Value Computed by CMake
googletest-distribution_IS_TOP_LEVEL:STATIC=OFF

//Value Computed by CMake
googletest-distribution_SOURCE_DIR:STATIC=D:/a/ADIOS2/ADIOS2/source/thirdparty/GTest/googletest

//Value Computed by CMake
gtest_BINARY_DIR:STATIC=D:/a/ADIOS2/ADIOS2/win2022-vs2022-static-serial/thirdparty/GTest/googletest/googletest

//Value Computed by CMake
gtest_IS_TOP_LEVEL:STATIC=OFF

//Value Computed by CMake
gtest_SOURCE_DIR:STATIC=D:/a/ADIOS2/ADIOS2/source/thirdparty/GTest/googletest/googletest

//Build gtest's sample programs.
gtest_build_samples:BOOL=OFF

@vicentebolea
Copy link
Collaborator

hmm we are still having the issue. error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in TestNullWriteRead.ob

For some reason the flag CMAKE_MSVC_RUNTIME_LIBRARY is not being passed down to gtest.

@vicentebolea
Copy link
Collaborator

Now we only have errors with FFS

@eisenhauer
Copy link
Member Author

Well, that's a start. I'll see what I can do from here. Thanks!

@vicentebolea
Copy link
Collaborator

Do you think that the remain errors are due to wrong dllexport directives in FFS?

@eisenhauer
Copy link
Member Author

eisenhauer commented Feb 19, 2024 via email

@vicentebolea
Copy link
Collaborator

vicentebolea commented Feb 19, 2024 via email

@eisenhauer
Copy link
Member Author

Does it make sense to force an export all for windows?

Probably. I've just been stuck at CI until now. I was digging around trying to sort of things like GENERATE_EXPORT_HEADER are still necessary or recommended, but hadn't landed on any obviously correct examples.

@vicentebolea vicentebolea force-pushed the WindowsStatic branch 7 times, most recently from e0e1fbf to 67a56fc Compare February 20, 2024 02:47
@vicentebolea
Copy link
Collaborator

It appears that the issue was with the use of dllexport | import. The latest change seems to have a address it. https://github.com/ornladios/ADIOS2/actions/runs/7967848404/job/21751218798?pr=4037

IT also seems that this affects DILL too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't make direct changes inside thirdparty libraries (at least not without killing our ability to easily update them). You also have this in the dashboard_cache list in ci-win2-22-vs2-22-static-serial.cmake. I assume that wasn't sufficient? Can we do this in a file we own like thirdparty/GTest/CMakeLists.txt?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eisenhauer these are exploratory changes, once we find the right changes we can add them in their respective repos

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eisenhauer these are exploratory changes, once we find the right changes we can add them in their respective repos

Understand of course, and that's my plan for the GTKorvo stuff, but I'm assuming that it's not so trivial for googletest...

@eisenhauer
Copy link
Member Author

Yeah, I knew the dllimport spec was the problem, but the question was how to fix it. It does look like changing to dllexport in source and outside helps. I can extend this to dill, atl and evpath as well (we're not pulling in evpath on Windows yet, but we need to for SST and remote stuff). No Windows CI on those packages, but the ADIOS CI can likely serve as an indirect proxy to try things out. Thanks!

@eisenhauer
Copy link
Member Author

@vicentebolea Just to close the loop for the final status. In general, the declspec(dllimport) was the problem in the static build, but it wasn't necessary to replace them with dllexport. That is all taken care of by CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS. However, the one place we do still need a declspec is in dill where we are exporting not just code symbols, but also data symbols. Data symbols require a declspec(dllimport) to be imported by the VS compiler, but it must only appear in the declaration where the symbol is used (not where it's defined), and only when we are building shared and not static libraries.

@vicentebolea
Copy link
Collaborator

@eisenhauer sounds great, CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS was what we were looking for initially in this thread. CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS is a good compromise for the time being, if in the future we have more people using adios2 static build (probably through pip) we could go the fine grain dllexport/inport not to incur in the size/perf overhead which CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS implies.

@eisenhauer
Copy link
Member Author

The EXPORT_ALL_SYMBOLS was actually already in use in all those GTkorvo projects, we just hadn't killed the declspec defines that were leftover from pre-CMake configuration. That they hadn't been killed both made the static build fail, but also happened to make the dynamic build work for the data symbols that dill needed to export). That messiness was probably why this hadn't been sorted before. In any case, I'm in the process of folding those changes into the upstream GTkorvo repos. When I'm done I'll probably kill this PR and re-submit something with a less complex history... Thanks for your help!

@vicentebolea
Copy link
Collaborator

When I'm done I'll probably kill this PR and re-submit something with a less complex history

Can you keep it in this PR, you can rebase/reset all the commits in a single one. In the future it will be easier to find the reason of this if this is done in a single PR 👼

@eisenhauer
Copy link
Member Author

The awkwardness it that I have to kill all the GTkorvo commits, because they really have to come in via the update script. I suppose I could reset all these commits away, kill the GTkorvo changes, redo them via update, etc. Just not keeping very much, but I guess it does keep the dialogue.

dill Upstream and others added 6 commits February 21, 2024 13:30
Code extracted from:

    https://github.com/GTkorvo/dill.git

at commit 2bd038273c1083cdaddb9a402fff5db8dbb385f4 (master).

Upstream Shortlog
-----------------
# By dill Upstream
* upstream-dill:
  dill 2024-02-21 (2bd03827)
Code extracted from:

    https://github.com/GTkorvo/ffs.git

at commit cc3da1a07d5040a9d76e0fafe89b082ce6121145 (master).

Upstream Shortlog
-----------------
# By ffs Upstream
* upstream-ffs:
  ffs 2024-02-21 (cc3da1a0)
Code extracted from:

    https://github.com/GTkorvo/EVPath.git

at commit 6587d0f0d7a80dbc0afb56ae4aca9250fe366e57 (master).

Upstream Shortlog
-----------------
# By EVPath Upstream
* upstream-EVPath:
  EVPath 2024-02-21 (6587d0f0)
@eisenhauer
Copy link
Member Author

The inability to do a rebase on any PR that has used the update.sh script in a thirdparty package is a nuisance...

@eisenhauer eisenhauer changed the title WIP: Try to do a static windows build in CI Add a static windows build to CI Feb 21, 2024
@vicentebolea
Copy link
Collaborator

vicentebolea commented Feb 21, 2024 via email

@eisenhauer
Copy link
Member Author

I think that the proper way would be to do a reset --soft (soft is the default mode so just git reset)

Well, since rebase often simply doesn't work in that scenario (during the rebase commits to things like ADIOS2/thirdparty/ffs/ffs/CMakeLists.txt get applied to ADIOS2/CMakeLists.txt), you do have to have to do something else...

@eisenhauer
Copy link
Member Author

@vicentebolea I believe that this is ready for review at this point.

Copy link
Collaborator

@vicentebolea vicentebolea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny comment, everything else great! Good job

thirdparty/GTest/CMakeLists.txt Outdated Show resolved Hide resolved
@eisenhauer
Copy link
Member Author

Ok, removed that...

@eisenhauer eisenhauer enabled auto-merge (squash) February 21, 2024 21:25
@eisenhauer eisenhauer merged commit b0b197f into ornladios:master Feb 21, 2024
39 checks passed
@eisenhauer eisenhauer deleted the WindowsStatic branch February 22, 2024 01:15
vicentebolea pushed a commit to vicentebolea/ADIOS2 that referenced this pull request Feb 28, 2024
- Upstream EVpath, FFS and dill.
 - Actually add the CI
Co-authored-by: Vicente Bolea <[email protected]>
This was referenced Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants