git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 07/18] build: introduce rust

From
Ezekiel Newren <ezekielnewren@gmail.com>
Date
Sep 19, 2025, 20:11 UTC
Message-ID
<CAH=ZcbBBkk2B3PxKf54MRnAmURMK8W7ofFZBRS=ZzkuDNWsY9w@mail.gmail.com>
In-Reply-To
<CAPig+cS_=YTBaCjn8-Th3yn3_k+a8_pMOmdv_Dq4S0tfp8BRCg@mail.gmail.com>
On Wed, Sep 17, 2025 at 2:26 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
> Is ".idea" directory detritus from your chosen editor? If so, it
> probably ought not be added to this list since we don't otherwise
> ignore detritus from foreign tools such as that.

Yes. I use the Jetbrains IDE's CLion and RustRover for C and Rust respectively. Jetbrains has an IDE for MANY languages and all of them use .idea/ as the folder for IDE specific configuration. I'm fine with keeping it out of .gitignore, but I wanted to know what the community thought. Which I should have made it more clear that this patch series was more of an RFC than proposed code to be merged.

Show 79 quoted lines
> > diff --git a/Makefile b/Makefile
> > @@ -916,6 +924,51 @@ TEST_SHELL_PATH = $(SHELL_PATH)
> > +RUST_CRATES :=
> > +.PHONY: compile_rust rustclean
>
> This is an extremely tiny nit, but multi-word target names in the Git
> Makefile are almost universally spelled with a hyphen rather than an
> underscore, so "compile-rust" would be more consistent and
> appropriate.
>
> > +$(GIT_BUILD_DIR)/lib%.a:
> > +       ./build_rust.sh $(GIT_BUILD_DIR) $(RUST_BUILD_MODE) $*
>
> I wonder if this should follow the convention of most (but not quite
> all) other local shell script invocations in the Makefile of
> referencing SHELL_PATH; for instance:
>
>     $(QUIET_GEN)$(SHELL_PATH) ./build_rust.sh ...etc...
>
> with or without the $(QUIET_GEN) bit.
>
> > diff --git a/build_rust.sh b/build_rust.sh
> > @@ -0,0 +1,60 @@
> > +if [ "$dir_git_root" = "" ]; then
> > +  echo "did not specify the directory for the root of git"
> > +  exit 1
> > +fi
>
> Let's follow project style conventions for shell scripts:
>
>     if test "$dir_git_root" = ""
>     then
>         ...
>     fi
>
> or even:
>
>     if test -z "$dir_git_root"
>     then
>         ...
>     fi
>
> Same comment applies to the rest of the script.
>
> Also, should the above error message be sent to stderr rather than
> stdout? (Genuine question since I'm not sure if other scripts are
> necessarily consistent in that regard.)
>
> > +if [ "$rust_build_profile" = "release" ]; then
> > +  rust_args="--release"
> > +  export RUSTFLAGS=''
> > +elif [ "$rust_build_profile" = "debug" ]; then
> > +  rust_args=""
> > +  export RUSTFLAGS='-C debuginfo=2 -C opt-level=1 -C force-frame-pointers=yes'
> > +else
> > +  echo "illegal rust_build_profile value $rust_build_profile"
> > +  exit 1
> > +fi
>
> For maximum portability, we don't use the:
>
>     export FOO=bar
>
> idiom in this project. Instead, do this:
>
>     FOO=bar
>     export FOO
>
> The same comment applies to the remainder of the patch, as well.
>
> Also, the empty-string assignments to RUSTFLAGS and rust_args above
> inconsistently use a mix of single and double quotes. However, we also
> usually just assign nothingness in such cases rather than an empty
> string:
>
>     RUSTFLAGS=
>     export RUSTFLAGS
>     ...
>     rust_args=
I'll try to keep these in mind for the future.
Show 7 quoted lines
> > +if rustup show active-toolchain | grep windows-msvc; then
> > +  libfile="${crate}.lib"
> > +  PATH="$(echo $PATH | tr ':' '\n' | grep -Ev "^(/mingw64/bin|/usr/bin)$" | paste -sd: -):/mingw64/bin:/usr/bin"
> > +fi
>
> Please add either an in-code comment or a sentence/paragraph to the
> commit message explaining why this PATH munging is needed.

I will amend the commit with something like: On windows when building with msvc using shell scripts it looks for link in /mingw64/bin|/usr/bin when it actually needs to look somewhere else for the msvc linker program. Since removing these from PATH would break everything else in the shell; move them to be at the end of PATH.

