Commit graph

16195 commits

Author SHA1 Message Date
bors 66ad359b40 Auto merge of #13144 - weihanglo:openssl1.1.1, r=epage
chore: downgrade to openssl v1.1.1

See <https://github.com/rust-lang/cargo/pull/13101>

> `openssl@0.10.160` switches to OpenSSL v3,
> which causes Cargo build failure on loongarch64.

I overlooked lockfile change in <https://github.com/rust-lang/cargo/pull/13117>.
2023-12-09 12:30:01 +00:00
Weihang Lo 3d4cc51e05
chore: downgrade to openssl v1.1.1 2023-12-08 23:13:06 -05:00
bors 6feabf9477 Auto merge of #13114 - weihanglo:trim-paths-explicit-cwd, r=epage
fix: explicitly remap current dir by using `.`
2023-12-08 22:38:37 +00:00
bors 047dc187da Auto merge of #13143 - ChrisDenton:test-changes, r=weihanglo
Don't rely on mtime to test changes

### What does this PR try to resolve?

Fixes #13139 by making sure tests aren't relying on changing the mtime alone

### How should we test and review this PR?

The pattern to watch out for is when a file is created with empty contents, e.g. `.file("foo", "")`, then later the same file updated with empty contents, e.g. `.change_file("foo", "")`. Tests should be making an actual change to the contents.
2023-12-08 21:37:50 +00:00
Weihang Lo fcd4221c5a
test(trim-paths): don't follow links to separate debuginfo files
For refeference:
https://sourceware.org/binutils/docs/binutils/readelf.html
2023-12-08 16:34:00 -05:00
bors a1449eeb3e Auto merge of #13128 - epage:schema, r=weihanglo
refactor: Pull PackageIdSpec into schema

### What does this PR try to resolve?

This removes one of the remaining ties `util_schemas` has on the rest of cargo as part of #12801.

### How should we test and review this PR?

This is broken up into small commits

### Additional information
2023-12-08 20:55:30 +00:00
Weihang Lo bb86adfff7
fix(trim-paths): explicit remap to current dir .
In https://github.com/rust-lang/rust/blob/87e1447aa/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs#L856
when the remap result of `work_dir` is an empty string,
LLVM won't generate some symbols for root debuginfo node.
For example, `N_SO` and `N_OSO` on macOS,
or `DW_AT_comp_dir` on Linux when debuginfo is splitted.
Precisely, it is observed that when the `DIFile` of compile unit was
provied with an empty compilation `Directory` string,
LLVM would not emit those symbols for the root DI node.

This behavior is not desired,
resulting in corrupted debuginfo and degrading debugging experience.

This is might not be a bug of `--remap-path-prefix` in rustc,
since `-fdebug-prefix-map` in clang 16 could have the same result
(`DW_AT_comp_dir` is gone when `work_dir` is remapped to an empty string).
However, in gcc 12 `fdebug-prefix-map` will return an absolute work_dir
when an empty string occurs.

To not bother whether this needs to be fixed in rustc or not,
let's fix it by always appending an explicit `.`
when `--remap-path-prefix` remaps to relative workspace root
a.k.a. where rustc is invoking.

For more on gcc/clang remap options, see
https://reproducible-builds.org/docs/build-path/
2023-12-08 15:52:06 -05:00
Weihang Lo 7cb7b47fe7
test(trim-paths): add test for each split-debuginfo options
Also demonstarte that on Linux with split-debuginfo on the remap is broken
2023-12-08 15:51:55 -05:00
Chris Denton 4ef503fc2d
Don't rely on mtime to test changes 2023-12-08 20:32:28 +00:00
bors 72b3eb5375 Auto merge of #13140 - epage:wincon, r=weihanglo
fix: Print rustc messages colored on wincon

### What does this PR try to resolve?

The real fix is over in rust-cli/anstyle#150; this just upgrades to it

Fixes #13104

### How should we test and review this PR?

I hacked vt console support off, ran a build before and rustc messages weren't colored.  Now with this change, rustc messages are colored.

### Additional information

This still doesn't address why wincon is being used on their system
2023-12-08 20:11:33 +00:00
Weihang Lo 985d49b916
test(trim-paths): use --config CLI to change options 2023-12-08 13:57:45 -05:00
bors 232f91368f Auto merge of #13131 - ChrisDenton:windows-manifest, r=ehuss
Add a windows manifest file

