Skip to content

Rollup of 8 pull requests #140273

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

Merged
merged 25 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0340a86
Add test for doctest runtool
ehuss Feb 15, 2025
ec25e33
Rename `--runtool` and `--runtool-arg`
ehuss Feb 15, 2025
6441701
Stabilize --test-runtool and --test-runtool-arg
ehuss Feb 15, 2025
7251b46
Remove and stabilize --enable-per-target-ignores
ehuss Feb 15, 2025
af2b4b9
Show an example of using multiple ignore attributes
ehuss Mar 28, 2025
f535922
Try to more clearly specify exactly what the runtool flags do
ehuss Mar 28, 2025
115341f
Fix grammar of --test-runtool-arg help text
ehuss Apr 14, 2025
fdf2c47
[AIX] Handle AIX dynamic library extensions within c-link-to-rust-dyl…
amy-kwan Apr 23, 2025
d88056c
Derive `HashStable` for `DelimArgs`.
nnethercote Apr 23, 2025
7fe6bc5
Use `clone` to clone `DelimArgs` in two places.
nnethercote Apr 23, 2025
18c3370
CI: use aws codebuild for job dist-arm-linux
marcoieni Apr 23, 2025
d2120e6
Work around cygwin issue on timeout
Berrysoft Apr 23, 2025
c9deaf6
fix for issue 135412
Kivooeo Apr 23, 2025
a224942
mention about `x.py setup` in `INSTALL.md`
onur-ozkan Apr 23, 2025
1feccc1
Make impl item info come before doc
GuillaumeGomez Apr 24, 2025
7a895bd
Fix indent of impl docs
GuillaumeGomez Apr 24, 2025
a29072a
Add/update GUI test for impl indent fix
GuillaumeGomez Apr 24, 2025
610ed82
Rollup merge of #137096 - ehuss:stabilize-doctest-xcompile, r=fmease
matthiaskrgr Apr 24, 2025
7ba71d3
Rollup merge of #140148 - marcoieni:ci-aws-codebuild, r=Kobzol
matthiaskrgr Apr 24, 2025
4c0d38b
Rollup merge of #140187 - amy-kwan:amy-kwan/update_runmake_tests_AIX,…
matthiaskrgr Apr 24, 2025
02ebca2
Rollup merge of #140196 - Kivooeo:new-fix-two, r=wesleywiser
matthiaskrgr Apr 24, 2025
11fbbc5
Rollup merge of #140210 - Berrysoft:cygwin-timedwait, r=joboet
matthiaskrgr Apr 24, 2025
ee7766a
Rollup merge of #140213 - onur-ozkan:x-setup, r=cuviper
matthiaskrgr Apr 24, 2025
c43022f
Rollup merge of #140229 - nnethercote:pre-DelimArgs-spacing, r=petroc…
matthiaskrgr Apr 24, 2025
bc25dc2
Rollup merge of #140248 - GuillaumeGomez:fix-impl-block-items-indent,…
matthiaskrgr Apr 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ jobs:
# Check the `calculate_matrix` job to see how is the matrix defined.
include: ${{ fromJSON(needs.calculate_matrix.outputs.jobs) }}
steps:
- name: Install cargo in AWS CodeBuild
if: matrix.codebuild
run: |
# Check if cargo is installed
if ! command -v cargo &> /dev/null; then
echo "Cargo not found, installing Rust..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal
# Make cargo available in PATH
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
fi
- name: disable git crlf conversion
run: git config --global core.autocrlf false

Expand Down Expand Up @@ -165,6 +176,8 @@ jobs:
run: src/ci/scripts/install-ninja.sh

- name: enable ipv6 on Docker
# Don't run on codebuild because systemctl is not available
if: ${{ !matrix.codebuild }}
run: src/ci/scripts/enable-docker-ipv6.sh

# Disable automatic line ending conversion (again). On Windows, when we're
Expand Down
25 changes: 24 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,31 @@ See [the rustc-dev-guide for more info][sysllvm].

2. Configure the build settings:

