mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Merge commit '4cf4ffc6ba514f171b3f52d1c731063e4fc45be3' into sync_cg_clif-2024-03-16
This commit is contained in:
parent
47abd3a486
commit
4b61629951
30
.github/workflows/main.yml
vendored
30
.github/workflows/main.yml
vendored
@ -44,10 +44,9 @@ jobs:
|
||||
env:
|
||||
TARGET_TRIPLE: x86_64-apple-darwin
|
||||
# cross-compile from Linux to Windows using mingw
|
||||
# FIXME The wine version in Ubuntu 22.04 is missing ProcessPrng
|
||||
#- os: ubuntu-latest
|
||||
# env:
|
||||
# TARGET_TRIPLE: x86_64-pc-windows-gnu
|
||||
- os: ubuntu-latest
|
||||
env:
|
||||
TARGET_TRIPLE: x86_64-pc-windows-gnu
|
||||
- os: ubuntu-latest
|
||||
env:
|
||||
TARGET_TRIPLE: aarch64-unknown-linux-gnu
|
||||
@ -81,11 +80,11 @@ jobs:
|
||||
if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
|
||||
run: rustup set default-host x86_64-pc-windows-gnu
|
||||
|
||||
#- name: Install MinGW toolchain and wine
|
||||
# if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
|
||||
# run: |
|
||||
# sudo apt-get update
|
||||
# sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
|
||||
- name: Install MinGW toolchain and wine
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
|
||||
|
||||
- name: Install AArch64 toolchain and qemu
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'aarch64-unknown-linux-gnu'
|
||||
@ -108,6 +107,15 @@ jobs:
|
||||
- name: Prepare dependencies
|
||||
run: ./y.sh prepare
|
||||
|
||||
# The Wine version shipped with Ubuntu 22.04 doesn't implement bcryptprimitives.dll
|
||||
- name: Build bcryptprimitives.dll shim for Wine
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
|
||||
run: |
|
||||
rustup target add x86_64-pc-windows-gnu
|
||||
mkdir wine_shims
|
||||
rustc patches/bcryptprimitives.rs -Copt-level=3 -Clto=fat --out-dir wine_shims --target x86_64-pc-windows-gnu
|
||||
echo "WINEPATH=$(pwd)/wine_shims" >> $GITHUB_ENV
|
||||
|
||||
- name: Build
|
||||
run: ./y.sh build --sysroot none
|
||||
|
||||
@ -234,11 +242,11 @@ jobs:
|
||||
if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
|
||||
run: rustup set default-host x86_64-pc-windows-gnu
|
||||
|
||||
- name: Install MinGW toolchain and wine
|
||||
- name: Install MinGW toolchain
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
|
||||
sudo apt-get install -y gcc-mingw-w64-x86-64
|
||||
|
||||
- name: Prepare dependencies
|
||||
run: ./y.sh prepare
|
||||
|
@ -167,6 +167,14 @@ fn main() {
|
||||
transmute_fat_pointer();
|
||||
|
||||
rust_call_abi();
|
||||
|
||||
const fn no_str() -> Option<Box<str>> {
|
||||
None
|
||||
}
|
||||
|
||||
static STATIC_WITH_MAYBE_NESTED_BOX: &Option<Box<str>> = &no_str();
|
||||
|
||||
println!("{:?}", STATIC_WITH_MAYBE_NESTED_BOX);
|
||||
}
|
||||
|
||||
fn panic(_: u128) {
|
||||
|
22
patches/bcryptprimitives.rs
Normal file
22
patches/bcryptprimitives.rs
Normal file
@ -0,0 +1,22 @@
|
||||
// Shim for bcryptprimitives.dll. The Wine version shipped with Ubuntu 22.04
|
||||
// doesn't support it yet. Authored by @ChrisDenton
|
||||
|
||||
#![crate_type = "cdylib"]
|
||||
#![allow(nonstandard_style)]
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "system" fn ProcessPrng(mut pbData: *mut u8, mut cbData: usize) -> i32 {
|
||||
while cbData > 0 {
|
||||
let size = core::cmp::min(cbData, u32::MAX as usize);
|
||||
RtlGenRandom(pbData, size as u32);
|
||||
cbData -= size;
|
||||
pbData = pbData.add(size);
|
||||
}
|
||||
1
|
||||
}
|
||||
|
||||
#[link(name = "advapi32")]
|
||||
extern "system" {
|
||||
#[link_name = "SystemFunction036"]
|
||||
pub fn RtlGenRandom(RandomBuffer: *mut u8, RandomBufferLength: u32) -> u8;
|
||||
}
|
@ -42,12 +42,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.83"
|
||||
version = "1.0.90"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
|
@ -1,3 +1,3 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2024-03-08"
|
||||
channel = "nightly-2024-03-16"
|
||||
components = ["rust-src", "rustc-dev", "llvm-tools"]
|
||||
|
@ -83,6 +83,7 @@ rm -r tests/run-make/symbols-include-type-name # --emit=asm not supported
|
||||
rm -r tests/run-make/target-specs # i686 not supported by Cranelift
|
||||
rm -r tests/run-make/mismatching-target-triples # same
|
||||
rm tests/ui/asm/x86_64/issue-96797.rs # const and sym inline asm operands don't work entirely correctly
|
||||
rm tests/ui/asm/x86_64/goto.rs # inline asm labels not supported
|
||||
|
||||
# requires LTO
|
||||
rm -r tests/run-make/cdylib
|
||||
@ -121,6 +122,7 @@ rm -r tests/run-make/optimization-remarks-dir # remarks are LLVM specific
|
||||
rm tests/ui/mir/mir_misc_casts.rs # depends on deduplication of constants
|
||||
rm tests/ui/mir/mir_raw_fat_ptr.rs # same
|
||||
rm tests/ui/consts/issue-33537.rs # same
|
||||
rm tests/ui/consts/const-mut-refs-crate.rs # same
|
||||
|
||||
# rustdoc-clif passes extra args, suppressing the help message when no args are passed
|
||||
rm -r tests/run-make/issue-88756-default-output
|
||||
|
@ -53,7 +53,11 @@ pub(crate) fn codegen_tls_ref<'tcx>(
|
||||
let call = fx.bcx.ins().call(func_ref, &[]);
|
||||
fx.bcx.func.dfg.first_result(call)
|
||||
} else {
|
||||
let data_id = data_id_for_static(fx.tcx, fx.module, def_id, false);
|
||||
let data_id = data_id_for_static(
|
||||
fx.tcx, fx.module, def_id, false,
|
||||
// For a declaration the stated mutability doesn't matter.
|
||||
false,
|
||||
);
|
||||
let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
|
||||
if fx.clif_comments.enabled() {
|
||||
fx.add_comment(local_data_id, format!("tls {:?}", def_id));
|
||||
@ -164,7 +168,11 @@ pub(crate) fn codegen_const_value<'tcx>(
|
||||
}
|
||||
GlobalAlloc::Static(def_id) => {
|
||||
assert!(fx.tcx.is_static(def_id));
|
||||
let data_id = data_id_for_static(fx.tcx, fx.module, def_id, false);
|
||||
let data_id = data_id_for_static(
|
||||
fx.tcx, fx.module, def_id, false,
|
||||
// For a declaration the stated mutability doesn't matter.
|
||||
false,
|
||||
);
|
||||
let local_data_id =
|
||||
fx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
|
||||
if fx.clif_comments.enabled() {
|
||||
@ -232,21 +240,19 @@ fn data_id_for_static(
|
||||
module: &mut dyn Module,
|
||||
def_id: DefId,
|
||||
definition: bool,
|
||||
definition_writable: bool,
|
||||
) -> DataId {
|
||||
let attrs = tcx.codegen_fn_attrs(def_id);
|
||||
|
||||
let instance = Instance::mono(tcx, def_id).polymorphize(tcx);
|
||||
let symbol_name = tcx.symbol_name(instance).name;
|
||||
let ty = instance.ty(tcx, ParamEnv::reveal_all());
|
||||
let is_mutable = if tcx.is_mutable_static(def_id) {
|
||||
true
|
||||
} else {
|
||||
!ty.is_freeze(tcx, ParamEnv::reveal_all())
|
||||
};
|
||||
let align = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap().align.pref.bytes();
|
||||
|
||||
if let Some(import_linkage) = attrs.import_linkage {
|
||||
assert!(!definition);
|
||||
assert!(!tcx.is_mutable_static(def_id));
|
||||
|
||||
let ty = instance.ty(tcx, ParamEnv::reveal_all());
|
||||
let align = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap().align.pref.bytes();
|
||||
|
||||
let linkage = if import_linkage == rustc_middle::mir::mono::Linkage::ExternalWeak
|
||||
|| import_linkage == rustc_middle::mir::mono::Linkage::WeakAny
|
||||
@ -259,7 +265,7 @@ fn data_id_for_static(
|
||||
let data_id = match module.declare_data(
|
||||
symbol_name,
|
||||
linkage,
|
||||
is_mutable,
|
||||
false,
|
||||
attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL),
|
||||
) {
|
||||
Ok(data_id) => data_id,
|
||||
@ -307,7 +313,7 @@ fn data_id_for_static(
|
||||
let data_id = match module.declare_data(
|
||||
symbol_name,
|
||||
linkage,
|
||||
is_mutable,
|
||||
definition_writable,
|
||||
attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL),
|
||||
) {
|
||||
Ok(data_id) => data_id,
|
||||
@ -341,7 +347,13 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
|
||||
|
||||
let alloc = tcx.eval_static_initializer(def_id).unwrap();
|
||||
|
||||
let data_id = data_id_for_static(tcx, module, def_id, true);
|
||||
let data_id = data_id_for_static(
|
||||
tcx,
|
||||
module,
|
||||
def_id,
|
||||
true,
|
||||
alloc.inner().mutability == Mutability::Mut,
|
||||
);
|
||||
(data_id, alloc, section_name)
|
||||
}
|
||||
};
|
||||
@ -421,7 +433,11 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
|
||||
// Don't push a `TodoItem::Static` here, as it will cause statics used by
|
||||
// multiple crates to be duplicated between them. It isn't necessary anyway,
|
||||
// as it will get pushed by `codegen_static` when necessary.
|
||||
data_id_for_static(tcx, module, def_id, false)
|
||||
data_id_for_static(
|
||||
tcx, module, def_id, false,
|
||||
// For a declaration the stated mutability doesn't matter.
|
||||
false,
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user