Skip to content
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

[beta] backports #131423

Merged
merged 9 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
[submodule "src/llvm-project"]
path = src/llvm-project
url = https://github.com/rust-lang/llvm-project.git
branch = rustc/19.1-2024-07-30
branch = rustc/19.1-2024-09-17
shallow = true
[submodule "src/doc/embedded-book"]
path = src/doc/embedded-book
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn parse_cfg<'a>(cx: &ExtCtxt<'a>, span: Span, tts: TokenStream) -> PResult<'a,
return Err(cx.dcx().create_err(errors::RequiresCfgPattern { span }));
}

let cfg = p.parse_meta_item(AllowLeadingUnsafe::Yes)?;
let cfg = p.parse_meta_item(AllowLeadingUnsafe::No)?;

let _ = p.eat(&token::Comma);

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2493,7 +2493,7 @@ fn add_order_independent_options(
}
}

cmd.set_output_kind(link_output_kind, out_filename);
cmd.set_output_kind(link_output_kind, crate_type, out_filename);

add_relro_args(cmd, sess);

Expand Down
83 changes: 69 additions & 14 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,12 @@ pub trait Linker {
fn is_cc(&self) -> bool {
false
}
fn set_output_kind(&mut self, output_kind: LinkOutputKind, out_filename: &Path);
fn set_output_kind(
&mut self,
output_kind: LinkOutputKind,
crate_type: CrateType,
out_filename: &Path,
);
fn link_dylib_by_name(&mut self, _name: &str, _verbatim: bool, _as_needed: bool) {
bug!("dylib linked with unsupported linker")
}
Expand Down Expand Up @@ -387,7 +392,7 @@ impl<'a> GccLinker<'a> {
]);
}

fn build_dylib(&mut self, out_filename: &Path) {
fn build_dylib(&mut self, crate_type: CrateType, out_filename: &Path) {
// On mac we need to tell the linker to let this library be rpathed
if self.sess.target.is_like_osx {
if !self.is_ld {
Expand Down Expand Up @@ -418,7 +423,7 @@ impl<'a> GccLinker<'a> {
let mut out_implib = OsString::from("--out-implib=");
out_implib.push(out_filename.with_file_name(implib_name));
self.link_arg(out_implib);
} else {
} else if crate_type == CrateType::Dylib {
// When dylibs are linked by a full path this value will get into `DT_NEEDED`
// instead of the full path, so the library can be later found in some other
// location than that specific path.
Expand Down Expand Up @@ -465,7 +470,12 @@ impl<'a> Linker for GccLinker<'a> {
!self.is_ld
}

fn set_output_kind(&mut self, output_kind: LinkOutputKind, out_filename: &Path) {
fn set_output_kind(
&mut self,
output_kind: LinkOutputKind,
crate_type: CrateType,
out_filename: &Path,
) {
match output_kind {
LinkOutputKind::DynamicNoPicExe => {
if !self.is_ld && self.is_gnu {
Expand Down Expand Up @@ -500,10 +510,10 @@ impl<'a> Linker for GccLinker<'a> {
self.link_args(&["-static", "-pie", "--no-dynamic-linker", "-z", "text"]);
}
}
LinkOutputKind::DynamicDylib => self.build_dylib(out_filename),
LinkOutputKind::DynamicDylib => self.build_dylib(crate_type, out_filename),
LinkOutputKind::StaticDylib => {
self.link_or_cc_arg("-static");
self.build_dylib(out_filename);
self.build_dylib(crate_type, out_filename);
}
LinkOutputKind::WasiReactorExe => {
self.link_args(&["--entry", "_initialize"]);
Expand Down Expand Up @@ -859,7 +869,12 @@ impl<'a> Linker for MsvcLinker<'a> {
&mut self.cmd
}

fn set_output_kind(&mut self, output_kind: LinkOutputKind, out_filename: &Path) {
fn set_output_kind(
&mut self,
output_kind: LinkOutputKind,
_crate_type: CrateType,
out_filename: &Path,
) {
match output_kind {
LinkOutputKind::DynamicNoPicExe
| LinkOutputKind::DynamicPicExe
Expand Down Expand Up @@ -1111,7 +1126,13 @@ impl<'a> Linker for EmLinker<'a> {
true
}

fn set_output_kind(&mut self, _output_kind: LinkOutputKind, _out_filename: &Path) {}
fn set_output_kind(
&mut self,
_output_kind: LinkOutputKind,
_crate_type: CrateType,
_out_filename: &Path,
) {
}

fn link_dylib_by_name(&mut self, name: &str, _verbatim: bool, _as_needed: bool) {
// Emscripten always links statically
Expand Down Expand Up @@ -1260,7 +1281,12 @@ impl<'a> Linker for WasmLd<'a> {
&mut self.cmd
}

fn set_output_kind(&mut self, output_kind: LinkOutputKind, _out_filename: &Path) {
fn set_output_kind(
&mut self,
output_kind: LinkOutputKind,
_crate_type: CrateType,
_out_filename: &Path,
) {
match output_kind {
LinkOutputKind::DynamicNoPicExe
| LinkOutputKind::DynamicPicExe
Expand Down Expand Up @@ -1409,7 +1435,13 @@ impl<'a> Linker for L4Bender<'a> {
&mut self.cmd
}

fn set_output_kind(&mut self, _output_kind: LinkOutputKind, _out_filename: &Path) {}
fn set_output_kind(
&mut self,
_output_kind: LinkOutputKind,
_crate_type: CrateType,
_out_filename: &Path,
) {
}

fn link_staticlib_by_name(&mut self, name: &str, _verbatim: bool, whole_archive: bool) {
self.hint_static();
Expand Down Expand Up @@ -1556,7 +1588,12 @@ impl<'a> Linker for AixLinker<'a> {
&mut self.cmd
}

fn set_output_kind(&mut self, output_kind: LinkOutputKind, out_filename: &Path) {
fn set_output_kind(
&mut self,
output_kind: LinkOutputKind,
_crate_type: CrateType,
out_filename: &Path,
) {
match output_kind {
LinkOutputKind::DynamicDylib => {
self.hint_dynamic();
Expand Down Expand Up @@ -1763,7 +1800,13 @@ impl<'a> Linker for PtxLinker<'a> {
&mut self.cmd
}

fn set_output_kind(&mut self, _output_kind: LinkOutputKind, _out_filename: &Path) {}
fn set_output_kind(
&mut self,
_output_kind: LinkOutputKind,
_crate_type: CrateType,
_out_filename: &Path,
) {
}

fn link_staticlib_by_name(&mut self, _name: &str, _verbatim: bool, _whole_archive: bool) {
panic!("staticlibs not supported")
Expand Down Expand Up @@ -1829,7 +1872,13 @@ impl<'a> Linker for LlbcLinker<'a> {
&mut self.cmd
}

fn set_output_kind(&mut self, _output_kind: LinkOutputKind, _out_filename: &Path) {}
fn set_output_kind(
&mut self,
_output_kind: LinkOutputKind,
_crate_type: CrateType,
_out_filename: &Path,
) {
}

fn link_staticlib_by_name(&mut self, _name: &str, _verbatim: bool, _whole_archive: bool) {
panic!("staticlibs not supported")
Expand Down Expand Up @@ -1900,7 +1949,13 @@ impl<'a> Linker for BpfLinker<'a> {
&mut self.cmd
}

fn set_output_kind(&mut self, _output_kind: LinkOutputKind, _out_filename: &Path) {}
fn set_output_kind(
&mut self,
_output_kind: LinkOutputKind,
_crate_type: CrateType,
_out_filename: &Path,
) {
}

fn link_staticlib_by_name(&mut self, _name: &str, _verbatim: bool, _whole_archive: bool) {
panic!("staticlibs not supported")
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
}
};

let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::Yes) {
let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::No) {
Ok(meta_item) if parser.token == token::Eof => meta_item,
Ok(..) => expected_error(),
Err(err) => {
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_mir_transform/src/jump_threading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,16 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
}
// Transfer the conditions on the copy rhs, after inversing polarity.
Rvalue::UnaryOp(UnOp::Not, Operand::Move(place) | Operand::Copy(place)) => {
if !place.ty(self.body, self.tcx).ty.is_bool() {
// Constructing the conditions by inverting the polarity
// of equality is only correct for bools. That is to say,
// `!a == b` is not `a != b` for integers greater than 1 bit.
return;
}
let Some(conditions) = state.try_get_idx(lhs, self.map) else { return };
let Some(place) = self.map.find(place.as_ref()) else { return };
// FIXME: I think This could be generalized to not bool if we
// actually perform a logical not on the condition's value.
let conds = conditions.map(self.arena, Condition::inv);
state.insert_value_idx(place, conds, self.map);
}
Expand Down
15 changes: 10 additions & 5 deletions src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ case $HOST_TARGET in
# Strangely, Linux targets do not work here. cargo always says
# "error: cannot produce cdylib for ... as the target ... does not support these crate types".
# Only run "pass" tests, which is quite a bit faster.
python3 "$X_PY" test --stage 2 src/tools/miri --target aarch64-apple-darwin --test-args pass
python3 "$X_PY" test --stage 2 src/tools/miri --target i686-pc-windows-gnu --test-args pass
#FIXME: Re-enable this once CI issues are fixed
#python3 "$X_PY" test --stage 2 src/tools/miri --target aarch64-apple-darwin --test-args pass
#python3 "$X_PY" test --stage 2 src/tools/miri --target i686-pc-windows-gnu --test-args pass
;;
*)
echo "FATAL: unexpected host $HOST_TARGET"
Expand All @@ -68,6 +69,10 @@ case $HOST_TARGET in
esac
# Also smoke-test `x.py miri`. This doesn't run any actual tests (that would take too long),
# but it ensures that the crates build properly when tested with Miri.
python3 "$X_PY" miri --stage 2 library/core --test-args notest
python3 "$X_PY" miri --stage 2 library/alloc --test-args notest
python3 "$X_PY" miri --stage 2 library/std --test-args notest

#FIXME: Re-enable this for msvc once CI issues are fixed
if [ "$HOST_TARGET" != "x86_64-pc-windows-msvc" ]; then
python3 "$X_PY" miri --stage 2 library/core --test-args notest
python3 "$X_PY" miri --stage 2 library/alloc --test-args notest
python3 "$X_PY" miri --stage 2 library/std --test-args notest
fi
16 changes: 16 additions & 0 deletions src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ runners:
os: macos-14
<<: *base-job

- &job-windows
os: windows-2022
<<: *base-job

- &job-windows-8c
os: windows-2022-8core-32gb
<<: *base-job
Expand Down Expand Up @@ -373,6 +377,18 @@ auto:
DEPLOY_TOOLSTATES_JSON: toolstates-windows.json
<<: *job-windows-8c

# Temporary builder to workaround CI issues
- image: x86_64-msvc-ext2
env:
SCRIPT: >
python x.py test --stage 2 src/tools/miri --target aarch64-apple-darwin --test-args pass &&
python x.py test --stage 2 src/tools/miri --target i686-pc-windows-gnu --test-args pass &&
python x.py miri --stage 2 library/core --test-args notest &&
python x.py miri --stage 2 library/alloc --test-args notest &&
python x.py miri --stage 2 library/std --test-args notest
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-lld
<<: *job-windows

# 32/64-bit MinGW builds.
#
# We are using MinGW with POSIX threads since LLVM requires
Expand Down
2 changes: 1 addition & 1 deletion src/llvm-project
Submodule llvm-project updated 145 files
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
- // MIR for `bitwise_not` before JumpThreading
+ // MIR for `bitwise_not` after JumpThreading

fn bitwise_not() -> i32 {
let mut _0: i32;
let mut _1: i32;
let mut _2: bool;
let mut _3: i32;
let mut _4: i32;
scope 1 {
debug a => _1;
}

bb0: {
StorageLive(_1);
_1 = const 0_i32;
_1 = const 1_i32;
StorageLive(_2);
StorageLive(_3);
StorageLive(_4);
_4 = copy _1;
_3 = Not(move _4);
StorageDead(_4);
_2 = Eq(move _3, const 0_i32);
switchInt(move _2) -> [0: bb2, otherwise: bb1];
}

bb1: {
StorageDead(_3);
_0 = const 1_i32;
goto -> bb3;
}

bb2: {
StorageDead(_3);
_0 = const 0_i32;
goto -> bb3;
}

bb3: {
StorageDead(_2);
StorageDead(_1);
return;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
- // MIR for `bitwise_not` before JumpThreading
+ // MIR for `bitwise_not` after JumpThreading

fn bitwise_not() -> i32 {
let mut _0: i32;
let mut _1: i32;
let mut _2: bool;
let mut _3: i32;
let mut _4: i32;
scope 1 {
debug a => _1;
}

bb0: {
StorageLive(_1);
_1 = const 0_i32;
_1 = const 1_i32;
StorageLive(_2);
StorageLive(_3);
StorageLive(_4);
_4 = copy _1;
_3 = Not(move _4);
StorageDead(_4);
_2 = Eq(move _3, const 0_i32);
switchInt(move _2) -> [0: bb2, otherwise: bb1];
}

bb1: {
StorageDead(_3);
_0 = const 1_i32;
goto -> bb3;
}

bb2: {
StorageDead(_3);
_0 = const 0_i32;
goto -> bb3;
}

bb3: {
StorageDead(_2);
StorageDead(_1);
return;
}
}

Loading
Loading