Skip to content

Commit 5c54aa7

Browse files
committed
Auto merge of #140273 - matthiaskrgr:rollup-rxmuvkg, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #137096 (Stabilize flags for doctest cross compilation) - #140148 (CI: use aws codebuild for job dist-arm-linux) - #140187 ([AIX] Handle AIX dynamic library extensions within c-link-to-rust-dylib run-make test) - #140196 (Improved diagnostics for non-primitive cast on non-primitive types (`Arc`, `Option`)) - #140210 (Work around cygwin issue on condvar timeout) - #140213 (mention about `x.py setup` in `INSTALL.md`) - #140229 (`DelimArgs` tweaks) - #140248 (Fix impl block items indent) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 862156d + bc25dc2 commit 5c54aa7

File tree

41 files changed

+399
-194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+399
-194
lines changed

.github/workflows/ci.yml

+13
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ jobs:
9191
# Check the `calculate_matrix` job to see how is the matrix defined.
9292
include: ${{ fromJSON(needs.calculate_matrix.outputs.jobs) }}
9393
steps:
94+
- name: Install cargo in AWS CodeBuild
95+
if: matrix.codebuild
96+
run: |
97+
# Check if cargo is installed
98+
if ! command -v cargo &> /dev/null; then
99+
echo "Cargo not found, installing Rust..."
100+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal
101+
# Make cargo available in PATH
102+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
103+
fi
104+
94105
- name: disable git crlf conversion
95106
run: git config --global core.autocrlf false
96107

@@ -165,6 +176,8 @@ jobs:
165176
run: src/ci/scripts/install-ninja.sh
166177

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

170183
# Disable automatic line ending conversion (again). On Windows, when we're

INSTALL.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,31 @@ See [the rustc-dev-guide for more info][sysllvm].
7575

7676
2. Configure the build settings:
7777

78+
If you're unsure which build configurations to use and need a good default, you
79+
can run the interactive `x.py setup` command. This will guide you through selecting
80+
a config profile, setting up the LSP, configuring a Git hook, etc.
81+
82+
With `configure` script, you can handle multiple configurations in a single
83+
command which is useful to create complex/advanced config files. For example:
84+
7885
```sh
79-
./configure
86+
./configure --build=aarch64-unknown-linux-gnu \
87+
--enable-full-tools \
88+
--enable-profiler \
89+
--enable-sanitizers \
90+
--enable-compiler-docs \
91+
--set target.aarch64-unknown-linux-gnu.linker=clang \
92+
--set target.aarch64-unknown-linux-gnu.ar=/rustroot/bin/llvm-ar \
93+
--set target.aarch64-unknown-linux-gnu.ranlib=/rustroot/bin/llvm-ranlib \
94+
--set llvm.link-shared=true \
95+
--set llvm.thin-lto=true \
96+
--set llvm.libzstd=true \
97+
--set llvm.ninja=false \
98+
--set rust.debug-assertions=false \
99+
--set rust.jemalloc \
100+
--set rust.use-lld=true \
101+
--set rust.lto=thin \
102+
--set rust.codegen-units=1
80103
```
81104

82105
If you plan to use `x.py install` to create an installation, you can either

compiler/rustc_ast/src/ast.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -1927,7 +1927,7 @@ impl AttrArgs {
19271927
}
19281928

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

1945-
impl<CTX> HashStable<CTX> for DelimArgs
1946-
where
1947-
CTX: crate::HashStableContext,
1948-
{
1949-
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
1950-
let DelimArgs { dspan, delim, tokens } = self;
1951-
dspan.hash_stable(ctx, hasher);
1952-
delim.hash_stable(ctx, hasher);
1953-
tokens.hash_stable(ctx, hasher);
1954-
}
1955-
}
1956-
19571945
/// Represents a macro definition.
19581946
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
19591947
pub struct MacroDef {

compiler/rustc_ast_lowering/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
916916
}
917917

918918
fn lower_delim_args(&self, args: &DelimArgs) -> DelimArgs {
919-
DelimArgs { dspan: args.dspan, delim: args.delim, tokens: args.tokens.clone() }
919+
args.clone()
920920
}
921921

922922
/// Lower an associated item constraint.

compiler/rustc_attr_parsing/src/context.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::collections::BTreeMap;
33
use std::ops::Deref;
44
use std::sync::LazyLock;
55

