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

Fix MSVC build by defining _USE_MATH_DEFINES earlier. #2576

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

ScottTodd
Copy link
Contributor

@ScottTodd ScottTodd commented Oct 3, 2024

The fix in #2254 is not sufficient because the first file that includes <cmath> is what determines which macros are defined.

Downstream Windows builds broke at some point due to this: https://github.com/iree-org/iree/actions/runs/11159458848/job/31017884277#step:7:6258

[5387/8614] Building CXX object llvm-external-projects\stablehlo\stablehlo\transforms\CMakeFiles\obj.StablehloPasses.dir\ChloLegalizeToStablehlo.cpp.obj
FAILED: llvm-external-projects/stablehlo/stablehlo/transforms/CMakeFiles/obj.StablehloPasses.dir/ChloLegalizeToStablehlo.cpp.obj 
C:\ProgramData\Chocolatey\bin\ccache C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1441~1.341\bin\Hostx64\x64\cl.exe  /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -ID:\a\iree\iree\third_party\llvm-project\llvm\include -ID:\a\iree\iree\build-windows\llvm-project\include -ID:\a\iree\iree\third_party\llvm-project\mlir\include -ID:\a\iree\iree\third_party\stablehlo -ID:\a\iree\iree\build-windows\llvm-external-projects\stablehlo -ID:\a\iree\iree\third_party\llvm-project\lld\include -ID:\a\iree\iree\build-windows\llvm-project\tools\lld\include -external:I\..\mlir\include -external:ID:\a\iree\iree\build-windows\llvm-project\tools\mlir\include -external:W0 /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /Z7 /O2 /Ob1  -std:c++17 -MD  /EHs-c- /GR- /showIncludes /Follvm-external-projects\stablehlo\stablehlo\transforms\CMakeFiles\obj.StablehloPasses.dir\ChloLegalizeToStablehlo.cpp.obj /Fdllvm-external-projects\stablehlo\stablehlo\transforms\CMakeFiles\obj.StablehloPasses.dir\ /FS -c D:\a\iree\iree\third_party\stablehlo\stablehlo\transforms\ChloLegalizeToStablehlo.cpp
D:\a\iree\iree\third_party\stablehlo\stablehlo\transforms\ChloLegalizeToStablehlo.cpp(1324): error C2065: 'M_PI': undeclared identifier
D:\a\iree\iree\third_party\stablehlo\stablehlo\transforms\ChloLegalizeToStablehlo.cpp(1324): error C2660: 'mlir::stablehlo::getConstantLike': function does not take 3 arguments
D:\a\iree\iree\third_party\stablehlo\stablehlo/transforms/PassUtils.h(51): note: see declaration of 'mlir::stablehlo::getConstantLike'

ScottTodd added a commit to iree-org/iree that referenced this pull request Oct 3, 2024
Upstream PR: openxla/stablehlo#2576.
Cherry-picked onto our fork at
https://github.com/iree-org/stablehlo/tree/integrates/2024-10-03 for
now.

This fixes the build failures caught by our nightly Windows CI:
https://github.com/iree-org/iree/actions/runs/11159458848/job/31017884277#step:7:6257
```
[5387/8614] Building CXX object llvm-external-projects\stablehlo\stablehlo\transforms\CMakeFiles\obj.StablehloPasses.dir\ChloLegalizeToStablehlo.cpp.obj
FAILED: llvm-external-projects/stablehlo/stablehlo/transforms/CMakeFiles/obj.StablehloPasses.dir/ChloLegalizeToStablehlo.cpp.obj 
C:\ProgramData\Chocolatey\bin\ccache C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1441~1.341\bin\Hostx64\x64\cl.exe  /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -ID:\a\iree\iree\third_party\llvm-project\llvm\include -ID:\a\iree\iree\build-windows\llvm-project\include -ID:\a\iree\iree\third_party\llvm-project\mlir\include -ID:\a\iree\iree\third_party\stablehlo -ID:\a\iree\iree\build-windows\llvm-external-projects\stablehlo -ID:\a\iree\iree\third_party\llvm-project\lld\include -ID:\a\iree\iree\build-windows\llvm-project\tools\lld\include -external:I\..\mlir\include -external:ID:\a\iree\iree\build-windows\llvm-project\tools\mlir\include -external:W0 /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /Z7 /O2 /Ob1  -std:c++17 -MD  /EHs-c- /GR- /showIncludes /Follvm-external-projects\stablehlo\stablehlo\transforms\CMakeFiles\obj.StablehloPasses.dir\ChloLegalizeToStablehlo.cpp.obj /Fdllvm-external-projects\stablehlo\stablehlo\transforms\CMakeFiles\obj.StablehloPasses.dir\ /FS -c D:\a\iree\iree\third_party\stablehlo\stablehlo\transforms\ChloLegalizeToStablehlo.cpp
D:\a\iree\iree\third_party\stablehlo\stablehlo\transforms\ChloLegalizeToStablehlo.cpp(1324): error C2065: 'M_PI': undeclared identifier
D:\a\iree\iree\third_party\stablehlo\stablehlo\transforms\ChloLegalizeToStablehlo.cpp(1324): error C2660: 'mlir::stablehlo::getConstantLike': function does not take 3 arguments
D:\a\iree\iree\third_party\stablehlo\stablehlo/transforms/PassUtils.h(51): note: see declaration of 'mlir::stablehlo::getConstantLike'
```
@bjacob
Copy link
Contributor

bjacob commented Oct 3, 2024

@GleasonK , if you could also review and merge this, that would allow me to perform a clean integrate of stablehlo into IREE.

@GleasonK GleasonK merged commit d40285e into openxla:main Oct 3, 2024
10 checks passed
bjacob added a commit to iree-org/iree that referenced this pull request Oct 3, 2024
No cherry-picks anymore, our PRs are in:
openxla/stablehlo#2576
openxla/stablehlo#2575
openxla/stablehlo#2572

Signed-off-by: Benoit Jacob <jacob.benoit.1@gmail.com>
@ScottTodd ScottTodd deleted the msvc-fix branch October 3, 2024 22:15
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.

3 participants