Skip to content

git: set update = none for all submodules so that cargo git dependencies don't clone them#1574

Merged
kkysen merged 3 commits intomasterfrom
kkysen/submodule-update-none
Feb 2, 2026
Merged

git: set update = none for all submodules so that cargo git dependencies don't clone them#1574
kkysen merged 3 commits intomasterfrom
kkysen/submodule-update-none

Conversation

@kkysen
Copy link
Contributor

@kkysen kkysen commented Jan 27, 2026

cargo always recursively clones git dependencies, even though c2rust git dependencies don't need any of the big submodules here used just for testing. Setting update = none is workaround (see rust-lang/cargo#10717). However, other users need to explicitly update submodules now.

With this change, it takes ~6 s to resolve a c2rust-bitfields git dependency, vs. many minutes before with all of the large submodules.

@kkysen kkysen requested a review from spernsteiner January 27, 2026 22:16
@kkysen kkysen force-pushed the kkysen/submodule-update-none branch from 43b79bf to ded2b7f Compare January 27, 2026 22:21
…ncies don't clone them

`cargo` always recursively clones git dependencies,
even though c2rust git dependencies don't need
any of the big submodules here used just for testing.
Setting `update = none` is workaround
(see <rust-lang/cargo#10717>).
However, other users need to explicitly update submodules now.

With this change, it takes ~6 s to resolve a `c2rust-bitfields` git dependency,
vs. many minutes before with all of the large submodules.
@kkysen kkysen force-pushed the kkysen/submodule-update-none branch from ded2b7f to a101fbe Compare January 27, 2026 22:32
@ahomescu
Copy link
Contributor

Do we really need this? I feel like it could create other problems, only to optimize a rare download.

Copy link
Contributor Author

@kkysen kkysen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this? I feel like it could create other problems, only to optimize a rare download.

I'm not sure if we really need this, but git dependencies aren't that rare. A bunch of other crates have done this workaround, too. So IMO it seems useful to me on its own, and didn't use to have this behavior before integrating c2rust-testsuite into this repo, so it's new breakage as well.

@randomPoison
Copy link
Contributor

Unfortunately this is fallout from merging the test suite into the main repo. We did that to improve the development workflow, but it does have the consequence that when using the repo as a git dependency cargo is going to try pull down all the submodules. The cargo docs specifically call out update = none as the way to prevent this. Considering that using git dependencies isn't all that uncommon, especially for in-development projects where the latest code may not be on crates.io yet, it seems reasonable that we setup the repo to not download submodules automatically.

One suggestion to make things a bit nice to work with: Could we update test.py to automatically run git submodule update --init --checkout if the repo dir is empty? That'd save us a bit of repetition in the CI script and would make the workflow for running integration tests in a fresh checkout less error-prone.

@kkysen
Copy link
Contributor Author

kkysen commented Jan 29, 2026

One suggestion to make things a bit nice to work with: Could we update test.py to automatically run git submodule update --init --checkout if the repo dir is empty? That'd save us a bit of repetition in the CI script and would make the workflow for running integration tests in a fresh checkout less error-prone.

Yeah, that could probably work.

Also, I realized that cargo install --git https://github.com/immunant/c2rust/, which I feel is actually pretty common, now takes forever.

Copy link
Contributor

@ahomescu ahomescu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a comment somewhere that we're doing this because cargo doesn't let us control whether it updates the submodules?

@ahomescu
Copy link
Contributor

For reference: I think cargo did the wrong thing here, and should have provided a way to download a dependency without submodule.

@kkysen
Copy link
Contributor Author

kkysen commented Jan 29, 2026

Could we add a comment somewhere that we're doing this because cargo doesn't let us control whether it updates the submodules?

Yeah, sure. You want me to add more here: https://github.com/immunant/c2rust/blob/a101fbe53ee2902531bfa6df756e79c792703ea7/.gitmodules?

For reference: I think cargo did the wrong thing here, and should have provided a way to download a dependency without submodule.

I agree. Harder to change that, though. Especially since we're stuck on an older nightly.

@ahomescu
Copy link
Contributor

The cargo issue discussing submodules: rust-lang/cargo#4247 (still open).

Cargo probably shouldn't be doing this,
which is tracked in issue rust-lang/cargo#4247.
@kkysen kkysen requested a review from ahomescu January 29, 2026 22:34
@ahomescu
Copy link
Contributor

LGTM (other than wishing cargo let us do it the other way). Handing it over to @randomPoison since there's some more feedback from her (I wish github had gerrit's +1 votes).

@kkysen kkysen merged commit da68de1 into master Feb 2, 2026
11 checks passed
@kkysen kkysen deleted the kkysen/submodule-update-none branch February 2, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants