Skip to content

Merge the ctest2 repository into libc #4283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 350 commits into from

Conversation

tgross35
Copy link
Contributor

libc's testing is pretty tightly coupled to ctest2, which is a reasonably simple crate that maps Rust syntax to C syntax and creates tests based off of that. ctest2 itself is a fork of ctest.

Unfortunately, relying on ctest(2) has been somewhat of a problem since it supports only a very outdated version of Rust's syntax, and there are a handful of other bugs. There have been some GSoC proposals to modernize libc and its test crates; moving ctest to a rust-lang repo makes that easier and should come with some maintenance benefits.

On Zulip, @alexcrichton confirmed ownership of the original ctest crate could be transferred to rust-lang so we can continue publishing under that name, for other repos that make use of ctest/ctest2.

This pull only brings over the repo source and history as it currently exists. I will need to follow up with integration of the CI and release workflows.

gnzlbg and others added 30 commits February 26, 2018 15:24
allow deprecated declarations on non-msvc targets
Without this, the entries added in
rust-lang#960 are never tested.
Add target_endian to the set of #[cfg()] items that are considered.
Add support for unions without typedefs
Being able to call `const fn` on stable is a relatively new addition.

CC rust-lang#1075
Revert bump in the minimum supported Rust version
Minimal support for fn types in extern statics
Add support for arrays in extern statics
Skip signedness checks for type aliases of non-integer types
@rustbot
Copy link
Collaborator

rustbot commented Feb 22, 2025

@tgross35: no appropriate reviewer found, use r? to override

@tgross35
Copy link
Contributor Author

tgross35 commented Feb 22, 2025

@JohnTitor would you be okay with libc absorbing ctest2, or do you have any concerns? You can continue to maintain it here if you wish of course.

@tgross35
Copy link
Contributor Author

Also, does anyone know of a better way to merge unrelated histories? The blame works fine but the log appears empty.

@alexcrichton
Copy link
Member

I think I've done something like this in the past using git filter-branch which rewrites the history as-if it all happened in a subfolder which should help with log/blame by ensuring the filenames don't change abruptly

@tgross35
Copy link
Contributor Author

r? @JohnTitor

I of course don't want to poach your fork without your okay, so I'll assign you :) if you're fine going forward, I'll get the history better integrated as Alex suggested before merging.

Copy link
Member

@JohnTitor JohnTitor left a comment

Choose a reason for hiding this comment

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

Yeah, no objection. Thank you!

@JohnTitor
Copy link
Member

JohnTitor commented Mar 1, 2025

Some crates use ctest2 in their tests, so maybe I should add a deprecation notice and encourage to migrate in the ctest2 once the ctest supports the modern Rust.

@12101111 12101111 mentioned this pull request Mar 16, 2025
3 tasks
@tgross35 tgross35 force-pushed the absorb-ctest branch 2 times, most recently from 2c44840 to f1f0fbf Compare April 2, 2025 21:55
@tgross35 tgross35 closed this Apr 2, 2025
@tgross35
Copy link
Contributor Author

tgross35 commented Apr 2, 2025

Github closed this on me when I pushed some unrelated history and won't let me reopen. Recreated as #4361

@tgross35
Copy link
Contributor Author

tgross35 commented Apr 2, 2025

Merged! 🎉 https://github.com/rust-lang/libc/tree/d5278fd7a746572c0c0b31d4a3d74366fbf5243e/ctest. Thanks Alex and Yuki for the help here.

I think I've done something like this in the past using git filter-branch which rewrites the history as-if it all happened in a subfolder which should help with log/blame by ensuring the filenames don't change abruptly

I wound up using git filter-repo (external tool recommended by git) rather than git filter-branch which worked out quite nice because it also rewrites shas mentioned in commit messages (e.g. reverts) and has a nice UI. The resulting history and blame look correct.

For future reference since I'm sure I'll need to do this again at some point:

# This was done on a fresh clone from ctest2

# Move to a subdirectory
git filter-repo --to-subdirectory-filter ctest

# Prefix all tags with `ctest-`
git filter-repo --tag-rename ':ctest-'

# The default merge messages are "merge pull request #nnn from user/branch"
# GH links these incorrectly in the new repo, so rename from `#nnn` to
# `JohnTitor/ctest2#nnn` (doesn't work for anything from the original `ctest`
# repo, but close enough).
echo 'regex:(^|\s)(#\d+)==>\1JohnTitor/ctest2\2' > messages.txt
git filter-repo --replace-message messages.txt

# After configuring a new remote (mine), push everything
git push --force --tags --prune tg-ctest2

# Now in the `libc` directory...

# Add that remote, fetch to update, etc
git remote add origin tg-ctest2 ...

# Merge, put something reasonable in the message
git merge tg-ctest2/... --allow-unrelated-histories

# Add whatever fixup commits are needed so CI passes,
# then push to `main` or use a PR.

# Tags didn't come through, so I just pushed them directly to rust-lang/libc
git push upstream tag 'ctest-*'

tgross35 added a commit to rust-lang/compiler-builtins that referenced this pull request Apr 18, 2025
…orb-libm

Absorb the libm repository into `compiler-builtins`.

This was done using `git-filter-repo` to ensure hashes mentioned in
commit messages were correctly rewritten, I used the same strategy to
merge `ctest` into `libc` [1] and it worked quite well. Approximately:

    # `git filter-repo` requires a clean clone
    git clone https://github.com/rust-lang/libm.git

    # Move all code to a `libm` subdirectory for all history
    git filter-repo --to-subdirectory-filter libm

    # The default merge messages are "merge pull request #nnn from
    # user/branch". GH links these incorrectly in the new repo, so
    # rewrite messages from `#nnn` to `rust-lang/libm#nnn`.
    echo 'regex:(^|\s)(#\d+)==>\1rust-lang/libm\2' > messages.txt
    git filter-repo --replace-message messages.txt

    # Re-add a remote and push as a new branch
    git remote add upstream https://github.com/rust-lang/libm.git
    git switch -c merge-into-builtins-prep
    git push --set-upstream upstream merge-into-builtins-prep

    # Now in a compiler-builtins, add `libm` as a remote
    git remote add libm https://github.com/rust-lang/libm.git
    git fetch libm

    # Do the merge that creates this commit
    git merge libm/merge-into-builtins-prep --allow-unrelated-histories

The result should be correct git history and blame for all files, with
messages that use correct rewritten hashes when they are referenced.
There is some reorganization and CI work needed, but that will be a
follow up.

After this merges I will need to push tags from `libm`, which I have
already rewritten to include a `libm-` prefix. Old tags in
compiler-builtins should likely also be rewritten to add a prefix (we
already have this for newer tags), but this can be done at any point.

