From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Difficulty building tree-sitter grammars [was: Help sought from C++ expert: ....] Date: Thu, 19 Jan 2023 19:53:58 +0200 Message-ID: <83tu0mo1ft.fsf@gnu.org> References: <83y1pyo9hs.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32005"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jan 19 18:54:27 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pIZ7L-00086e-C5 for ged-emacs-devel@m.gmane-mx.org; Thu, 19 Jan 2023 18:54:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pIZ70-0008WT-Ey; Thu, 19 Jan 2023 12:54:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pIZ6y-0008Vx-EG for emacs-devel@gnu.org; Thu, 19 Jan 2023 12:54:04 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pIZ6w-0005oj-JW; Thu, 19 Jan 2023 12:54:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=k6Mj3lZIA1FYmJJVbxjHtSF5YWyGgdjoFX+Z0OBLwn0=; b=HBvRkev77jwT /SowDiiWwvNGWezultPb/XMXhNSRLdR4PH8yISer2kHBVE/gDWI/z0yntqBwbmMGITFWV3wluHzua j7QjoHKScOjCnKv+hGyrLnModCb8i7N7u16uwQ5uGo6eF3h6NOOSzokYVUpbZ8ySzPJ5TzQ6Fj0w6 d1r0SB1YjiQxsJiQyBjEwb2ik7NnZRbXIEy5FVV2y853LOI0JGGY7LG9oZr34IOGQ0PpiqX/MfQT9 qciK0IEFxqDankdL2mKxgLc2Gjn0e0pR7wuvr3zXWtSuNMScmkqZHChGuwedcloOFFDPsnv49Vo/9 qav1ksqnEt8M7Z+5VxLueQ==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pIZ6u-0004PN-TP; Thu, 19 Jan 2023 12:54:01 -0500 In-Reply-To: (message from Alan Mackenzie on Thu, 19 Jan 2023 17:14:43 +0000) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:302556 Archived-At: > Date: Thu, 19 Jan 2023 17:14:43 +0000 > Cc: emacs-devel@gnu.org > From: Alan Mackenzie > > > > Just as a matter of interest, in c++-ts-mode a treesit-query-error gets > > > thrown. > > > I don't see any such error. Maybe this is again your outdated grammar > > library? > > Heh! Maybe you're right. So time to get around to installing one from > github. So I look at the Emacs-29 NEWS for instructions on how to do > this. These instructions are glib and insufficiently helpful. Nothing is ever good enough, eh? > (i) The smallest problem is actually downloading the source of, e.g., > tree-sitter-cpp. github doesn't make it obvious how to download stuff, > and it took me over 10 minutes to find the GUI thing to activate the > download. Then this download was a file.zip. The instructions don't > mention that, on GNU, a package called zip is required to unzip this. > > (ii) The instructions glibly say "To compile such a library, compile the > files "scanner.c" and "parser.c" (sometimes named "scanner.cc" and > "parser.cc") in the "src" subdirectory of the library's source tree > using the C or C++ compiler,...". A Python hacker may well not even > know that the C/C++ compiler is called "gcc", far less that the > necessary command line option -c is needed to compile the two source > files. Personally, this bit didn't present me any great difficulty. > > (iii) The instructions continue with "..., then link these two files > into a shared library named "libtree-sitter-LANG.so, ...". How, > exactly? I've guessed that I can also do this with gcc, and need the > option -o libtree-sitter-cpp.so, but I also need some flags meaning > "link" and "build a .so" and some standard run-time library besides the > two object files. I still haven't worked out what these are. The > Python hacker pictured above will be totally lost here. If you don't know how to do this given what's in NEWS, then I'm sorry, but these instructions are not for you. You will have to wait until someone else (your distro?) produces the grammar library and lets you download and install it like you download and install all the image libraries and the rest of the optional stuff for Emacs. I'm not going to make NEWS a step-by-step tutorial for how to compile a bunch of files into a shared library. That is too much to expect from us. It is NOT our job to teach people how to do that. > (iv) Then we have precise instructions on where to put the newly built > ..so file. This is good! This is the only part that is specific to Emacs, so I deliberately included there all the details, since you are unlikely to find it elsewhere. > This process has so far taken me over an hour, which is too long for > something which should be purely routine. It is likely to take a > typical Emacs user even longer. Typical Emacs users who don't know how to build libraries from sources will need someone else to do the job for them. Exactly like they do with GMP or librsvg or HarfBuzz or any other library that Emacs can link against. Eventually, there's no way around this. > I suggest that these instructions in NEWS should be enhanced with (i) > Tips on downloading stuff from github; (ii) A sample command line for > compiling the C/C++ source files; (iii) A sample command line for > linking these to the needed .so file. Possibly two or three versions of > these would be needed for the different environments Emacs runs in. Sorry, but NO!!