Show 30 quoted lines
> > +cd $dir_rust && cargo clean && pwd && USE_LINKING="false" cargo build -p $crate $rust_args; cd $dir_git_root
>
> When formatted like this, it is very easy to overlook the fact that
> the final `cd` is (correctly) not &&-chained with the preceding
> commands. Reformatting it like this would help:
>
>     cd $dir_rust &&
>         cargo clean &&
>         pwd &&
>         USE_LINKING="false" cargo build -p $crate $rust_args
>     cd $dir_git_root
>
> Alternatively, use a subshell and drop the final `cd`:
>
>     (
>         cd $dir_rust &&
>         cargo clean &&
>         pwd &&
>         USE_LINKING="false" cargo build -p $crate $rust_args
>     )
>
> By the way, is the `pwd` command needed? What is its purpose?
>
> > +rm $dst 2>/dev/null
>
> I think we typically use `rm -f` without redirect to /dev/null to do
> the "right thing".
>
> > +echo mv $src $dst
> > +mv $src $dst
pwd was for debugging and I forgot to take it out. I'll clean up my script.
Previous: Eric SunshineNext: Eric Sunshine
Message 51 of 100 in “Introduce rust: In xdiff”
  1. 00/15 Introduce rust: In xdiffEzekiel Newren via GitGitGadget, Aug 29, 2025
  2. 01/15 doc: add a policy for using Rustbrian m. carlson via GitGitGadget, Aug 29, 2025
  3. brian m. carlsonAug 29, 2025
  4. Ezekiel NewrenAug 29, 2025
  5. brian m. carlsonSep 2, 2025
  6. Ezekiel NewrenSep 2, 2025
  7. Ezekiel NewrenSep 4, 2025
  8. 02/15 xdiff: introduce rustEzekiel Newren via GitGitGadget, Aug 29, 2025
  9. 03/15 github workflows: install rustEzekiel Newren via GitGitGadget, Aug 29, 2025
  10. 04/15 win+Meson: do allow linking with the Rust-built xdiffJohannes Schindelin via GitGitGadget, Aug 29, 2025
  11. 05/15 github workflows: upload Cargo.lockEzekiel Newren via GitGitGadget, Aug 29, 2025
  12. 06/15 ivec: create a vector type that is interoperable between C and RustEzekiel Newren via GitGitGadget, Aug 29, 2025
  13. 07/15 xdiff/xprepare: remove superfluous forward declarationsEzekiel Newren via GitGitGadget, Aug 29, 2025
  14. 08/15 xdiff: delete unnecessary fields from xrecord_t and xdfile_tEzekiel Newren via GitGitGadget, Aug 29, 2025
  15. 09/15 xdiff: make fields of xrecord_t Rust friendlyEzekiel Newren via GitGitGadget, Aug 29, 2025
  16. 10/15 xdiff: use one definition for freeing xdfile_tEzekiel Newren via GitGitGadget, Aug 29, 2025
  17. 11/15 xdiff: replace chastore with an ivec in xdfile_tEzekiel Newren via GitGitGadget, Aug 29, 2025
  18. 12/15 xdiff: delete nrec field from xdfile_tEzekiel Newren via GitGitGadget, Aug 29, 2025
  19. 13/15 xdiff: delete recs field from xdfile_tEzekiel Newren via GitGitGadget, Aug 29, 2025
  20. 14/15 xdiff: make xdfile_t more rust friendlyEzekiel Newren via GitGitGadget, Aug 29, 2025
  21. 15/15 xdiff: implement xdl_trim_ends() in RustEzekiel Newren via GitGitGadget, Aug 29, 2025
  22. 00/18 Introduce rust: In xdiffEzekiel Newren via GitGitGadget, Sep 17, 2025
  23. 01/18 cleanup: rename variables that collide with Rust primitive type namesEzekiel Newren via GitGitGadget, Sep 17, 2025
  24. Eric SunshineSep 17, 2025
  25. Junio C HamanoSep 17, 2025
  26. Ezekiel NewrenSep 19, 2025
  27. 02/18 make: add -fPIE flagEzekiel Newren via GitGitGadget, Sep 17, 2025
  28. Eric SunshineSep 17, 2025
  29. Ezekiel NewrenSep 19, 2025
  30. Junio C HamanoSep 19, 2025
  31. Ezekiel NewrenSep 19, 2025
  32. Junio C HamanoSep 19, 2025
  33. Collin FunkSep 19, 2025
  34. Junio C HamanoSep 20, 2025
  35. Ramsay JonesSep 21, 2025
  36. 03/18 make: merge xdiff lib into libgit.aEzekiel Newren via GitGitGadget, Sep 17, 2025
  37. Eric SunshineSep 17, 2025
  38. Ezekiel NewrenSep 19, 2025
  39. 04/18 make: merge reftable lib into libgit.aEzekiel Newren via GitGitGadget, Sep 17, 2025
  40. Eric SunshineSep 17, 2025
  41. Junio C HamanoSep 19, 2025
  42. Ezekiel NewrenSep 19, 2025
  43. Junio C HamanoSep 19, 2025
  44. Ezekiel NewrenSep 19, 2025
  45. 05/18 doc: add a policy for using Rustbrian m. carlson via GitGitGadget, Sep 17, 2025
  46. 06/18 BreakingChanges: announce Rust becoming mandatoryPatrick Steinhardt via GitGitGadget, Sep 17, 2025
  47. 07/18 build: introduce rustEzekiel Newren via GitGitGadget, Sep 17, 2025
  48. Eric SunshineSep 17, 2025
  49. Junio C HamanoSep 17, 2025
  50. Eric SunshineSep 18, 2025
  51. Ezekiel NewrenSep 19, 2025
  52. Eric SunshineSep 19, 2025
  53. Ezekiel NewrenSep 19, 2025
  54. 08/18 help: report on whether or not Rust is enabledPatrick Steinhardt via GitGitGadget, Sep 17, 2025
  55. 09/18 github workflows: install rustEzekiel Newren via GitGitGadget, Sep 17, 2025
  56. Eric SunshineSep 17, 2025
  57. 10/18 win+Meson: do allow linking with the Rust-built xdiffJohannes Schindelin via GitGitGadget, Sep 17, 2025
  58. 11/18 github workflows: upload Cargo.lockEzekiel Newren via GitGitGadget, Sep 17, 2025
  59. 12/18 build: new crate, build-helperEzekiel Newren via GitGitGadget, Sep 17, 2025
  60. Eric SunshineSep 17, 2025
  61. 13/18 build-helper: link against libgit.a and any other required C librariesEzekiel Newren via GitGitGadget, Sep 17, 2025
  62. Eric SunshineSep 17, 2025
  63. D. Ben KnobleSep 17, 2025
  64. Eric SunshineSep 17, 2025
  65. Ezekiel NewrenSep 19, 2025
  66. 14/18 build-helper: cbindgen, let crates generate a header fileEzekiel Newren via GitGitGadget, Sep 17, 2025
  67. Eric SunshineSep 17, 2025
  68. Ezekiel NewrenSep 19, 2025
  69. 15/18 varint: use explicit width for integersPatrick Steinhardt via GitGitGadget, Sep 17, 2025
  70. 16/18 build: new crate, miscEzekiel Newren via GitGitGadget, Sep 17, 2025
  71. Eric SunshineSep 17, 2025
  72. Ezekiel NewrenSep 19, 2025
  73. Eric SunshineSep 19, 2025
  74. Ezekiel NewrenSep 19, 2025
  75. 17/18 misc: use BuildHelperEzekiel Newren via GitGitGadget, Sep 17, 2025
  76. 18/18 misc::varint: reimplement as test balloon for RustPatrick Steinhardt via GitGitGadget, Sep 17, 2025
  77. Patrick SteinhardtSep 17, 2025
  78. Ezekiel NewrenSep 19, 2025
  79. Patrick SteinhardtSep 22, 2025
  80. Ezekiel NewrenSep 22, 2025
  81. Patrick SteinhardtSep 22, 2025
  82. Junio C HamanoSep 22, 2025
  83. Ezekiel NewrenSep 22, 2025
  84. Ezekiel NewrenSep 22, 2025
  85. Junio C HamanoSep 22, 2025
  86. Ezekiel NewrenSep 22, 2025
  87. Junio C HamanoSep 22, 2025
  88. Junio C HamanoSep 22, 2025
  89. Junio C HamanoSep 17, 2025
  90. Junio C HamanoSep 17, 2025
  91. Elijah NewrenSep 17, 2025
  92. Junio C HamanoSep 17, 2025
  93. Patrick SteinhardtSep 22, 2025
  94. Ezekiel NewrenSep 22, 2025
  95. Patrick SteinhardtSep 22, 2025
  96. Ezekiel NewrenSep 22, 2025
  97. Patrick SteinhardtSep 23, 2025
  98. Ezekiel NewrenSep 23, 2025
  99. Ezekiel NewrenSep 23, 2025
  100. Junio C HamanoSep 23, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.