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 compile error C3688 #1136

Merged
merged 1 commit into from Jul 26, 2023
Merged

Fix MSVC compile error C3688 #1136

merged 1 commit into from Jul 26, 2023

Conversation

bobqianic
Copy link
Collaborator

@bobqianic bobqianic commented Jul 26, 2023

Instead of simply using add_compile_options(/utf-8) to address the MSVC compile error C3688, a better approach would be to handle it in a way that prevents passing /utf-8 to NVCC.

A proper fix for error C3688 should look something like this:

    if (MSVC)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
        set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /utf-8")
        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8")
        if(NOT WHISPER_NO_AVX2)
            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2")
            set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:AVX2")
            set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX2")
        else()
            if(NOT WHISPER_NO_AVX)
                set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX")
                set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:AVX")
                set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX")
            endif()
        endif()
    else()

Before:

C:\Program Files\CMake\bin>"C:\Program Files\CMake\bin\cmake.exe" --build D:\Temp\Download\whiper_build --config release

用于 .NET Framework 的 Microsoft (R) 生成引擎版本 17.1.0+ae57d105c
版权所有(C) Microsoft Corporation。保留所有权利。

  1>Checking Build System
  Building Custom Rule D:/Temp/Download/whisper.cpp-master/CMakeLists.txt
  Compiling CUDA source file ..\whisper.cpp-master\ggml-cuda.cu...

  D:\Temp\Download\whiper_build>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\bin\nvcc.exe"  --use-local-en
  v -ccbin "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX64\x64" -x cu
  -I"D:\Temp\Download\whisper.cpp-master\." -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\include" -I"C:\
  Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\include"     --keep-dir x64\release  -maxrregcount=0   --machin
  e 64 --compile -cudart static -std=c++14 -Xcompiler="/EHsc -Ob2"   -D_WINDOWS -DNDEBUG -DWHISPER_SHARED -DGGML_SHARED
   -DWHISPER_BUILD -DGGML_BUILD -D_CRT_SECURE_NO_WARNINGS -DGGML_USE_CUBLAS -D"CMAKE_INTDIR=\"Release\"" -Dwhisper_EXPO
  RTS -D_WINDLL -D_MBCS -DWIN32 -D_WINDOWS -DNDEBUG -DWHISPER_SHARED -DGGML_SHARED -DWHISPER_BUILD -DGGML_BUILD -D_CRT_
  SECURE_NO_WARNINGS -DGGML_USE_CUBLAS -D"CMAKE_INTDIR=\"Release\"" -Dwhisper_EXPORTS -Xcompiler "/EHsc /W3 /nologo /O2
   /FS   /MD /GR" -Xcompiler "/Fdwhisper.dir\Release\vc143.pdb" -o whisper.dir\Release\ggml-cuda.obj "D:\Temp\Download\
  whisper.cpp-master\ggml-cuda.cu"
  ggml-cuda.cu
  tmpxft_00006fd4_00000000-7_ggml-cuda.cudafe1.cpp
  ggml.c
  whisper.cpp
D:\Temp\Download\whisper.cpp-master\whisper.cpp(3441,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请
将该文件保存为 Unicode 格式以防止
数据丢失 [D:\Temp\Download\whiper_build\whisper.vcxproj]
D:\Temp\Download\whisper.cpp-master\whisper.cpp(3614,47): error C3688: 文本后缀“銆”无效;未找到文文本运算符或文本运算符 模板“operator """"銆” [D:\
Temp\Download\whiper_build\whisper.vcxproj]
D:\Temp\Download\whisper.cpp-master\whisper.cpp(3614,61): error C3688: 文本后缀“銆”无效;未找到文文本运算符或文本运算符 模板“operator """"銆” [D:\
Temp\Download\whiper_build\whisper.vcxproj]
D:\Temp\Download\whisper.cpp-master\whisper.cpp(3616,25): error C3688: 文本后缀“鈾”无效;未找到文文本运算符或文本运算符 模板“operator """"鈾” [D:\
Temp\Download\whiper_build\whisper.vcxproj]
D:\Temp\Download\whisper.cpp-master\whisper.cpp(3616,39): error C3688: 文本后缀“鈾”无效;未找到文文本运算符或文本运算符 模板“operator """"鈾” [D:\
Temp\Download\whiper_build\whisper.vcxproj]
D:\Temp\Download\whisper.cpp-master\whisper.cpp(3616,53): error C3688: 文本后缀“鈾”无效;未找到文文本运算符或文本运算符 模板“operator """"鈾” [D:\
Temp\Download\whiper_build\whisper.vcxproj]
D:\Temp\Download\whisper.cpp-master\whisper.cpp(3617,1): error C3688: 文本后缀“鈾”无效;未找到文文本运算符或文本运算符模板“operator """"鈾” [D:\T
emp\Download\whiper_build\whisper.vcxproj]

