-
Notifications
You must be signed in to change notification settings - Fork 865
Enable and propagate /permissive- on MSVC #2268
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
Enable and propagate /permissive- on MSVC #2268
Conversation
|
Ok, that’s cool I think we need to mention that somewhere, though. Could you add it to the INSTALL.md file in the windows section? BTW that section seems very old - I think most people use VS code now - so are those instructions still valid? |
|
It looks mostly up-to-date, just needs to be I put this right under the steps for Windows: |
|
Thank you for the PR! The other problems are probably related to the visibility of I think it's still a bit unclear whether this is the right approach though.
Have you checked if the symbol |
|
Whoops, I made a mistake. It was actually Dumping the object file, that symbol just didn't exist when I built statically. It did when I built shared libraries, and it was successfully statically linked only under
Given the fact that I had dynamic_pointer_cast fail when it should've succeeded in a similar way to some of those issues, I think the visibility of |
|
I think to let permissive flags is to avoid the problems you have in gtsam. Usually it connected to improper use of const. But here as I understand you try to avoid other problems. I also myself encounter bugs when I compile gtsam on debug on windows. |
|
Yeah, a static library build would be good. It definitely fails on my machine (with Boost disabled) with unresolved symbol errors unless I add
The vector iterator failure is fixed by #2256, and the nonlinear_unstable test failure can definitely be fixed by adding |
|
Here's a GitHub Actions run where I use develop and just build statically, no other changes except to enable CI and a gitignore I accidently committed (look at the debug run): https://github.com/Gold856/gtsam/actions/runs/18263446940 Here's a GitHub Actions run where I do that, but also enable I have no idea why this is the case. I take permissive mode to essentially mean that MSVC can do whatever it wants. All I know is enabling |
|
After we speak on this PR to compile static windows, I tried it myself. In this process I seen the problems that gtsam have that need to be fixed. |
|
I don't really understand what you're saying. Are you disagreeing with adding
You have it reversed, I think. I'm having trouble parsing this sentence. I assume you meant that adding
MSVC is older than the first C++ standard. The reason non-standards compliance is disabled by default is because Microsoft really tries hard to keep things backwards-compatible. If they forced standards compliance on everyone, many codebases would stop compiling until they fixed it to be standards compliant. So Microsoft just leaves standards compliance off by default to not make them do work. Well, until you turn on C++20 or beyond. Then The only reason I note that adding Also, sorry if I come off as argumentative. I just want to be sure we do things the right way :) |
f68c45e to
d4cb1cf
Compare
|
OK, @Gold856 and @talregev and @ProfFan . I love this effort on making our windows life smoother and more compatible :-) I'd love to merge - if this is the right thing to do, but have two requests:
|
d4cb1cf to
b26b982
Compare
|
I am also waiting for @ProfFan respond. I was thinking maybe to export all the symbols in gtsam. I am not sure what the effect will be, but it will not need to deal with export / import dll and all the weird problems include linkage problem that it get gtsam project. Then if we succeeded in this direction, Then it will be sure yes for /permissive-. |
|
I agree we should have the flag, it disables msvc hacks. |
I don't think it's the job of
Could you clarify what you mean by this? Based on some articles I've found, it seems like exporting inline things is fine? Would
I'm assuming this means using dllimport/dllexport when you should've used the other, like how cephes currently incorrectly does dllimport for both shared and static libraries? This can easily be caught by CI by building static as well as shared.
Could you clarify this as well? The closest thing I found was
This is actually more complicated than you might think. It's also related to exporting check_slam_program error``` 13/23 Testing: check_slam_program 13/23 Test: check_slam_program Command: "D:/gtsam/build/bin/check_slam_program.exe" Directory: D:/gtsam/build/gtsam/slam/tests "check_slam_program" start time: Oct 11 04:48 Eastern Daylight Time Output: ---------------------------------------------------------- Not equal: expected: [ 3.26795e-07, -1, 0; 1, 3.26795e-07, 0; 0, 0, 1 ] actual: [ -2.97202e-05, -1, -4.11641e-06; 1, -2.97202e-05, -1.08352e-06; 1.0834e-06, -4.11644e-06, 1 ] D:\gtsam\gtsam\slam\tests\testInitializePose3.cpp:118: Failure: "assert_equal(simple::R1, initial.at(x1), 1e-6)" Not equal: expected: [ -1, 3.4641e-07, 0; -3.4641e-07, -1, 0; 0, 0, 1 ] actual: [ -1, 6.04471e-05, -8.23338e-06; -6.04471e-05, -1, -2.16733e-06; -8.23351e-06, -2.16684e-06, 1 ] D:\gtsam\gtsam\slam\tests\testInitializePose3.cpp:119: Failure: "assert_equal(simple::R2, initial.at(x2), 1e-6)" Not equal: expected: [ 1.96153e-08, 1, 0; -1, 1.96153e-08, 0; 0, 0, 1 ] actual: [ 8.70269e-05, 1, -1.25086e-05; -1, 8.70268e-05, -3.25862e-06; -3.25753e-06, 1.25089e-05, 1 ] D:\gtsam\gtsam\slam\tests\testInitializePose3.cpp:120: Failure: "assert_equal(simple::R3, initial.at(x3), 1e-6)" There were 3 failures Test time = 0.16 sec ---------------------------------------------------------- Test Failed. "check_slam_program" end time: Oct 11 04:48 Eastern Daylight Time "check_slam_program" time elapsed: 00:00:00 ---------------------------------------------------------- ```
So I might've gotten a bit confused here. Most of the Windows issues that show up seem to have already been resolved? But they're not closed either. They look kinda similar, but further analysis suggests to me that only #496 seems to fit the profile of something that would be fixed by this PR (unresolved symbol on
Yeah, I can't say I know how this will impact downstream projects either. But if 4.3 is gonna be a fresh release with breaking changes, I think this can reasonably be noted in the release notes as a heads-up to anyone compiling with MSVC. |
|
I cannot give you an example for each problem it will hide, I can show the ones I encounter when I tried to compile gtsam in static. These problem will be hidden for /permissive- flag. I don't say no to /permissive-, I am concern about that it will hide problems. |
|
Okay, that's fair. I think we should just stick to our current export system, given that exporting all symbols isn't possible and has some issues with the way gtsam is currently built. As for the other issues, they certainly aren't hidden by
Dumping the indicating that this symbol is, in fact, in this object file. It's my understanding that without |
|
The CI ran except for vcpkg, which got killed. Re-running to make sure it's not a systematic OOM error. |
|
Hm, wasn’t there a commit that fixed this by increasing the swap space? I think if I update my branch to be up-to-date with develop, that should pull in that change and fix it. |
|
Oh, this time it passed. But I'll wait to see if you are pulling in that swap change here. Might be good to pull in develop regardless. I'll await word. |
|
please rebase to the latest dev |
Include /permissive- notice and fix up a few other things
b26b982 to
7ab8d4c
Compare
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.
OK, great ! Let's do it :-)
|
Thank you so much! |
Previously in #2256:
I gave it some more thought, and now I do understand why it fails! Well, at least how to fix it. For whatever reason,
/permissive-, which enables standards compliance, fixes this issue. Adding it as a build flag makes the ifdef unnecessary. This also happens to fix some other issues I encountered when attempting to build gtsam statically, namely unresolved symbol errors forSO<2>SO<3>. The lack of this flag may actually be the root cause for several of the open Windows issues.Enabling this flag does have some consequences however. As demonstrated, this flag subtly changes the behavior of the code in potentially unknown and mysterious ways. And all downstream consumers must also compile with
/permissive-(made easier by the fact that I put it in the public compile flags), which could also be relying on MSVC's default/permissivebehavior. However, given that Linux and Mac are already compiling with standards compliance flags, and that some gtsam code is already broken by non-standard behavior in MSVC, I think it's acceptable to enable this flag for gtsam and all downstream consumers.