If you're unsure which build configurations to use and need a good default, you
can run the interactive `x.py setup` command. This will guide you through selecting
a config profile, setting up the LSP, configuring a Git hook, etc.

With `configure` script, you can handle multiple configurations in a single
command which is useful to create complex/advanced config files. For example:

```sh
./configure
./configure --build=aarch64-unknown-linux-gnu \
--enable-full-tools \
--enable-profiler \
--enable-sanitizers \
--enable-compiler-docs \
--set target.aarch64-unknown-linux-gnu.linker=clang \
--set target.aarch64-unknown-linux-gnu.ar=/rustroot/bin/llvm-ar \
--set target.aarch64-unknown-linux-gnu.ranlib=/rustroot/bin/llvm-ranlib \
--set llvm.link-shared=true \
--set llvm.thin-lto=true \
--set llvm.libzstd=true \
--set llvm.ninja=false \
--set rust.debug-assertions=false \
--set rust.jemalloc \
--set rust.use-lld=true \
--set rust.lto=thin \
--set rust.codegen-units=1
```

If you plan to use `x.py install` to create an installation, you can either
Expand Down
14 changes: 1 addition & 13 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,7 @@ impl AttrArgs {
}

/// Delimited arguments, as used in `#[attr()/[]/{}]` or `mac!()/[]/{}`.
#[derive(Clone, Encodable, Decodable, Debug)]
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
pub struct DelimArgs {
pub dspan: DelimSpan,
pub delim: Delimiter, // Note: `Delimiter::Invisible` never occurs
Expand All @@ -1942,18 +1942,6 @@ impl DelimArgs {
}
}

impl<CTX> HashStable<CTX> for DelimArgs
where
CTX: crate::HashStableContext,
{
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
let DelimArgs { dspan, delim, tokens } = self;
dspan.hash_stable(ctx, hasher);
delim.hash_stable(ctx, hasher);
tokens.hash_stable(ctx, hasher);
}
}

/// Represents a macro definition.
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
pub struct MacroDef {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}

fn lower_delim_args(&self, args: &DelimArgs) -> DelimArgs {
DelimArgs { dspan: args.dspan, delim: args.delim, tokens: args.tokens.clone() }
args.clone()
}

/// Lower an associated item constraint.
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::BTreeMap;
use std::ops::Deref;
use std::sync::LazyLock;

