Fixes for building onnx-mlir on Windows with Visual Studio 2022#3253
Open
Fixes for building onnx-mlir on Windows with Visual Studio 2022#3253
Conversation
647edc7 to
db2c7aa
Compare
Collaborator
|
Can one of the admins verify this patch? |
Member
|
@jenkins-droid test this please |
AlexandreEichenberger
approved these changes
Aug 7, 2025
Collaborator
AlexandreEichenberger
left a comment
There was a problem hiding this comment.
LGTM, thanks for fixing the Windows build.
Is this a one-off attempt, or are you looking to maintain Windows support?
Author
I'm still getting my bearings in the Onnx and MLIR space, so it's a one-off attempt at the minute. |
Signed-off-by: Mark Schofield <mschofie@microsoft.com>
Signed-off-by: Mark Schofield <mschofie@microsoft.com>
Signed-off-by: Mark Schofield <mschofie@microsoft.com>
Signed-off-by: Mark Schofield <mschofie@microsoft.com>
8640c5d to
b127c21
Compare
Collaborator
|
Can one of the admins verify this patch? |
Author
|
@jenkins-droid test this please |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Whilst trying out onnx-mlir I hit a few problems getting things compiling on Windows. This PR contains some of the changes I needed to make to get onnx-mlir working correctly - I'm still working through the (I think) last issue. I'm sending these changes in a single PR to show the scope of the changes - I'm happy to break individual commits out and submit them separately if that's preferred. The commits are:
Add 'ONNX_MLIR_ENABLE_OMP' to allow explicit opt-out of OpenMP support - I followed the instructions for building on Windows - which opt-out of openmp support for LLVM - yet my build has the 'omp' target declared. The comment in
src/Runtime/omp/CMakeLists.txtsuggests that that shouldn't be the case, but my build ends-up building the 'OMomp' project, which doesn't work on Windows. I've added aONNX_MLIR_ENABLE_OMPoption to explicitly opt-out. I updated the Windows documentation and.cmdfile to opt-out of OpenMP support.Define M_PI if it isn't already defined -
src/Conversion/ONNXToKrnl/Math/Window.cppassumes thatM_PIis defined. It's not a C or C++ standard define. On Windows you can get the compiler to define it by setting the pre-processor define_USE_MATH_DEFINES, but adding one non-standard definition to get another non-standard definition seems a bit awkward, so I just added a protected definition ofM_PI.Don't rely on implicit std::filesystem::path --> std::string conversion -
std::filesystem::pathhas implicit conversion tostd::filesystem::path::string_type, wherestring_typeis the string type that is native to the character set of the file-system. On (most?) non-Windows platforms, that would bestd::string, but on Windows that'sstd::wstring. Rather than relying on implicit conversion, call.string().Suppress warning 4927 around the consumption of ONNXConstProp.inc - MSVC warns:
And since warnings are treated as errors, this breaks the build. Since the warning is in the generated code, the tightest scope I can suppress at is around the
#includeof the generated code, and that's what this commit does.