After:

C:\Program Files\CMake\bin>"C:\Program Files\CMake\bin\cmake.exe" --build D:\Temp\Download\whiper_build --config release

用于 .NET Framework 的 Microsoft (R) 生成引擎版本 17.1.0+ae57d105c
版权所有(C) Microsoft Corporation。保留所有权利。

  1>Checking Build System
  Building Custom Rule D:/Temp/Download/whisper.cpp-master/CMakeLists.txt
  ggml.c
  whisper.cpp
    正在创建库 D:/Temp/Download/whiper_build/Release/whisper.lib 和对象 D:/Temp/Download/whiper_build/Release/whisper.exp
  whisper.vcxproj -> D:\Temp\Download\whiper_build\bin\Release\whisper.dll
  Building Custom Rule D:/Temp/Download/whisper.cpp-master/examples/bench/CMakeLists.txt
  bench.cpp
  bench.vcxproj -> D:\Temp\Download\whiper_build\bin\Release\bench.exe
  Building Custom Rule D:/Temp/Download/whisper.cpp-master/examples/CMakeLists.txt
  common.cpp
  common-ggml.cpp
  正在生成代码...
  common.vcxproj -> D:\Temp\Download\whiper_build\examples\Release\common.lib
  Building Custom Rule D:/Temp/Download/whisper.cpp-master/examples/main/CMakeLists.txt
  main.cpp
  main.vcxproj -> D:\Temp\Download\whiper_build\bin\Release\main.exe
  Building Custom Rule D:/Temp/Download/whisper.cpp-master/examples/quantize/CMakeLists.txt
  quantize.cpp
  quantize.vcxproj -> D:\Temp\Download\whiper_build\bin\Release\quantize.exe
  Building Custom Rule D:/Temp/Download/whisper.cpp-master/CMakeLists.txt

Instead of simply using 'add_compile_options(/utf-8)' to address the MSVC compile error C3688, a better approach would be to handle it in a way that prevents passing '/utf-8' to NVCC.
@ggerganov ggerganov merged commit a792c40 into ggerganov:master Jul 26, 2023
34 checks passed
@bobqianic
Copy link
Collaborator Author

#1135

jacobwu-b pushed a commit to jacobwu-b/Transcriptify-by-whisper.cpp that referenced this pull request Oct 24, 2023
Instead of simply using 'add_compile_options(/utf-8)' to address the MSVC compile error C3688, a better approach would be to handle it in a way that prevents passing '/utf-8' to NVCC.
jacobwu-b pushed a commit to jacobwu-b/Transcriptify-by-whisper.cpp that referenced this pull request Oct 24, 2023
Instead of simply using 'add_compile_options(/utf-8)' to address the MSVC compile error C3688, a better approach would be to handle it in a way that prevents passing '/utf-8' to NVCC.
landtanin pushed a commit to landtanin/whisper.cpp that referenced this pull request Dec 16, 2023
Instead of simply using 'add_compile_options(/utf-8)' to address the MSVC compile error C3688, a better approach would be to handle it in a way that prevents passing '/utf-8' to NVCC.
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.

None yet

2 participants