iree-org / iree

A retargetable MLIR-based machine learning compiler and runtime toolkit.
http://iree.dev/
Apache License 2.0
2.85k stars 614 forks source link

samples/custom_dispatch/cuda/kernels/cuda_ukernel_ukernel.cu.bc fails to build on Windows #17933

Open ScottTodd opened 4 months ago

ScottTodd commented 4 months ago

What happened?

I hit an error building https://github.com/iree-org/iree/blob/main/samples/custom_dispatch/cuda/kernels/CMakeLists.txt on my Windows machine after a recent update to our LLVM submodule.

Steps to reproduce your issue

  1. Build the all CMake target with -DIREE_BUILD_SAMPLES=ON set
  2. Observe error:
    [build] [6785/7145  94% :: 1152.192] Compiling ukernel.cu to cuda_ukernel_ukernel.cu.bc
    [build] FAILED: samples/custom_dispatch/cuda/kernels/cuda_ukernel_ukernel.cu.bc D:/dev/projects/iree-build/samples/custom_dispatch/cuda/kernels/cuda_ukernel_ukernel.cu.bc 
    [build] cmd.exe /C "cd /D D:\dev\projects\iree-build\samples\custom_dispatch\cuda\kernels && D:\dev\projects\iree-build\llvm-project\bin\clang.exe -x cuda --cuda-gpu-arch=sm_60 "--cuda-path=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2" -Wno-unknown-cuda-version -nocudalib --cuda-device-only -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH -O3 -c -emit-llvm D:/dev/projects/iree/samples/custom_dispatch/cuda/kernels/ukernel.cu -o cuda_ukernel_ukernel.cu.bc"
    [build] In file included from <built-in>:1:
    [build] In file included from D:\dev\projects\iree-build\llvm-project\lib\clang\19\include\__clang_cuda_runtime_wrapper.h:472:
    [build] In file included from D:\dev\projects\iree-build\llvm-project\lib\clang\19\include\__clang_cuda_cmath.h:16:
    [build] In file included from C:\Program Files (x86)\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.31.31103\include\limits:13:
    [build] In file included from C:\Program Files (x86)\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.31.31103\include\cwchar:12:
    [build] In file included from C:\Program Files (x86)\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.31.31103\include\cstdio:12:
    [build] In file included from C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\stdio.h:13:
    [build] C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\corecrt_wstdio.h:486:24: error: non-const lvalue reference to type '__builtin_va_list' cannot bind to a value of unrelated type 'va_list' (aka 'char *')
    [build]   486 |         __crt_va_start(_ArgList, _Locale);
    [build]       |                        ^~~~~~~~
    [build] D:\dev\projects\iree-build\llvm-project\lib\clang\19\include\vadefs.h:39:54: note: expanded from macro '__crt_va_start'
    [build]    39 | #define __crt_va_start(ap, param) __builtin_va_start(ap, param)
    [build]       |                                                      ^~
  3. Full logs: https://gist.github.com/ScottTodd/40aa39fa343665108f742c2e5271d011

What component(s) does this issue relate to?

No response

Version information

First observed at https://github.com/iree-org/iree/commit/30e2c203ca2c4368a6812eeec41e95b43c777c34 . This does not occur at the prior commit (https://github.com/iree-org/iree/commit/3dffadbc0b8a37ab170a61eddb3131c8cbd8c2b2)

Additional context

No response

benvanik commented 4 months ago

I suspect because it's using the MSVC CRT - we probably need to force it to use compiler-rt as built with our clang build.

ScottTodd commented 4 months ago

I looked a bit for culprit commits but there are 400 LLVM commits in the range and a search through relevant directories didn't show anything obvious. Leaning towards disabling the sample on Windows for now to keep local builds more stable.

ScottTodd commented 4 months ago

Possibly https://github.com/llvm/llvm-project/commit/dad7442aff5c85ff9141b0d0f231bcd731cbadc6 (if we use compiler-rt here)

benvanik commented 4 months ago

seems likely - unfortunate but not unexpected that things would break (in that, I don't know if an issue was filed if it'd get fixed). getting on compiler-rt for sample artifacts would insulate us from issues like this.

benvanik commented 4 months ago

-isystem ${IREE_CLANG_BUILTIN_HEADERS_PATH} is what we use in the samples/custom_dispatch/cpu/embedded/ and iree_bitcode_library and may be enough.