6-
use rustc_ast::{self as ast, DelimArgs};
6+
use rustc_ast as ast;
77
use rustc_attr_data_structures::AttributeKind;
88
use rustc_errors::{DiagCtxtHandle, Diagnostic};
99
use rustc_feature::Features;
@@ -315,11 +315,7 @@ impl<'sess> AttributeParser<'sess> {
315315
fn lower_attr_args(&self, args: &ast::AttrArgs, lower_span: impl Fn(Span) -> Span) -> AttrArgs {
316316
match args {
317317
ast::AttrArgs::Empty => AttrArgs::Empty,
318-
ast::AttrArgs::Delimited(args) => AttrArgs::Delimited(DelimArgs {
319-
dspan: args.dspan,
320-
delim: args.delim,
321-
tokens: args.tokens.clone(),
322-
}),
318+
ast::AttrArgs::Delimited(args) => AttrArgs::Delimited(args.clone()),
323319
// This is an inert key-value attribute - it will never be visible to macros
324320
// after it gets lowered to HIR. Therefore, we can extract literals to handle
325321
// nonterminals in `#[doc]` (e.g. `#[doc = $e]`).

compiler/rustc_hir_typeck/src/cast.rs

+19-6
Original file line numberDiff line numberDiff line change
@@ -501,12 +501,25 @@ impl<'a, 'tcx> CastCheck<'tcx> {
501501
.must_apply_modulo_regions()
502502
{
503503
label = false;
504-
err.span_suggestion(
505-
self.span,
506-
"consider using the `From` trait instead",
507-
format!("{}::from({})", self.cast_ty, snippet),
508-
Applicability::MaybeIncorrect,
509-
);
504+
if let ty::Adt(def, args) = self.cast_ty.kind() {
505+
err.span_suggestion_verbose(
506+
self.span,
507+
"consider using the `From` trait instead",
508+
format!(
509+
"{}::from({})",
510+
fcx.tcx.value_path_str_with_args(def.did(), args),
511+
snippet
512+
),
513+
Applicability::MaybeIncorrect,
514+
);
515+
} else {
516+
err.span_suggestion(
517+
self.span,
518+
"consider using the `From` trait instead",
519+
format!("{}::from({})", self.cast_ty, snippet),
520+
Applicability::MaybeIncorrect,
521+
);
522+
};
510523
}
511524
}
512525

library/std/src/sys/pal/unix/sync/condvar.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ impl Condvar {
6464
// https://gist.github.com/stepancheg/198db4623a20aad2ad7cddb8fda4a63c
6565
//
6666
// To work around this issue, the timeout is clamped to 1000 years.
67-
#[cfg(target_vendor = "apple")]
67+
//
68+
// Cygwin implementation is based on NT API and a super large timeout
69+
// makes the syscall block forever.
70+
#[cfg(any(target_vendor = "apple", target_os = "cygwin"))]
6871
let dur = Duration::min(dur, Duration::from_secs(1000 * 365 * 86400));
6972

7073
let timeout = Timespec::now(Self::CLOCK).checked_add_duration(&dur);

src/ci/citool/src/jobs.rs

+32-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ mod tests;
33

44
use std::collections::BTreeMap;
55

6+
use anyhow::Context as _;
67
use serde_yaml::Value;
78

89
use crate::GitHubContext;
10+
use crate::utils::load_env_var;
911

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

3136
impl Job {
@@ -80,7 +85,7 @@ impl JobDatabase {
8085
}
8186

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

8590
// We need to expand merge keys (<<), because serde_yaml can't deal with them
8691
// `apply_merge` only applies the merge once, so do it a few times to unwrap nested merges.
@@ -107,6 +112,29 @@ struct GithubActionsJob {
107112
free_disk: Option<bool>,
108113
#[serde(skip_serializing_if = "Option::is_none")]
109114
doc_url: Option<String>,
115+
#[serde(skip_serializing_if = "Option::is_none")]
116+
codebuild: Option<bool>,
117+
}
118+
119+
/// Replace GitHub context variables with environment variables in job configs.
120+
/// Used for codebuild jobs like
121+
/// `codebuild-ubuntu-22-8c-$github.run_id-$github.run_attempt`
122+
fn substitute_github_vars(jobs: Vec<Job>) -> anyhow::Result<Vec<Job>> {
123+
let run_id = load_env_var("GITHUB_RUN_ID")?;
124+
let run_attempt = load_env_var("GITHUB_RUN_ATTEMPT")?;
125+
126+
let jobs = jobs
127+
.into_iter()
128+
.map(|mut job| {
129+
job.os = job
130+
.os
131+
.replace("$github.run_id", &run_id)
132+
.replace("$github.run_attempt", &run_attempt);
133+
job
134+
})
135+
.collect();
136+
137+
Ok(jobs)
110138
}
111139

112140
/// Skip CI jobs that are not supposed to be executed on the given `channel`.
@@ -177,6 +205,8 @@ fn calculate_jobs(
177205
}
178206
RunType::AutoJob => (db.auto_jobs.clone(), "auto", &db.envs.auto_env),
179207
};
208+
let jobs = substitute_github_vars(jobs.clone())
209+
.context("Failed to substitute GitHub context variables in jobs")?;
180210
let jobs = skip_jobs(jobs, channel);
181211
let jobs = jobs
182212
.into_iter()
@@ -207,6 +237,7 @@ fn calculate_jobs(
207237
continue_on_error: job.continue_on_error,
208238
free_disk: job.free_disk,
209239
doc_url: job.doc_url,
240+
codebuild: job.codebuild,
210241
}
211242
})
212243
.collect();

src/ci/docker/host-x86_64/dist-arm-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.04
1+
FROM ghcr.io/rust-lang/ubuntu:22.04
22

33
COPY scripts/cross-apt-packages.sh /scripts/
44
RUN sh /scripts/cross-apt-packages.sh

src/ci/docker/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ args="$args --privileged"
288288
# `LOCAL_USER_ID` (recognized in `src/ci/run.sh`) to ensure that files are all
289289
# read/written as the same user as the bare-metal user.
290290
if [ -f /.dockerenv ]; then
291-
docker create -v /checkout --name checkout alpine:3.4 /bin/true
291+
docker create -v /checkout --name checkout ghcr.io/rust-lang/alpine:3.4 /bin/true
292292
docker cp . checkout:/checkout
293293
args="$args --volumes-from checkout"
294294
else

src/ci/github-actions/jobs.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ runners:
5656
- &job-aarch64-linux-8c
5757
os: ubuntu-24.04-arm64-8core-32gb
5858
<<: *base-job
59+
60+
# Codebuild runners are provisioned in
61+
# https://github.com/rust-lang/simpleinfra/blob/b7ddd5e6bec8a93ec30510cdddec02c5666fefe9/terragrunt/accounts/ci-prod/ci-runners/terragrunt.hcl#L2
62+
- &job-linux-36c-codebuild
63+
free_disk: true
64+
codebuild: true
65+
os: codebuild-ubuntu-22-36c-$github.run_id-$github.run_attempt
66+
<<: *base-job
67+
5968
envs:
6069
env-x86_64-apple-tests: &env-x86_64-apple-tests
6170
SCRIPT: ./x.py check compiletest --set build.compiletest-use-stage0-libtest=true && ./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc -- --exact
@@ -151,7 +160,7 @@ auto:
151160
<<: *job-linux-4c
152161

153162
- name: dist-arm-linux
154-
<<: *job-linux-8c
163+
<<: *job-linux-36c-codebuild
155164

156165
- name: dist-armhf-linux
157166
<<: *job-linux-4c

src/ci/scripts/free-disk-space.sh

+34-9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ isX86() {
1414
fi
1515
}
1616

17+
# Check if we're on a GitHub hosted runner.
18+
# In aws codebuild, the variable RUNNER_ENVIRONMENT is "self-hosted".
19+
isGitHubRunner() {
20+
# `:-` means "use the value of RUNNER_ENVIRONMENT if it exists, otherwise use an empty string".
21+
if [[ "${RUNNER_ENVIRONMENT:-}" == "github-hosted" ]]; then
22+
return 0
23+
else
24+
return 1
25+
fi
26+
}
27+
1728
# print a line of the specified character
1829
printSeparationLine() {
1930
for ((i = 0; i < 80; i++)); do
@@ -32,7 +43,7 @@ getAvailableSpace() {
3243
# make Kb human readable (assume the input is Kb)
3344
# REF: https://unix.stackexchange.com/a/44087/60849
3445
formatByteCount() {
35-
numfmt --to=iec-i --suffix=B --padding=7 "$1"'000'
46+
numfmt --to=iec-i --suffix=B --padding=7 "${1}000"
3647
}
3748

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

59+
if [ "$saved" -lt 0 ]; then
60+
echo "::warning::Saved space is negative: $saved. Using '0' as saved space."
61+
saved=0
62+
fi
63+
4864
echo ""
4965
printSeparationLine "*"
5066
if [ -n "${title}" ]; then
@@ -118,10 +134,14 @@ removeUnusedFilesAndDirs() {
118134
# Azure
119135
"/opt/az"
120136
"/usr/share/az_"*
137+
)
121138

139+
if [ -n "${AGENT_TOOLSDIRECTORY:-}" ]; then
122140
# Environment variable set by GitHub Actions
123-
"$AGENT_TOOLSDIRECTORY"
124-
)
141+
to_remove+=(
142+
"${AGENT_TOOLSDIRECTORY}"
143+
)
144+
fi
125145

126146
for element in "${to_remove[@]}"; do
127147
if [ ! -e "$element" ]; then
@@ -155,20 +175,25 @@ cleanPackages() {
155175
'^dotnet-.*'
156176
'^llvm-.*'
157177
'^mongodb-.*'
158-
'azure-cli'
159178
'firefox'
160179
'libgl1-mesa-dri'
161180
'mono-devel'
162181
'php.*'
163182
)
164183

165-
if isX86; then
184+
if isGitHubRunner; then
166185
packages+=(
167-
'google-chrome-stable'
168-
'google-cloud-cli'
169-
'google-cloud-sdk'
170-
'powershell'
186+
azure-cli
171187
)
188+
189+
if isX86; then
190+
packages+=(
191+
'google-chrome-stable'
192+
'google-cloud-cli'
193+
'google-cloud-sdk'
194+
'powershell'
195+
)
196+
fi
172197
fi
173198

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

0 commit comments

Comments
 (0)