* Original remote: https://github.com/rust-lang/libm.git
* Default HEAD: c94017af75c3ec4616d5b7f9b6b1b3826b934469 ("Migrate all
  crates except `libm` to edition 2024")
* HEAD after rewriting history: 15fb630
  ("Migrate all crates except `libm` to edition 2024")

[1]: rust-lang/libc#4283 (comment)
tgross35 added a commit to rust-lang/compiler-builtins that referenced this pull request Apr 19, 2025
…orb-libm

Absorb the libm repository into `compiler-builtins`.

This was done using `git-filter-repo` to ensure hashes mentioned in
commit messages were correctly rewritten, I used the same strategy to
merge `ctest` into `libc` [1] and it worked quite well. Approximately:

    # `git filter-repo` requires a clean clone
    git clone https://github.com/rust-lang/libm.git

    # Move all code to a `libm` subdirectory for all history
    git filter-repo --to-subdirectory-filter libm

    # The default merge messages are "merge pull request #nnn from
    # user/branch". GH links these incorrectly in the new repo, so
    # rewrite messages from `#nnn` to `rust-lang/libm#nnn`.
    echo 'regex:(^|\s)(#\d+)==>\1rust-lang/libm\2' > messages.txt
    git filter-repo --replace-message messages.txt

    # Re-add a remote and push as a new branch
    git remote add upstream https://github.com/rust-lang/libm.git
    git switch -c merge-into-builtins-prep
    git push --set-upstream upstream merge-into-builtins-prep

    # Now in a compiler-builtins, add `libm` as a remote
    git remote add libm https://github.com/rust-lang/libm.git
    git fetch libm

    # Do the merge that creates this commit
    git merge libm/merge-into-builtins-prep --allow-unrelated-histories

The result should be correct git history and blame for all files, with
messages that use correct rewritten hashes when they are referenced.
There is some reorganization and CI work needed, but that will be a
follow up.

After this merges I will need to push tags from `libm`, which I have
already rewritten to include a `libm-` prefix. Old tags in
compiler-builtins should likely also be rewritten to add a prefix (we
already have this for newer tags), but this can be done at any point.

* Original remote: https://github.com/rust-lang/libm.git
* Default HEAD: c94017af75c3ec4616d5b7f9b6b1b3826b934469 ("Migrate all
  crates except `libm` to edition 2024")
* HEAD after rewriting history: 15fb630
  ("Migrate all crates except `libm` to edition 2024")

[1]: rust-lang/libc#4283 (comment)
tgross35 added a commit to tgross35/rust that referenced this pull request Jun 3, 2025
…orb-libm

Absorb the libm repository into `compiler-builtins`.

This was done using `git-filter-repo` to ensure hashes mentioned in
commit messages were correctly rewritten, I used the same strategy to
merge `ctest` into `libc` [1] and it worked quite well. Approximately:

    # `git filter-repo` requires a clean clone
    git clone https://github.com/rust-lang/libm.git

    # Move all code to a `libm` subdirectory for all history
    git filter-repo --to-subdirectory-filter libm

    # The default merge messages are "merge pull request #nnn from
    # user/branch". GH links these incorrectly in the new repo, so
    # rewrite messages from `#nnn` to `rust-lang/libm#nnn`.
    echo 'regex:(^|\s)(#\d+)==>\1rust-lang/libm\2' > messages.txt
    git filter-repo --replace-message messages.txt

    # Re-add a remote and push as a new branch
    git remote add upstream https://github.com/rust-lang/libm.git
    git switch -c merge-into-builtins-prep
    git push --set-upstream upstream merge-into-builtins-prep

    # Now in a compiler-builtins, add `libm` as a remote
    git remote add libm https://github.com/rust-lang/libm.git
    git fetch libm

    # Do the merge that creates this commit
    git merge libm/merge-into-builtins-prep --allow-unrelated-histories

The result should be correct git history and blame for all files, with
messages that use correct rewritten hashes when they are referenced.
There is some reorganization and CI work needed, but that will be a
follow up.

After this merges I will need to push tags from `libm`, which I have
already rewritten to include a `libm-` prefix. Old tags in
compiler-builtins should likely also be rewritten to add a prefix (we
already have this for newer tags), but this can be done at any point.

* Original remote: https://github.com/rust-lang/libm.git
* Default HEAD: c94017af75c3ec4616d5b7f9b6b1b3826b934469 ("Migrate all
  crates except `libm` to edition 2024")
* HEAD after rewriting history: 15fb6307f6dc295fb965d1c4f486571cc18ab6b3
  ("Migrate all crates except `libm` to edition 2024")

[1]: rust-lang/libc#4283 (comment)
tautschnig pushed a commit to model-checking/verify-rust-std that referenced this pull request Jun 17, 2025
…orb-libm

Absorb the libm repository into `compiler-builtins`.

This was done using `git-filter-repo` to ensure hashes mentioned in
commit messages were correctly rewritten, I used the same strategy to
merge `ctest` into `libc` [1] and it worked quite well. Approximately:

    # `git filter-repo` requires a clean clone
    git clone https://github.com/rust-lang/libm.git

    # Move all code to a `libm` subdirectory for all history
    git filter-repo --to-subdirectory-filter libm

    # The default merge messages are "merge pull request #nnn from
    # user/branch". GH links these incorrectly in the new repo, so
    # rewrite messages from `#nnn` to `rust-lang/libm#nnn`.
    echo 'regex:(^|\s)(#\d+)==>\1rust-lang/libm\2' > messages.txt
    git filter-repo --replace-message messages.txt

    # Re-add a remote and push as a new branch
    git remote add upstream https://github.com/rust-lang/libm.git
    git switch -c merge-into-builtins-prep
    git push --set-upstream upstream merge-into-builtins-prep

    # Now in a compiler-builtins, add `libm` as a remote
    git remote add libm https://github.com/rust-lang/libm.git
    git fetch libm

    # Do the merge that creates this commit
    git merge libm/merge-into-builtins-prep --allow-unrelated-histories

The result should be correct git history and blame for all files, with
messages that use correct rewritten hashes when they are referenced.
There is some reorganization and CI work needed, but that will be a
follow up.

After this merges I will need to push tags from `libm`, which I have
already rewritten to include a `libm-` prefix. Old tags in
compiler-builtins should likely also be rewritten to add a prefix (we
already have this for newer tags), but this can be done at any point.

* Original remote: https://github.com/rust-lang/libm.git
* Default HEAD: c94017af75c3ec4616d5b7f9b6b1b3826b934469 ("Migrate all
  crates except `libm` to edition 2024")
* HEAD after rewriting history: 15fb6307f6dc295fb965d1c4f486571cc18ab6b3
  ("Migrate all crates except `libm` to edition 2024")

[1]: rust-lang/libc#4283 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.