use rustc_ast::{self as ast, DelimArgs};
use rustc_ast as ast;
use rustc_attr_data_structures::AttributeKind;
use rustc_errors::{DiagCtxtHandle, Diagnostic};
use rustc_feature::Features;
Expand Down Expand Up @@ -315,11 +315,7 @@ impl<'sess> AttributeParser<'sess> {
fn lower_attr_args(&self, args: &ast::AttrArgs, lower_span: impl Fn(Span) -> Span) -> AttrArgs {
match args {
ast::AttrArgs::Empty => AttrArgs::Empty,
ast::AttrArgs::Delimited(args) => AttrArgs::Delimited(DelimArgs {
dspan: args.dspan,
delim: args.delim,
tokens: args.tokens.clone(),
}),
ast::AttrArgs::Delimited(args) => AttrArgs::Delimited(args.clone()),
// This is an inert key-value attribute - it will never be visible to macros
// after it gets lowered to HIR. Therefore, we can extract literals to handle
// nonterminals in `#[doc]` (e.g. `#[doc = $e]`).
Expand Down
25 changes: 19 additions & 6 deletions compiler/rustc_hir_typeck/src/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,25 @@ impl<'a, 'tcx> CastCheck<'tcx> {
.must_apply_modulo_regions()
{
label = false;
err.span_suggestion(
self.span,
"consider using the `From` trait instead",
format!("{}::from({})", self.cast_ty, snippet),
Applicability::MaybeIncorrect,
);
if let ty::Adt(def, args) = self.cast_ty.kind() {
err.span_suggestion_verbose(
self.span,
"consider using the `From` trait instead",
format!(
"{}::from({})",
fcx.tcx.value_path_str_with_args(def.did(), args),
snippet
),
Applicability::MaybeIncorrect,
);
} else {
err.span_suggestion(
self.span,
"consider using the `From` trait instead",
format!("{}::from({})", self.cast_ty, snippet),
Applicability::MaybeIncorrect,
);
};
}
}

Expand Down
5 changes: 4 additions & 1 deletion library/std/src/sys/pal/unix/sync/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ impl Condvar {
// https://gist.github.com/stepancheg/198db4623a20aad2ad7cddb8fda4a63c
//
// To work around this issue, the timeout is clamped to 1000 years.
#[cfg(target_vendor = "apple")]
//
// Cygwin implementation is based on NT API and a super large timeout
// makes the syscall block forever.
#[cfg(any(target_vendor = "apple", target_os = "cygwin"))]
let dur = Duration::min(dur, Duration::from_secs(1000 * 365 * 86400));

let timeout = Timespec::now(Self::CLOCK).checked_add_duration(&dur);
Expand Down
33 changes: 32 additions & 1 deletion src/ci/citool/src/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ mod tests;

use std::collections::BTreeMap;

use anyhow::Context as _;
use serde_yaml::Value;

use crate::GitHubContext;
use crate::utils::load_env_var;

/// Representation of a job loaded from the `src/ci/github-actions/jobs.yml` file.
#[derive(serde::Deserialize, Debug, Clone)]
#[serde(deny_unknown_fields)]
pub struct Job {
/// Name of the job, e.g. mingw-check
pub name: String,
Expand All @@ -26,6 +29,8 @@ pub struct Job {
pub free_disk: Option<bool>,
/// Documentation link to a resource that could help people debug this CI job.
pub doc_url: Option<String>,
/// Whether the job is executed on AWS CodeBuild.
pub codebuild: Option<bool>,
}

impl Job {
Expand Down Expand Up @@ -80,7 +85,7 @@ impl JobDatabase {
}

pub fn load_job_db(db: &str) -> anyhow::Result<JobDatabase> {
let mut db: Value = serde_yaml::from_str(&db)?;
let mut db: Value = serde_yaml::from_str(db)?;

// We need to expand merge keys (<<), because serde_yaml can't deal with them
// `apply_merge` only applies the merge once, so do it a few times to unwrap nested merges.
Expand All @@ -107,6 +112,29 @@ struct GithubActionsJob {
free_disk: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
doc_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
codebuild: Option<bool>,
}

/// Replace GitHub context variables with environment variables in job configs.
/// Used for codebuild jobs like
/// `codebuild-ubuntu-22-8c-$github.run_id-$github.run_attempt`
fn substitute_github_vars(jobs: Vec<Job>) -> anyhow::Result<Vec<Job>> {
let run_id = load_env_var("GITHUB_RUN_ID")?;
let run_attempt = load_env_var("GITHUB_RUN_ATTEMPT")?;

let jobs = jobs
.into_iter()
.map(|mut job| {
job.os = job
.os
.replace("$github.run_id", &run_id)
.replace("$github.run_attempt", &run_attempt);
job
})
.collect();

Ok(jobs)
}

/// Skip CI jobs that are not supposed to be executed on the given `channel`.
Expand Down Expand Up @@ -177,6 +205,8 @@ fn calculate_jobs(
}
RunType::AutoJob => (db.auto_jobs.clone(), "auto", &db.envs.auto_env),
};
let jobs = substitute_github_vars(jobs.clone())
.context("Failed to substitute GitHub context variables in jobs")?;
let jobs = skip_jobs(jobs, channel);
let jobs = jobs
.into_iter()
Expand Down Expand Up @@ -207,6 +237,7 @@ fn calculate_jobs(
continue_on_error: job.continue_on_error,
free_disk: job.free_disk,
doc_url: job.doc_url,
codebuild: job.codebuild,
}
})
.collect();
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/host-x86_64/dist-arm-linux/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:22.04
FROM ghcr.io/rust-lang/ubuntu:22.04

COPY scripts/cross-apt-packages.sh /scripts/
RUN sh /scripts/cross-apt-packages.sh
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ args="$args --privileged"
# `LOCAL_USER_ID` (recognized in `src/ci/run.sh`) to ensure that files are all
# read/written as the same user as the bare-metal user.
if [ -f /.dockerenv ]; then
docker create -v /checkout --name checkout alpine:3.4 /bin/true
docker create -v /checkout --name checkout ghcr.io/rust-lang/alpine:3.4 /bin/true
docker cp . checkout:/checkout
args="$args --volumes-from checkout"
else
Expand Down
11 changes: 10 additions & 1 deletion src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ runners:
- &job-aarch64-linux-8c
os: ubuntu-24.04-arm64-8core-32gb
<<: *base-job

# Codebuild runners are provisioned in
# https://github.com/rust-lang/simpleinfra/blob/b7ddd5e6bec8a93ec30510cdddec02c5666fefe9/terragrunt/accounts/ci-prod/ci-runners/terragrunt.hcl#L2
- &job-linux-36c-codebuild
free_disk: true
codebuild: true
os: codebuild-ubuntu-22-36c-$github.run_id-$github.run_attempt
<<: *base-job

envs:
env-x86_64-apple-tests: &env-x86_64-apple-tests
SCRIPT: ./x.py check compiletest --set build.compiletest-use-stage0-libtest=true && ./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc -- --exact
Expand Down Expand Up @@ -151,7 +160,7 @@ auto:
<<: *job-linux-4c

- name: dist-arm-linux
<<: *job-linux-8c
<<: *job-linux-36c-codebuild

- name: dist-armhf-linux
<<: *job-linux-4c
Expand Down
43 changes: 34 additions & 9 deletions src/ci/scripts/free-disk-space.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ isX86() {
fi
}

# Check if we're on a GitHub hosted runner.
# In aws codebuild, the variable RUNNER_ENVIRONMENT is "self-hosted".
isGitHubRunner() {
# `:-` means "use the value of RUNNER_ENVIRONMENT if it exists, otherwise use an empty string".
if [[ "${RUNNER_ENVIRONMENT:-}" == "github-hosted" ]]; then
return 0
else
return 1
fi
}

# print a line of the specified character
printSeparationLine() {
for ((i = 0; i < 80; i++)); do
Expand All @@ -32,7 +43,7 @@ getAvailableSpace() {
# make Kb human readable (assume the input is Kb)
# REF: https://unix.stackexchange.com/a/44087/60849
formatByteCount() {
numfmt --to=iec-i --suffix=B --padding=7 "$1"'000'
numfmt --to=iec-i --suffix=B --padding=7 "${1}000"
}

# macro to output saved space
Expand All @@ -45,6 +56,11 @@ printSavedSpace() {
after=$(getAvailableSpace)
local saved=$((after - before))

if [ "$saved" -lt 0 ]; then
echo "::warning::Saved space is negative: $saved. Using '0' as saved space."
saved=0
fi

echo ""
printSeparationLine "*"
if [ -n "${title}" ]; then
Expand Down Expand Up @@ -118,10 +134,14 @@ removeUnusedFilesAndDirs() {
# Azure
"/opt/az"
"/usr/share/az_"*
)

if [ -n "${AGENT_TOOLSDIRECTORY:-}" ]; then
# Environment variable set by GitHub Actions
"$AGENT_TOOLSDIRECTORY"
)
to_remove+=(
"${AGENT_TOOLSDIRECTORY}"
)
fi

for element in "${to_remove[@]}"; do
if [ ! -e "$element" ]; then
Expand Down Expand Up @@ -155,20 +175,25 @@ cleanPackages() {
'^dotnet-.*'
'^llvm-.*'
'^mongodb-.*'
'azure-cli'
'firefox'
'libgl1-mesa-dri'
'mono-devel'
'php.*'
)

if isX86; then
if isGitHubRunner; then
packages+=(
'google-chrome-stable'
'google-cloud-cli'
'google-cloud-sdk'
'powershell'
azure-cli
)

if isX86; then
packages+=(
'google-chrome-stable'
'google-cloud-cli'
'google-cloud-sdk'
'powershell'
)
fi
fi

sudo apt-get -qq remove -y --fix-missing "${packages[@]}"
Expand Down
Loading
Loading