[vim/vim] Revamp `make proto` (PR #18045)

109 views
Skip to first unread message

h_east

unread,
Aug 18, 2025, 11:59:15 AMAug 18
to vim/vim, Subscribed

Instead of cproto, use clang.cindex from Python to create prototype declaration files (.pro) from source code.

I'm working on Ubuntu 24.04.

$ sudo apt-get update
$ sudo apt-get install -y python3 python3-pip clang libclang-dev python3-clang

You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/18045

Commit Summary

  • c81eed3 Revamp `make proto`
  • 0bef846 Add src/proto/gen_prototypes.py
  • bac2a88 tweak around proto
  • 9e3fedb tweak around proto
  • ed0df52 tweak around proto
  • 7a5188c tweak arounf proto
  • 7806c05 tweak around proto
  • f916ead Make array parameters print as `name[]` (e.g., `char *dirnames[]`) instead of `char *[]name`.
  • ace6c5d - Top-level variadic: when the function type is variadic, change void → `...` or append `, ...`.
  • 141ba6d show libclang diagnostics to stderr for easier troubleshooting, when env GENPROTO_SHOW_DIAGS is true.
  • de34b92 - Respect argument types as defined.

File Changes

(19 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045@github.com>

h_east

unread,
Aug 18, 2025, 12:04:43 PMAug 18
to vim/vim, Subscribed
h-east left a comment (vim/vim#18045)

@chrisbra and Vim members,
What do you think of this approach?
Although make proto depends on python and clang, I think it's better than continuing to use cproto.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3197530099@github.com>

h_east

unread,
Aug 19, 2025, 7:13:00 AMAug 19
to vim/vim, Push

@h-east pushed 11 commits.

  • 3c6de13 Revamp `make proto`
  • e5f6433 Add src/proto/gen_prototypes.py
  • 95cd8e2 tweak around proto
  • 1ce7324 tweak around proto
  • f6010c6 tweak around proto
  • 8d72718 tweak arounf proto
  • 6f1bab1 tweak around proto
  • 20f4a28 Make array parameters print as `name[]` (e.g., `char *dirnames[]`) instead of `char *[]name`.
  • 84ccf02 - Top-level variadic: when the function type is variadic, change void → `...` or append `, ...`.
  • 295acf7 show libclang diagnostics to stderr for easier troubleshooting, when env GENPROTO_SHOW_DIAGS is true.
  • c479d4b - Respect argument types as defined.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/de34b92aa3a61abd1db70416e4b7494c6209b316/after/c479d4bba694a78625e3e7908ccf80dd1c7a6c48@github.com>

h_east

unread,
Aug 19, 2025, 9:37:39 AMAug 19
to vim/vim, Push

@h-east pushed 8 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/c479d4bba694a78625e3e7908ccf80dd1c7a6c48/after/a4dd71be13ef31f194ca44f978860f2e173b00a7@github.com>

h_east

unread,
Aug 19, 2025, 9:47:19 AMAug 19
to vim/vim, Push

@h-east pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/a4dd71be13ef31f194ca44f978860f2e173b00a7/after/20936d007c1bd3130aad93fcf180d0d0ae1e3c5d@github.com>

h_east

unread,
Aug 19, 2025, 10:10:49 AMAug 19
to vim/vim, Push

@h-east pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/20936d007c1bd3130aad93fcf180d0d0ae1e3c5d/after/81487f12397e6b502c9455b76934d83243b278a3@github.com>

Yegappan Lakshmanan

unread,
Aug 19, 2025, 10:43:44 AMAug 19
to vim/vim, Subscribed

@yegappan commented on this pull request.


In src/indent.c:

> @@ -474,7 +474,7 @@ get_indent_str(
     return count;
 }
 
-#ifdef FEAT_VARTABS
+#if defined(FEAT_VARTABS) || defined(PROTO)

One suggestion: it might be easier to track the changes later, if you can separate out the changes related to the "PROTO" checks into one PR and the changes for the new script into another PR.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/review/3132669594@github.com>

h_east

unread,
Aug 19, 2025, 10:56:23 AMAug 19
to vim/vim, Subscribed

@h-east commented on this pull request.


In src/indent.c:

> @@ -474,7 +474,7 @@ get_indent_str(
     return count;
 }
 
-#ifdef FEAT_VARTABS
+#if defined(FEAT_VARTABS) || defined(PROTO)

Around the same time you commented, I submitted a PR implementing your suggestion 👍


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/review/3132720074@github.com>

Yee Cheng Chin

unread,
Aug 19, 2025, 10:04:38 PMAug 19
to vim/vim, Subscribed
ychin left a comment (vim/vim#18045)

Does this work in all platforms? And does it still require us to do all the typedef's in say os_mswin.c (e.g. typedef int BOOL;) or the declarations in struct.h (e.g. typedef long varnumber_T;).

If the answer is no, then I wonder what the point of switching to a separate Python script is?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3203894047@github.com>

h_east

unread,
Aug 19, 2025, 11:57:20 PMAug 19
to vim/vim, Subscribed
h-east left a comment (vim/vim#18045)

The answer is “Yes.” I’m still experimenting, but my goal is to get the same output in any environment where Python and Clang are available. It’s impossible to do this with a truly accurate parser, so I’m switching to an approach that detects “something like a function definition” and then generates its prototype declaration as-is.

If this works, we won’t need the PROTO definitions themselves nor the hacky consistency-forcing code for cproto that you mentioned.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3204098876@github.com>

h_east

unread,
Aug 20, 2025, 11:39:42 AMAug 20
to vim/vim, Push

@h-east pushed 1 commit.

  • 73d9f17 Switching to an approach that detects "something like a function definition" and then generates its prototype declaration as-is.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/81487f12397e6b502c9455b76934d83243b278a3/after/73d9f1749be94b9c6250cf7a005d1f33d4d0ef8c@github.com>

h_east

unread,
Aug 21, 2025, 6:53:18 AMAug 21
to vim/vim, Push

@h-east pushed 9 commits.

  • c0ff97c Revamp `make proto`
  • 4bb8af1 Add src/proto/gen_prototypes.py
  • 104e29b Make array parameters print as `name[]` (e.g., `char *dirnames[]`) instead of `char *[]name`.
  • dbb93ff - Top-level variadic: when the function type is variadic, change void → `...` or append `, ...`.
  • 18239d4 show libclang diagnostics to stderr for easier troubleshooting, when env GENPROTO_SHOW_DIAGS is true.
  • d77ff3d - Respect argument types as defined.
  • 40881fc tweak script around pointer
  • f2ffcf4 fix makefile
  • 3863053 Switching to an approach that detects "something like a function definition" and then generates its prototype declaration as-is.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/73d9f1749be94b9c6250cf7a005d1f33d4d0ef8c/after/38630530242f59ed2edbc50dd2e1041cb54e0089@github.com>

h_east

unread,
Aug 22, 2025, 8:30:48 PMAug 22
to vim/vim, Push

@h-east pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/19d0395a00de13aee2bf6065955678862b10a439/after/82bcde92b0bdc4bb996b6c521f8018b0c2a763fb@github.com>

h_east

unread,
Sep 1, 2025, 8:08:54 AMSep 1
to vim/vim, Push

@h-east pushed 4 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/82bcde92b0bdc4bb996b6c521f8018b0c2a763fb/after/a487a9b50e8b9d6109657cede877d3264e8b13cc@github.com>

h_east

unread,
Sep 5, 2025, 8:42:32 PMSep 5
to vim/vim, Push

@h-east pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/a487a9b50e8b9d6109657cede877d3264e8b13cc/after/d5ebedb083f2de1d469fe610571d2744ba0e091b@github.com>

h_east

unread,
Sep 6, 2025, 3:01:18 PMSep 6
to vim/vim, Push

@h-east pushed 1 commit.

  • d53ac84 support `#ifndef PROTO` and `#if !defined(PROTO)`

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/2d254ff491d2a77a11fab6e7fd19bc91b7acfdb7/after/d53ac84164d85a34ccc07a35832d8686129f2a76@github.com>

h_east

unread,
Sep 14, 2025, 10:43:59 AMSep 14
to vim/vim, Push

@h-east pushed 4 commits.

  • 10fbe91 Revamp `make proto`
  • f23de23 support `#ifndef PROTO` and `#if !defined(PROTO)`
  • b50fac3 update script
  • 8036c66 Removed error workaround code for `cproto`

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/d53ac84164d85a34ccc07a35832d8686129f2a76/after/8036c661b3914f4f578e32b4f2e3c08bc44b15a1@github.com>

h_east

unread,
Sep 14, 2025, 12:02:35 PMSep 14
to vim/vim, Push

@h-east pushed 2 commits.

  • 26c5c85 Removed error workaround code for `cproto`
  • 551bccb update script

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/8036c661b3914f4f578e32b4f2e3c08bc44b15a1/after/551bccb1a7d2fc7f0b09dbbe872a563c61bc8f21@github.com>

h_east

unread,
Sep 14, 2025, 9:44:48 PMSep 14
to vim/vim, Push

@h-east pushed 5 commits.

  • 3855da8 Revamp `make proto`
  • c943355 support `#ifndef PROTO` and `#if !defined(PROTO)`
  • 594f59b Removed error workaround code for `cproto`
  • 50f5aba update script
  • c304bb9 update script

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/551bccb1a7d2fc7f0b09dbbe872a563c61bc8f21/after/c304bb9eccfdd10c26ef63fcb490544be4a14afc@github.com>

h_east

unread,
Sep 15, 2025, 5:31:54 PMSep 15
to vim/vim, Push

@h-east pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/c304bb9eccfdd10c26ef63fcb490544be4a14afc/after/bb596d45dab118ea7ff8f4da569c0c07b3a41ffe@github.com>

h_east

unread,
Sep 20, 2025, 10:27:31 AMSep 20
to vim/vim, Push

@h-east pushed 9 commits.

  • 215e9e9 Revamp `make proto`
  • 76e8e94 support `#ifndef PROTO` and `#if !defined(PROTO)`
  • 0770a36 Removed error workaround code for `cproto`
  • 16f698a update script
  • e2868cd update script
  • 4027a9d Update script
  • cbf8c73 New `make proto` checks the `#if` side by default, so the conditions and contents of `#if` and `#else` are swapped.
  • f9c9d5f The code inside `#ifdef _DEBUG` is excluded.
  • 5d7be04 update

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/bb596d45dab118ea7ff8f4da569c0c07b3a41ffe/after/5d7be04293a26ef54bfb0a023774f3ba78cff524@github.com>

h_east

unread,
Sep 20, 2025, 1:55:07 PMSep 20
to vim/vim, Push

@h-east pushed 6 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/5d7be04293a26ef54bfb0a023774f3ba78cff524/after/3b65ddeda72d879a210e7041caed98dd7a2e4623@github.com>

h_east

unread,
Sep 21, 2025, 12:05:41 AMSep 21
to vim/vim, Push

@h-east pushed 1 commit.

  • 8e4a68b Removed unnecessary `defined(PROTO)`

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/3b65ddeda72d879a210e7041caed98dd7a2e4623/after/8e4a68b7e895596bffaaa266c17a0a07ec88ef44@github.com>

h_east

unread,
Sep 21, 2025, 12:06:29 PMSep 21
to vim/vim, Push

@h-east pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/8e4a68b7e895596bffaaa266c17a0a07ec88ef44/after/9854df83e43906ecfbb5a807ef068413737ffe16@github.com>

h_east

unread,
Sep 22, 2025, 10:22:52 PMSep 22
to vim/vim, Push

@h-east pushed 3 commits.

  • 9e22c43 Revamp `make proto`
  • 166140a Removed error workaround code for `cproto`
  • b7528a1 Removed unnecessary `defined(PROTO)`

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/9854df83e43906ecfbb5a807ef068413737ffe16/after/b7528a1c967bda90c7a85a7890947a62b33da007@github.com>

h_east

unread,
Sep 22, 2025, 10:30:37 PMSep 22
to vim/vim, Push

@h-east pushed 3 commits.

  • ff2fb5d Revamp `make proto`
  • 700dd03 Removed error workaround code for `cproto`
  • fb84f4c Removed unnecessary `defined(PROTO)`

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/b7528a1c967bda90c7a85a7890947a62b33da007/after/fb84f4c4b3b0565e4c0ebe16e792f35d26bb3ca9@github.com>

h_east

unread,
Sep 22, 2025, 10:51:06 PMSep 22
to vim/vim, Push

@h-east pushed 3 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/fb84f4c4b3b0565e4c0ebe16e792f35d26bb3ca9/after/9e42ba34f9851140c7b85b637d31c3f0f7e6d2b8@github.com>

h_east

unread,
Sep 23, 2025, 12:35:51 AMSep 23
to vim/vim, Push

@h-east pushed 4 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/9e42ba34f9851140c7b85b637d31c3f0f7e6d2b8/after/6ccb571a9d9f8fbff9c7ee05b88fe720fe0cd3ef@github.com>

h_east

unread,
Sep 23, 2025, 12:49:41 AMSep 23
to vim/vim, Subscribed
h-east left a comment (vim/vim#18045)

I think it's almost finished.
I've confirmed that proto/*.pro outputs the same thing on Ubuntu 24.04 and Windows 11 (with Git Bash).

ALL>
I have a request for everyone:
Could you please let me know if there are any differences when running make proto in your environment?

The setup for the execution environment is written in src/Makefile. (See below)

I would be happy to gather information from various platforms. Thank you.

# Generate function prototypes. Previously, cproto was used, but since there
# was a lot of fiddling to do to generate them correctly, so we switched to a
# Python script using libclang.  It has the following features:
# - Only the bare minimum of macro definitions is required.
# - Generates the same .pro file even across different operating systems.
#   (maybe)
#
# How to set up environment to run `make proto`
# On Ubuntu 24.04:
# - Install libclang
#   Use the package provided by Ubuntu.
#     $ sudo apt install python3-clang
#   Or, Create venv (if you want to use it freely with pip)
#     $ python3 -m venv ~/venv
#     $ source ~/venv/bin/activate
#     $ pip install --upgrade pip
#     $ pip install libclang
# On Windows 11 (using Git Bash):
# - Install GNU Make 3.81 or later.
# - Download and install Python from the Python official website.
# - Install libclang
#   $ python -m pip install libclang
# - Change the following lines in this file:
#   s/^PYTHON=python3/PYTHON=python/
#   s/^tags TAGS: notags/tags: notags/
PYTHON=python3


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3322401715@github.com>

Christian Brabandt

unread,
Sep 23, 2025, 4:52:47 PMSep 23
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18045)

it seems to work better for me, does no longer depend on the current configure options, although the build dependencies are much heavier.

I have 2 questions:


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3325514637@github.com>

h_east

unread,
Sep 24, 2025, 8:45:10 AMSep 24
to vim/vim, Push

@h-east pushed 5 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/6ccb571a9d9f8fbff9c7ee05b88fe720fe0cd3ef/after/9292170bb2f53f63accef346d61bea2af8952c4b@github.com>

h_east

unread,
Sep 24, 2025, 9:11:18 AMSep 24
to vim/vim, Subscribed
h-east left a comment (vim/vim#18045)

although the build dependencies are much heavier.

What part of the behavior does this refer to specifically?

I have 2 questions:
* Can we make it true dependencies? So it only generates the proto files, if there are changes?

Does this mean, for example, that when alloc.c is updated, make should update proto/alloc.pro?
The original make proto was separate from make, so I gave it a similar structure.
The new make proto depends on Python and libclang. If I implement the above suggestion, even make will depend on Python and libclang. Is this okay?

Or does it mean that it only updates the .pro files that correspond to the .c files that are updated when make proto is executed?
Hmm, make proto isn't something that is executed that often, so I think it's fine to leave it as it is (updating all .pro files).
(It's just that writing the dependencies is a hassle. 😅)

* I think we can get rid of this block here: 

Done. Thanks.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3328347267@github.com>

h_east

unread,
Sep 25, 2025, 9:07:57 AMSep 25
to vim/vim, Subscribed
h-east left a comment (vim/vim#18045)

Or does it mean that it only updates the .pro files that correspond to the .c files that are updated when make proto is executed?

I'm working on above.
Final confirmation is underway.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3333897634@github.com>

h_east

unread,
Sep 28, 2025, 7:57:22 PM (12 days ago) Sep 28
to vim/vim, Push

@h-east pushed 4 commits.

  • 581c1bd Revamp `make proto`
  • 015f499 Removed error workaround code for `cproto`
  • c8b2a26 Removed unnecessary `defined(PROTO)`
  • 10e4c2a Remove unnecessary blocks

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/9292170bb2f53f63accef346d61bea2af8952c4b/after/10e4c2a18ab499de2ccb04aaef84e4ae5fd2b6e1@github.com>

h_east

unread,
Sep 28, 2025, 8:23:36 PM (12 days ago) Sep 28
to vim/vim, Push

@h-east pushed 1 commit.

  • 4b7a5e6 Added a mechanism to update only the target .pro by adding a dependency between .pro and .c

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/10e4c2a18ab499de2ccb04aaef84e4ae5fd2b6e1/after/4b7a5e6d3768a06826b9d97e50eb524442553e43@github.com>

h_east

unread,
Sep 28, 2025, 8:33:35 PM (12 days ago) Sep 28
to vim/vim, Push

@h-east pushed 1 commit.

  • d174dda Added a mechanism to update only the target .pro by adding a dependency between .pro and .c

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/4b7a5e6d3768a06826b9d97e50eb524442553e43/after/d174dda9d8aa1dfa64eae3af28fc888c10027f55@github.com>

h_east

unread,
Sep 30, 2025, 9:38:53 AM (10 days ago) Sep 30
to vim/vim, Push

@h-east pushed 5 commits.

  • 58f2dd5 Revamp `make proto`
  • ce02786 Removed error workaround code for `cproto`
  • 3747f92 Removed unnecessary `defined(PROTO)`
  • af1eea0 Remove unnecessary blocks
  • 09a45ae Added a mechanism to update only the target .pro by adding a dependency between .pro and .c

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/d174dda9d8aa1dfa64eae3af28fc888c10027f55/after/09a45ae4fd5174aea079150240a3460d37877db0@github.com>

h_east

unread,
Sep 30, 2025, 9:48:22 AM (10 days ago) Sep 30
to vim/vim, Push

@h-east pushed 5 commits.

  • 9e01fe1 Revamp `make proto`
  • 761e271 Removed error workaround code for `cproto`
  • ae56f6a Removed unnecessary `defined(PROTO)`
  • c4e4796 Remove unnecessary blocks
  • 50e3fd2 Added a mechanism to update only the target .pro by adding a dependency between .pro and .c

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/09a45ae4fd5174aea079150240a3460d37877db0/after/50e3fd221b61c6118cebb50d027d1910da724a00@github.com>

h_east

unread,
Sep 30, 2025, 10:44:07 AM (10 days ago) Sep 30
to vim/vim, Push

@h-east pushed 6 commits.

  • 2c81725 Revamp `make proto`
  • f9674e9 Removed error workaround code for `cproto`
  • f8740b5 Removed unnecessary `defined(PROTO)`
  • 81ad53d Remove unnecessary blocks
  • 7dab2ed Added a mechanism to update only the target .pro by adding a dependency between .pro and .c
  • 1a8616d Fix permission to 644

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/50e3fd221b61c6118cebb50d027d1910da724a00/after/1a8616d3eee200b66e59068cc777c17c992c5d4a@github.com>

h_east

unread,
Sep 30, 2025, 10:51:01 AM (10 days ago) Sep 30
to vim/vim, Subscribed
h-east left a comment (vim/vim#18045)

Or does it mean that it only updates the .pro files that correspond to the .c files that are updated when make proto is executed?

I'm working on above. Final confirmation is underway.

Done !!

@ychin
Could you please tell me the results of make protoclean; make proto on macOS using the following as a reference?
#18045 (comment)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3352577994@github.com>

h_east

unread,
Oct 1, 2025, 6:45:16 AM (9 days ago) Oct 1
to vim/vim, Push

@h-east pushed 5 commits.

  • 2184519 Revamp `make proto`
  • 922801a Removed error workaround code for `cproto`
  • 0d47408 Removed unnecessary `defined(PROTO)`
  • bbc78cd Remove unnecessary blocks
  • 63f746d Added a mechanism to update only the target .pro by adding a dependency between .pro and .c

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/1a8616d3eee200b66e59068cc777c17c992c5d4a/after/63f746d887798a6429bf207710ffc87ebc078ae0@github.com>

h_east

unread,
Oct 1, 2025, 7:04:00 AM (9 days ago) Oct 1
to vim/vim, Subscribed
h-east left a comment (vim/vim#18045)

@chrisbra
No one has checked it, but if it works fine in your environment, I think it's fine to merge it in. At least you can run make proto on major/minor releases.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3355808433@github.com>

Christian Brabandt

unread,
Oct 1, 2025, 4:24:13 PM (9 days ago) Oct 1
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18045)

Thanks, it is quite nice. Can you add something like the following on top of it, so that it runs in CI automatically and verifies the proto files are always up to date?

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 004f4a622..b408d8569 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -84,7 +84,7 @@ jobs:
             architecture: arm64
           - features: normal
             compiler: gcc
-            extra: [vimtags]
+            extra: [vimtags, proto]
           - features: huge
             compiler: gcc
             extra: [no_x11]
@@ -182,6 +182,9 @@ jobs:
               libattr1-dev
             )
           fi
+          if ${{ contains(matrix.extra, 'proto') }}; then
+            PKGS+=( python3-clang )
+          fi
           sudo apt-get update && sudo apt-get upgrade -y --allow-downgrades && sudo apt-get install -y --allow-downgrades "${PKGS[@]}"

       - name: Install gcc-${{ env.GCC_VER }}
@@ -270,6 +273,9 @@ jobs:
           if ${{ contains(matrix.extra, 'vimtags') }}; then
             echo "TEST=-C runtime/doc vimtags VIMEXE=../../${SRCDIR}/vim"
           fi
+          if ${{ contains(matrix.extra, 'proto') }}; then
+            echo "TEST=-C src proto"
+          fi
           echo "CFLAGS=${CFLAGS}"
           echo "CONFOPT=${CONFOPT}"
           # Disables GTK attempt to integrate with the accessibility service that does run in CI.
@@ -354,6 +360,15 @@ jobs:
             true
           )

+      - name: Generate Proto files
+        if: contains(matrix.extra, 'proto')
+        run: |
+          # This will exit with an error code if the generated proto files differ from source
+          (
+            git diff --exit-code -- src/proto/
+            true
+          )
+
       - name: Generate gcov files
         if: matrix.coverage
         run: |

(untested)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3358006853@github.com>

D. Ben Knoble

unread,
Oct 1, 2025, 5:53:05 PM (9 days ago) Oct 1
to vim/vim, Subscribed
benknoble left a comment (vim/vim#18045)

On my machine (macOS 12.7.6) after installing libclang in a Python virtual environment, make protoclean && make proto ran from src (but not the top-level…).

It reran the configure script, which was unexpected to me as a passive follower of this topic (I'm not sure which configure options were picked up or used).

The resulting working tree was clean (no files were modified according to git status).

I used commit 3b682f5 (Merge 63f746d into 3495936, 2025-10-02) generated automatically by GitHub as refs/pull/18045/merge from this PR at 63f746d (Added a mechanism to update only the target .pro by adding a dependency between .pro and .c, 2025-09-29).


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3358291064@github.com>

D. Ben Knoble

unread,
Oct 4, 2025, 6:07:53 AM (6 days ago) Oct 4
to vim/vim, Subscribed
benknoble left a comment (vim/vim#18045)

It reran the configure script, which was unexpected to me as a passive follower of this topic (I'm not sure which configure options were picked up or used).

I updated the path names for TCL_PRO and PERL_PRO in src/configure.ac and src/auto/configure, so it's normal for configure to run on the first attempt. (I'll also review the settings for LUA_PRO, MZSCHEME_PRO, and RUBY_PRO.)

Ah, gotcha, good to know!


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3358759935@github.com>

h_east

unread,
Oct 4, 2025, 6:07:54 AM (6 days ago) Oct 4
to vim/vim, Subscribed
h-east left a comment (vim/vim#18045)

Thanks for confirming.

On my machine (macOS 12.7.6) after installing libclang in a Python virtual environment, make protoclean && make proto ran from src (but not the top-level…).

It reran the configure script, which was unexpected to me as a passive follower of this topic (I'm not sure which configure options were picked up or used).

I updated the path names for TCL_PRO and PERL_PRO in src/configure.ac and src/auto/configure, so it's normal for configure to run on the first attempt. (I'll also review the settings for LUA_PRO, MZSCHEME_PRO, and RUBY_PRO.)

The resulting working tree was clean (no files were modified according to git status).

Since everything worked without issues, I'm relieved.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3358623418@github.com>

Drew Vogel

unread,
Oct 4, 2025, 9:45:26 AM (6 days ago) Oct 4
to vim/vim, Subscribed
dvogel left a comment (vim/vim#18045)

@chrisbra and Vim members, What do you think of this approach? Although make proto depends on python and clang, I think it's better than continuing to use cproto.

@h-east can you elaborate on why you think this is better than using cproto? Which cproto shortcomings are you working to rid us of?

The python program appears to be using regular expressions to parse pre-processor directives, translating them to python code, so that it can eval the conditions. It is an impressive feat but it requires pretty substantial expertise with both C and python to work on. Also, it seems to me we already have a tool to evaluate those pre-processor conditions: the C pre-processor. Why not run the source files through cpp and parse that with the clang parser?


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3368252200@github.com>

h_east

unread,
Oct 5, 2025, 8:29:29 AM (5 days ago) Oct 5
to vim/vim, Subscribed
h-east left a comment (vim/vim#18045)

Thank you for your question.
The main goal of gen_prototypes.py is to improve the consistency and maintainability of the generated .pro files.
There are several long-standing issues with the current cproto-based approach.


1. Limitations of cproto

  • Development of cproto has long been discontinued, so no further updates or fixes are expected.
  • Without manually specifying a sufficient number of system include paths using -I, cproto fails to parse and produces no .pro files.
  • Many workarounds exist in the Vim source and src/Makefile to make cproto work correctly.
    See this commit
  • On macOS — one of Vim's major supported platforms — make proto currently does not work properly.

These issues make maintaining and reproducing consistent results with cproto increasingly difficult.


2. Advantages of using Clang

By using libclang, we can parse source code with the same accuracy as a real C compiler.
This allows us to reliably extract return types, argument types, and qualifiers, eliminating discrepancies between Vim's source code and the generated prototypes.


3. Why not just use cpp?

gen_prototypes.py implements its own lightweight handling of preprocessor directives only to keep the generated output consistent across all platforms.

  • I wanted the output of make proto to be identical regardless of the results of ./configure.
  • Achieving that with cpp would require defining all relevant macros for every platform, which is cumbersome.
  • Therefore, I implemented a minimal, self-contained interpretation of preprocessor conditions directly in Python,
    reducing the need for external macro definitions while still ensuring consistent results.

In summary, combining Clang's precise parsing with minimal preprocessing logic in Python allows us to produce reliable, reproducible proto files across all platforms, without depending on cproto's legacy behavior.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3369024645@github.com>

h_east

unread,
Oct 5, 2025, 9:00:43 AM (5 days ago) Oct 5
to vim/vim, Push

@h-east pushed 3 commits.

  • 1c40b7e Revamp `make proto`
  • 7de36f2 Removed error workaround code for `cproto`
  • 1ccc488 Removed unnecessary `defined(PROTO)`


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/63f746d887798a6429bf207710ffc87ebc078ae0/after/1ccc488c3fbc83a224343066b6980081b3cae505@github.com>

h_east

unread,
Oct 6, 2025, 7:21:22 AM (4 days ago) Oct 6
to vim/vim, Push

@h-east pushed 3 commits.

  • ad218c8 Revamp `make proto`
  • 94c625b Removed error workaround code for `cproto`
  • baebda4 Removed unnecessary `defined(PROTO)`

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/1ccc488c3fbc83a224343066b6980081b3cae505/after/baebda4b64ac9c49cf829098224acac85000103e@github.com>

h_east

unread,
Oct 6, 2025, 8:45:07 AM (4 days ago) Oct 6
to vim/vim, Push

@h-east pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/baebda4b64ac9c49cf829098224acac85000103e/after/bf998b2360ae7543cdcf54f456cf85244d7e5fcd@github.com>

h_east

unread,
Oct 6, 2025, 9:10:56 AM (4 days ago) Oct 6
to vim/vim, Push

@h-east pushed 1 commit.

  • dcb38d8 Test: Commit the proto error intentionally

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/bf998b2360ae7543cdcf54f456cf85244d7e5fcd/after/dcb38d85aa82fc106ad19afeec47d8bb5c9cb9e0@github.com>

h_east

unread,
Oct 6, 2025, 10:23:47 AM (4 days ago) Oct 6
to vim/vim, Push

@h-east pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/dcb38d85aa82fc106ad19afeec47d8bb5c9cb9e0/after/8ecd7bd0634b020e18f7908e42049c919f34b061@github.com>

h_east

unread,
Oct 6, 2025, 10:34:53 AM (4 days ago) Oct 6
to vim/vim, Push

@h-east pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/8ecd7bd0634b020e18f7908e42049c919f34b061/after/fe50afaf9389374af84947f8ed689043453184d5@github.com>

Drew Vogel

unread,
Oct 6, 2025, 10:45:50 PM (4 days ago) Oct 6
to vim/vim, Subscribed

@dvogel commented on this pull request.

Thanks for the full explanation of your motivations here @h-east. I did my best to condense it down into a comment at the top of the program because I think it will be very helpful to maintain momentum here.

I think some minimal level of automated tests will be needed to help others maintain this. cproto had a collection of tests that allowed it's output to be verified. Perhaps those could be ported over here.


In src/proto/gen_prototypes.py:

> @@ -0,0 +1,462 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import os
⬇️ Suggested change
-import os
+
+# The main goal of gen_prototypes.py is to provide .pro files that are generated consistently
+# across platforms, thereby making them easier to maintain. This replaced the cproto project
+# because (a) it became unmaintained, (b) had too many system-wide include path
+# dependencies, and (c) did not run on macos.
+#
+# libclang is used to reliably parse the C source code with the same accuracy as the compiler.
+# The parsed code is then scanned for pre-processor directives and dynamically translated to
+# python code that can be evaluated. This approach allows the translation to be done without
+# defining all macros (which would be required for evaluation with cpp) and without concern
+# for the developer's most recently generated build configuration.
+
+import os


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/review/3308116429@github.com>

h_east

unread,
Oct 6, 2025, 11:28:34 PM (4 days ago) Oct 6
to vim/vim, Subscribed
h-east left a comment (vim/vim#18045)

Thank you.
Automated testing (CI) was also suggested by ChrisBra, so yesterday I committed a trial implementation. It's currently producing duplicate output, but I plan to fix it eventually.
#18045 (comment)

https://github.com/vim/vim/actions/runs/18284424132/job/52055491680?pr=18045#step:21:221


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3375033463@github.com>

h_east

unread,
Oct 7, 2025, 7:36:28 AM (3 days ago) Oct 7
to vim/vim, Push

@h-east pushed 5 commits.

  • 256d04d Revamp `make proto`
  • 9c95ade Removed error workaround code for `cproto`
  • 1b10ef1 Removed unnecessary `defined(PROTO)`
  • 4d666b1 Add CI proto
  • e600e23 Test: Commit the proto error intentionally

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/fe50afaf9389374af84947f8ed689043453184d5/after/e600e232c6928ca2346d51f0cbdb9aafbeaae6d1@github.com>

h_east

unread,
Oct 7, 2025, 7:53:06 AM (3 days ago) Oct 7
to vim/vim, Subscribed
h-east left a comment (vim/vim#18045)

Confirm that the expected proto error appears. OK

image.png (view on web)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3376542552@github.com>

h_east

unread,
Oct 7, 2025, 7:58:45 AM (3 days ago) Oct 7
to vim/vim, Push

@h-east pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/e600e232c6928ca2346d51f0cbdb9aafbeaae6d1/after/45631665c9d0549e79c9f71676007a684a347bc5@github.com>

h_east

unread,
Oct 7, 2025, 10:39:47 AM (3 days ago) Oct 7
to vim/vim, Push

@h-east pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/45631665c9d0549e79c9f71676007a684a347bc5/after/231bed855a13cc582a110a7887220130f15456e8@github.com>

h_east

unread,
Oct 8, 2025, 7:56:19 AM (2 days ago) Oct 8
to vim/vim, Push

@h-east pushed 8 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/231bed855a13cc582a110a7887220130f15456e8/after/d205beb4139b1920391120c2ca7e1e0529b705a2@github.com>

h_east

unread,
Oct 8, 2025, 8:51:35 AM (2 days ago) Oct 8
to vim/vim, Push

@h-east pushed 6 commits.

  • f773aca Revamp `make proto`
  • 31a6b3d Removed error workaround code for `cproto`
  • 42b50f1 Removed unnecessary `defined(PROTO)`
  • f03b6bf Add CI proto
  • c95f7d3 Test: Commit the proto error intentionally
  • 7e32ec5 Tweak (W.I.P)

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/d205beb4139b1920391120c2ca7e1e0529b705a2/after/7e32ec53480c0745870e6e1e453ab3c5a9e037c7@github.com>

h_east

unread,
Oct 8, 2025, 8:54:29 AM (2 days ago) Oct 8
to vim/vim, Push

@h-east pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/7e32ec53480c0745870e6e1e453ab3c5a9e037c7/after/0b3c828eb58d4a86aae89a5ba544b8c8626a9a2b@github.com>

h_east

unread,
Oct 8, 2025, 10:32:31 AM (2 days ago) Oct 8
to vim/vim, Subscribed
h-east left a comment (vim/vim#18045)

@chrisbra Ready to merge 👍
I think it's fine to add various documentation and code comments later.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3381835967@github.com>

h_east

unread,
Oct 8, 2025, 10:43:28 AM (2 days ago) Oct 8
to vim/vim, Push

@h-east pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/before/fc348266c959ff9e533465e2f07f1f547be63eb1/after/5418fc2e476fc173e129da8ef77f6d301051de4e@github.com>

Christian Brabandt

unread,
Oct 8, 2025, 2:25:03 PM (2 days ago) Oct 8
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18045)

thanks


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3382725965@github.com>

Christian Brabandt

unread,
Oct 8, 2025, 2:34:51 PM (2 days ago) Oct 8
to vim/vim, Subscribed

Closed #18045 via e7c765f.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/issue_event/20170021709@github.com>

Yee Cheng Chin

unread,
Oct 8, 2025, 10:31:36 PM (2 days ago) Oct 8
to vim/vim, Subscribed
ychin left a comment (vim/vim#18045)

Hi, I haven't been keeping up-to-date with this but I just pulled Vim and this doesn't even build…

The error message looks like this:

Traceback (most recent call last):
gcc -c -I. -Ilibvterm/include -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN -I/opt/homebrew/Cellar/libsodium/1.0.20/include  -g -O2  -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1        -DINLINE="" -DVSNPRINTF=vim_vsnprintf -DSNPRINTF=vim_snprintf -DIS_COMBINING_FUNCTION=utf_iscomposing_uint -DWCWIDTH_FUNCTION=utf_uint2cells -o objects/vterm_screen.o libvterm/src/screen.c
  File "/Users/ychin/Dev/external/vim/src/proto/gen_prototypes.py", line 39, in <module>
    from clang.cindex import Index, CursorKind, StorageClass, TokenKind
ModuleNotFoundError: No module named 'clang'
make[1]: *** [proto/gui_beval.pro] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [first] Error 2

For reference the build steps was make distclean && ./configure && make, the most bog-standard way to build Vim cleanly.

Seems like every single build is now calling gen_prototypes.py, which uses the clang dependency. This is a completely new build requirement. Is this intentional? I thought this is just run on CI to make sure the prototypes match? Why are we forcing a new build dependency on everyone who just wants to build Vim without prior notice?

Can we revert this if a fix cannot be found quickly?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3383830825@github.com>

h_east

unread,
Oct 8, 2025, 10:44:39 PM (2 days ago) Oct 8
to vim/vim, Subscribed
h-east left a comment (vim/vim#18045)

@ychin Sorry, see below links.
#18523 (comment)
#18523 (comment)


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3383848862@github.com>

Yee Cheng Chin

unread,
Oct 9, 2025, 6:08:42 PM (24 hours ago) Oct 9
to vim/vim, Subscribed
ychin left a comment (vim/vim#18045)

Thanks for fixing it.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18045/c3387626571@github.com>

Reply all
Reply to author
Forward
0 new messages