Windows source build fails with C2001 in xgrammar's tokenizer_info.cc when the system code page is 932

Aperta Adatta ai principianti
#277 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cmake, cpp
Ambito
build-system

Direzione di ricerca

Inizia con le opzioni MSVC in CMakeLists.txt e il file sorgente xgrammar che causa l’errore, 3rdParty/xgrammar/cpp/tokenizer_info.cc, intorno alla riga 226. Riproduci l’errore seguendo i passaggi di compilazione per Windows in installation.md oppure compila quel file con /source-charset:.932; verifica che le opzioni del compilatore UTF-8 proposte consentano di completare la compilazione con una code page di sistema giapponese.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug

With system code page 932 (Japanese locale), the Windows source build stops in xgrammar, so llm_inference cannot be built (blocker).

FAILED: [code=2] CMakeFiles/xgrammarCore.dir/3rdParty/xgrammar/cpp/tokenizer_info.cc.obj
...\3rdParty\xgrammar\cpp\tokenizer_info.cc(226): error C2001: 定数が 2 行目に続いています。 [English: newline in string literal]
...\3rdParty\xgrammar\cpp\tokenizer_info.cc(224): fatal error C1075: '(': 一致するトークンが見つかりませんでした [English: the left token was unmatched at the end of the file]

MSVC reads a source without a BOM in the current user code page. Line 226 holds "▁" (bytes E2 96 81). In code page 932, 81 starts a two-byte character, and the closing quote becomes its second byte.

Steps/Code to reproduce bug

On such a system, follow the Windows section of installation.md at main. With -- -k 0, no other file fails.

Another machine should show the same error with /source-charset:.932 on this file. On this PC, .932, .936, .949 and .950 fail, and .1252 and /utf-8 pass.

Build configuration:

python kernelSrcs\build_cutedsl.py --kernels ALL --gpu_arch sm_120 --cuda-version 13.5 --jobs 3 --clean
cmake -S . -B b_nopatch -G Ninja -DCMAKE_BUILD_TYPE=Release -DTRT_PACKAGE_DIR=C:/path/to/TensorRT-RTX-1.7.1.116 -DCUDA_CTK_VERSION=13.5 -DCMAKE_CUDA_ARCHITECTURES=120 -DENABLE_CUTE_DSL=ALL -DCUTE_DSL_ARTIFACT_TAG=sm_120
cmake --build b_nopatch --parallel 3

Runtime command used:
None.

Expected behavior

The build passes on any system code page.

These lines in if(MSVC) in CMakeLists.txt do that here: in a new build folder, all 391 steps pass, C4819 warnings go from 11,771 to 0, and llm_inference runs Qwen/Qwen3-0.6B.

+  # Read BOM-less UTF-8 sources as UTF-8, not in the system code page.
+  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/utf-8>)
+  add_compile_options($<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/utf-8>)

May I open a PR with this change?

System information (Edge Device)

  • Platform: Windows x64 laptop
  • Software release: Windows 11 Home 25H2, build 26200.9711
  • CPU architecture: x86_64
  • GPU compute capability: SM120 (RTX 5080 Laptop GPU)
  • Total device memory: 31.5 GB RAM, 16 GB GPU
  • Build type: Release
  • Library versions:
    • TensorRT Edge-LLM version or commit hash: 4022297f
    • CUDA: 13.5.37
    • TensorRT: TensorRT for RTX 1.7.1.116
    • C++ compiler: MSVC 19.44.35229.0
  • CMake options used: as above, no toolchain file or embedded target
  • Any other details that may help: chcp 65001 before the compile gives the same error.
Lingua principale
Python
Stelle
613
Fork
146
Merge medio
2g 19h
PR unite (30g)
7

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NVIDIA/TensorRT-Edge-LLM

Tutte le issue di NVIDIA/TensorRT-Edge-LLM

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.