This adds a Windows [application manifest file](https://docs.microsoft.com/en-us/windows/win32/sbscs/application-manifests) to the built `cargo.exe` for windows msvc. This manifest file is used to enable modern features of Windows. [`rustc`](7df0c211ac/compiler/rustc) has been using a similar manifest for about a year now.

The manifest file does the following:

* States our compatibility with Windows versions 7, 8, 8.1, 10 and 11. This allows avoiding unnecessary compatibility shims.
* Sets the code page to UTF-8. This should have no real impact on existing code (which should work with any code page). That said it may avoid issues if dependencies do use the local code page because conversions to/from Unicode are lossy so if a Unicode code point has no local code page equivalent, information is lost.
* Enable long path awareness. Mostly rust itself side-steps long path issues by using `\\?\` paths internally. However, this doesn't work for the current directory whereas using this option does.

You can test that a manifest file has been embedded by extracting it to a new file:

    mt -nologo -inputresource:cargo.exe -out:embedded.manifest

You can also examine the `.rsrc` (aka resource) section using `dumpbin`

    dumpbin /SECTION:.rsrc /ALL cargo.exe

### Additional info

This also sets the [`/Wx` linker option](https://learn.microsoft.com/en-us/cpp/build/reference/wx-treat-linker-warnings-as-errors?view=msvc-170) which turns linker warnings into errors. When setting linker options manually, I prefer to also set this because, unless there are also linker errors, `rustc` will not show linker warnings by default. Linker warnings should be rare and usually do indicate an actual problem so not ignoring them should be fine.
2023-12-08 18:19:15 +00:00
Ed Page ad2643d8e2 fix: Print rustc messages colored on wincon
Fixes #13104
2023-12-08 11:49:05 -06:00
bors 749654c5fd Auto merge of #13132 - arlosi:cachedir, r=epage
Avoid writing CACHEDIR.TAG if it already exists

Cargo currently unconditionally writes `CACHEDIR.TAG` files even if they already exist.

This practice causes problems for build systems that disallow multiple writes to the same file.
2023-12-07 22:37:55 +00:00
Arlo Siemsen 04af5e7a06 Avoid writing CACHEDIR.TAG if it already exists 2023-12-07 14:51:01 -06:00
bors bdef274df2 Auto merge of #13130 - Byron:fix-flaky-tests, r=weihanglo
re-enable flaky tests thanks to update to `gix-config`. (#11821)

Related to #11821.

With `gix-config` now being fixed, it will properly respect `GIT_CONFIG_NOSYSTEM` both for system-wide configuration as well as for the git installation configuration.

That way, credential helpers provided by the git installation won't be called anymore, which prevents them from 'somehow' emitting information to stderr.

The latter was previously disabled for credential helpers, and despite [everything looking like it should work][1], it simply didn't.

[1]: https://github.com/rust-lang/cargo/pull/13117#issuecomment-1844881287
2023-12-07 19:15:12 +00:00
Chris Denton 6f7f927acf
Add a windows manifest file
This avoids the need for compatibility shims, sets the code page to UTF-8 and enables long path awareness.
2023-12-07 14:24:58 +00:00
bors 52b13207ae Auto merge of #13126 - lukas-code:bashcomp, r=weihanglo
fix bash completion in directory with spaces

### What does this PR try to resolve?

This PR fixes bash completion for `cargo run --bin <TAB>` when the path to the project contains a space.

### How should we test and review this PR?

1. create a project in a directory with a space, for example `mkdir '/tmp/has space' && cd '/tmp/has space' && cargo new foo && cd foo`.
2. add a binary to Cargo.toml, e.g.
   ```
   [[bin]]
   name = "bar"
   ```
3. on bash, type `cargo run --bin b` and press tab
4. observe error message `bash: $manifest: ambiguous redirect`, command is not completed
5. apply the fix to `$(rustc --print sysroot)/etc/bash_completion.d/cargo`
6. repeat step 3 and observe that the command is completed successfully
2023-12-07 12:59:41 +00:00
Sebastian Thiel 189de40a6f
re-enable flaky tests thanks to update to gix-config. (#11821)
With `gix-config` now being fixed, it will properly respect `GIT_CONFIG_NOSYSTEM`
both for system-wide configuration as well as for the git installation configuration.

That way, credential helpers provided by the git installation won't be called anymore,
which prevents them from 'somehow' emitting information to stderr.

The latter was previously disabled for credential helpers, and despite
everything^1 looking like it should work, it simply didn't.

[1]: https://github.com/rust-lang/cargo/pull/13117#issuecomment-1844881287
2023-12-07 10:19:07 +01:00
bors 64266c842b Auto merge of #13129 - weihanglo:ignore, r=epage
test: re-ignore git auth tests for gitoxide

Happened again in <https://github.com/rust-lang/cargo/pull/13126#issuecomment-1843886830>
even after #13117. Let's ignore them again and hope someday we can fix it :)
2023-12-07 02:31:09 +00:00
Weihang Lo 7ec1367973
test: re-ignore git auth tests for gitoxide 2023-12-06 20:18:22 -05:00
Ed Page d1b1cb184c refactor: Pull PackageIdSpec into schema 2023-12-06 16:26:41 -06:00
Ed Page 33d1d78a72 refactor: Move Id to Spec converter 2023-12-06 16:09:34 -06:00
bors 000d279306 Auto merge of #13125 - epage:public, r=weihanglo
fix(toml): Disallow inheriting of dependency public status

### What does this PR try to resolve?

This is a step towards rust-lang/rust#44663.  When discussing inheriting this field
for #13046, we realized that we should probably start by disallowing
inheritance.  We can always add it later.  imo the principle of what should
be inherited is what is truely common among dependencies.  For example,
we don't allow removing features.  Public should not be universally
applied and likely should be explicit so its not over-done, especially
since we can't (atm) lint for when a public dependency could be
non-public.

### How should we test and review this PR?

### Additional information

This reverts parts of #12817
2023-12-06 22:08:40 +00:00
Ed Page 294c3851e9 refactor: Pull out constructor for PackageIdSpec 2023-12-06 15:56:08 -06:00
Ed Page f3999d544f refactor(schema): Pull SourceKind out into schemas 2023-12-06 15:31:07 -06:00
Ed Page d7bcc0cd26 refactor(spec): Move queries to a extension trait
This is a step towards moving `PackageIdSpec` into `schema` as manifests
need it as part of #12801.

While I didn't take this approach in #13080, that was largely how core
these functions are / how pervasive their use is.
2023-12-06 14:56:22 -06:00
Lukas Markeffsky 5853e99782 prevent word splitting in bash completion script 2023-12-06 21:55:33 +01:00
bors 862e53a985 Auto merge of #13117 - Byron:enable-tests, r=weihanglo
re-enable previously disabled tests with Windows-specific fix

Related to #11821 for which this is a fix.
However, it's probably not yet the optimal solution, depending on how `stderr` of subprocesses should be handled.

### Tasks

* [x] try to fix the issue with an env var.
    - Failure, as one warning remains that seems to originate from a C# HTTP client
* [x] figure out if `stderr` should be on or off by default - on by default like before, but now one can control it.
* [x] create a new `gix` release and use it here

### Review Notes

* Personally, I think `cargo` should keep `stderr` to be inherited so users can see potentially relevant warnings or errors provided by credential helpers. Thus this is still the default, but the tests that need it explicitly disabled `stderr` of credential helpers.

----

On Windows, `gix` will call the `git-credential-manager, but with
`stderr` set to `inherit` which makes any errors visible to the user,
just like `git` does.

```
1   1         Updating git repository `https://foo.bar/foo/bar`
    2    +warning: auto-detection of host provider took too long (>2000ms)
    3    +warning: see https://aka.ms/gcm/autodetect for more information.
    4    +fatal: A task was canceled.
    5    +warning: auto-detection of host provider took too long (>2000ms)
    6    +warning: see https://aka.ms/gcm/autodetect for more information.`
````

This, however, isn't what's desirable in tests sometimes, nor may
it be desirable in Cargo.

For now, it seems easiest to disable this particular feature that
issues the warning messages, even though a future `gix` update
should allow to control what to do with `stderr`.
2023-12-06 19:04:36 +00:00
Sebastian Thiel 49c48b88cc
re-enable previously disabled tests (#11821)
On Windows, `gix` will call the `git-credential-manager, but with
`stderr` set to `inherit` it makes any errors visible to the user,
just like `git` does.

```
1   1         Updating git repository `https://foo.bar/foo/bar`
    2    +warning: auto-detection of host provider took too long (>2000ms)
    3    +warning: see https://aka.ms/gcm/autodetect for more information.
    4    +fatal: A task was canceled.
    5    +warning: auto-detection of host provider took too long (>2000ms)
    6    +warning: see https://aka.ms/gcm/autodetect for more information.`
````

This, however, isn't what's desirable in tests sometimes, nor may
it be desirable in Cargo.

In the latest version of `gix`, it's possible to control `stderr`
which is now set on a per-test basis.

Also note that for `cargo` as a whole the default didn't change,
and stderr of spawned helper programs will remain visible in the
enclosing terminal.
2023-12-06 17:09:17 +01:00
Sebastian Thiel 50c0005a28
upgrade gitoxide to v0.56 (#11821)
This release disables stderr for external programs by default, while
allowing to override these settings using configuration or environment
variables.
2023-12-06 17:09:08 +01:00
bors 403a7ace04 Auto merge of #13123 - epage:pure, r=weihanglo
refactor: Clarify PackageId constructor names

### What does this PR try to resolve?

From #13080

> I would love to see eithe rename this function or have a doc comment on it. It always puzzle me what pure means.

From my experience, `new` is more normally a name for more direct construction when there are alternatives

### How should we test and review this PR?

### Additional information
2023-12-06 15:46:23 +00:00
bors 9787229614 Auto merge of #12933 - epage:pkgid-spec, r=weihanglo
feat(spec): Extend PackageIdSpec with source kind + git ref for unambiguous specs

### What does this PR try to resolve?

This tries to add just enough information to Package ID Specs that we can be sure they are unambiguous.  On its own thats important but this will unblock #12914 so we can have a user-facing ID that can be used with cargo's CLI.

More specifically, this adds
- `git+`, etc prefixes to the scheme
  - These were previously stabilized for `cargo metadata`s source id urls
  - Like with `SourceID`, this will allow `PackageIDSpec` to generate `directory+` and `local-registry+` prefixes but not parse them.  I'm assuming that the layers where those are dealt with they won't appear here but I don't have enough experience with them
- git ref query strings for URLs

Things from `SourceID` that this does not include
- precise: this seems less related to matching (e.g. ignored for `impl Ord for SourceId`)
- canonical URL for git kinds: this could be nice for users but users aren't the target audience and we can switch to these later

Fixes #10256

### How should we test and review this PR?

Per-commit

### Additional information
2023-12-06 02:29:23 +00:00
bors 0124d280ff Auto merge of #13118 - weihanglo:object-works-macos, r=epage
test(trim-paths): assert `OSO` and `SO` cannot be trimmed
2023-12-06 01:50:28 +00:00
Ed Page 00557a2a77 fix(toml): Disallow inheriting of dependency public status
This is a step towards #44663.  When discussing inheriting this field
for #13046, we realized that we should probably start by disallowing
inheritance.  We can always add it later.  imo the principle of what should
be inherited is what is truely common among dependencies.  For example,
we don't allow removing features.  Public should not be universally
applied and likely should be explicit so its not over-done, especially
since we can't (atm) lint for when a public dependency could be
non-public.

This reverts parts of #12817
2023-12-05 17:00:01 -06:00
Ed Page 123289ba97 refactor(toml): Inline a bail's format parameter 2023-12-05 16:59:57 -06:00
Weihang Lo a4c607cde4
test(trim-paths): assert OSO and SO cannot be trimmed
See
* rust-lang/rust issue 117652
* rust-lang/rust issue 116948
2023-12-05 17:58:32 -05:00
bors a5fa676731 Auto merge of #13097 - epage:schemas, r=ehuss
refactor(schemas): Pull out mod for proposed schemas package

Originally for #12801 we talked about a `cargo-util-manifest-schema` package
- `util` in the name to not clash with plugins
- manifest specific to keep the scope down

The problem is we have types that aren't manifest specific, like
- `PartialVersion` (currently slated for `cargo-util-semverext`)
- `RustVersion`
- `PackageIdSpec`
- `SourceKind` (soon)

Things get messy if we try to break things down into common packages. Instead, I think it'd be useful to have a schemas package that has mods for each type of schema, re-exporting what is needed.

Normally, componentizing your package by the layer in the stack is a recipe for pain.
I don't think that'll apply here because these are meant to be so low level.

The other big concern could be compile times.  My hope is it won't be too bad.

So this moves the `util/toml` types into the module and we can add more in the future.
2023-12-05 00:15:22 +00:00
bors f88a44ab87 Auto merge of #13108 - linyihai:clean-optionals-tests, r=epage
chore(test): remove unnecesary packages and versions for `optionals` tests

### What does this PR try to resolve?

This PR was inspired by https://github.com/rust-lang/cargo/pull/13046#discussion_r1406387864 and https://github.com/rust-lang/cargo/pull/12189.

There is unnecessary to keep more pacakages and versions on test case and the more pacakage added, the more test time and CI resource taken up.

And this PR also fixed a issue that  `overwrite_optional_with_optional` had not been added to `tests/testsuite/cargo_add/mod.rs`.

### How should we test and review this PR?

### Additional information
2023-12-04 16:38:20 +00:00
Lin Yihai b7b036f3a1 Chore(test): remove unnecesary packages and versions for optionals tests 2023-12-04 11:25:38 +08:00
bors 9e9349d3f7 Auto merge of #13106 - rust-lang:renovate/migrate-config, r=weihanglo
chore(config): migrate renovate config

[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

The Renovate config in this repository needs migrating. Typically this is because one or more configuration options you are using have been renamed.

  You don't need to merge this PR right away, because Renovate will continue to migrate these fields internally each time it runs. But later some of these fields may be fully deprecated and the migrations removed. So it's a good idea to merge this migration PR soon.

#### [PLEASE NOTE](https://docs.renovatebot.com/configuration-options#configmigration): JSON5 config file migrated! All comments & trailing commas were removed.

🔕 **Ignore**: Close this PR and you won't be reminded about config migration again, but one day your current config may no longer be valid.

 Got questions? Does something look wrong to you? Please don't hesitate to [request help here](https://togithub.com/renovatebot/renovate/discussions).

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/rust-lang/cargo).
2023-12-03 13:58:13 +00:00
renovate[bot] 3e660a6421
chore(config): migrate config .github/renovate.json5 2023-12-03 08:53:53 -05:00
bors 623b788496 Auto merge of #13102 - weihanglo:book-redirect, r=ehuss
docs(book): make old title anchorable
2023-12-02 18:10:03 +00:00
bors 8854c4d90b Auto merge of #13101 - rust-lang:revert-13068-renovate/crate-openssl-vulnerability, r=ehuss
Revert "chore(deps): update rust crate openssl to 0.10.60 [security]"

Reverts https://github.com/rust-lang/cargo/pull/13068

`openssl@0.10.160` switches to OpenSSL v3,
which causes Cargo build failure on loongarch64.

See <https://github.com/rust-lang/rust/pull/118541#issuecomment-1837197918>
2023-12-02 17:41:16 +00:00
Weihang Lo 4af0e57253
docs(book): make old title anchorable
See https://github.com/rust-lang/blog.rust-lang.org/pull/1172
2023-12-02 11:55:57 -05:00
Weihang Lo df34bdd8d7
Revert "chore(deps): update rust crate openssl to 0.10.60 [security]"
Reverts rust-lang/cargo#13068

`openssl@0.10.160` switches to OpenSSL v3,
which causes Cargo build failure on loongarch64.

See <https://github.com/rust-lang/rust/pull/118541#issuecomment-1837197918>
2023-12-02 11:41:57 -05:00
bors 58fb231409 Auto merge of #13099 - weihanglo:running-binary, r=epage
test(install): use TCP connection instead of thread sleep
2023-12-02 14:15:16 +00:00
Weihang Lo 297b827fa3
test(install): use TCP connection instead of thread sleep
This is more robust than `thread::sleep`, ensuring

* foo is running before the first `cargo uninstall` call
* foo is stopped before the second `cargo uninstall` call
2023-12-02 01:54:20 -05:00
bors f023d057e1 Auto merge of #13098 - epage:snap, r=weihanglo
test(mdman): Switch to snapbox

Working with #13090 is the motivation

Benefits
- We use it elsewhere
- We don't have to bake in our own snapshotting solution
- It is more obvious how to update the snapshots
2023-12-01 22:29:51 +00:00
bors aa6e46e8ca Auto merge of #13012 - Urgau:check-cfg-fingerprint, r=epage
Include declared list of features in fingerprint for `-Zcheck-cfg`

This PR include the declared list of features in fingerprint for `-Zcheck-cfg` (#10554)

`--check-cfg` verifies that `#[cfg()]` attributes are valid in Rust code, which includes `--cfg features foo` definitions that came from `[features]` tables in `Cargo.toml`.  For us to correctly re-check cfgs on feature changes,we need to include them in the fingerprint.

For example, if a user deletes an entry from `[features]`, they should then get warnings about any `#[cfg()]` attributes left in the code.  Without this change, that won't happen.  With this change, it now does.
2023-12-01 21:46:28 +00:00