tree-sitter-module icon indicating copy to clipboard operation
tree-sitter-module copied to clipboard

Support for clang/clang++ on Windows?

Open cowboyd opened this issue 1 year ago • 2 comments

I'm trying to compile tree-sitter modules on a Windows 10 box at my work. However, whenever I try to use clang and clang++ for the compilers (those are the C compilers that I could find from the command line that come with Visual Studio 2022). I get the following error:

Warning (treesit): Error encountered when installing language grammar: (treesit-error Command: clang -fPIC -c -I. parser.c Error output: clang: error: unsupported option '-fPIC' for target 'i686-pc-windows-msvc'

Is there a way to support clang when compiling on windows?

cowboyd avatar Dec 23 '23 13:12 cowboyd

There is also the msvc compiler cl.exe which I know even less about, but is also present.

cowboyd avatar Dec 23 '23 13:12 cowboyd

FWIW, I had luck using gcc installed via scoop.

After installing gcc, I started a bash shell via git-bash.exe, cloned this repository, edited the contained build.sh appropriately to use gcc instead of cc (and g++ instead of c++) and executed ./build.sh <language>.

This produced a dist directory with an appropriate-looking .dll in it. I also tried for a number of grammars and it worked in each case (e.g. c, javascript, python, and zig).

Haven't tested whether the .dlls are functional though.


I tried a similar procedure with clang and got the same error:

clang: error: unsupported option '-fPIC' for target 'i686-pc-windows-msvc'

mentioned in the first post.

sogaiu avatar Dec 23 '23 14:12 sogaiu