diff --git a/Cargo.lock b/Cargo.lock index 47925f72c2c..2688ea4a4e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,7 +41,7 @@ dependencies = [ [[package]] name = "gccjit" version = "1.0.0" -source = "git+https://github.com/antoyo/gccjit.rs#0672b78d162d65b6f36ea4062947253affe9fdef" +source = "git+https://github.com/antoyo/gccjit.rs#e68fce53af18dce4d40e6b7090f881ff86a2e892" dependencies = [ "gccjit_sys", ] @@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "gccjit_sys" version = "0.0.1" -source = "git+https://github.com/antoyo/gccjit.rs#0672b78d162d65b6f36ea4062947253affe9fdef" +source = "git+https://github.com/antoyo/gccjit.rs#e68fce53af18dce4d40e6b7090f881ff86a2e892" dependencies = [ "libc 0.1.12", ] diff --git a/patches/0023-core-Ignore-failing-tests.patch b/patches/0023-core-Ignore-failing-tests.patch index 73e9c858caf..ee5ba449fb8 100644 --- a/patches/0023-core-Ignore-failing-tests.patch +++ b/patches/0023-core-Ignore-failing-tests.patch @@ -46,24 +46,4 @@ index 4bc44e9..8e3c7a4 100644 #[test] fn cell_allows_array_cycle() { -diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs -index 3e00e0a..8e5663b 100644 ---- a/library/core/tests/slice.rs -+++ b/library/core/tests/slice.rs -@@ -2108,6 +2108,7 @@ fn test_copy_within_panics_src_out_of_bounds() { - bytes.copy_within(usize::MAX..=usize::MAX, 0); - } - -+/* - #[test] - fn test_is_sorted() { - let empty: [i32; 0] = []; -@@ -2122,6 +2123,7 @@ fn test_is_sorted() { - assert!(!["c", "bb", "aaa"].is_sorted()); - assert!(["c", "bb", "aaa"].is_sorted_by_key(|s| s.len())); - } -+*/ - - #[test] - fn test_slice_run_destructors() { -- 2.21.0 (Apple Git-122) diff --git a/src/consts.rs b/src/consts.rs index e55da7952e7..af00539f89b 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -35,7 +35,12 @@ impl<'gcc, 'tcx> StaticMethods for CodegenCx<'gcc, 'tcx> { // following: for (value, variable) in &*self.const_globals.borrow() { if format!("{:?}", value) == format!("{:?}", cv) { - // TODO(antoyo): upgrade alignment. + if let Some(global_variable) = self.global_lvalues.borrow().get(variable) { + let alignment = align.bits() as i32; + if alignment > global_variable.get_alignment() { + global_variable.set_alignment(alignment); + } + } return *variable; } } @@ -182,7 +187,9 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { // globally. global.global_set_initializer_rvalue(cv); // TODO(antoyo): set unnamed address. - global.get_address(None) + let rvalue = global.get_address(None); + self.global_lvalues.borrow_mut().insert(rvalue, global); + rvalue } pub fn get_static(&self, def_id: DefId) -> LValue<'gcc> { diff --git a/src/context.rs b/src/context.rs index dfcd1b62312..d260a983347 100644 --- a/src/context.rs +++ b/src/context.rs @@ -83,6 +83,9 @@ pub struct CodegenCx<'gcc, 'tcx> { /// Cache of emitted const globals (value -> global) pub const_globals: RefCell, RValue<'gcc>>>, + /// Map from the address of a global variable (rvalue) to the global variable itself (lvalue). + /// TODO(antoyo): remove when the rustc API is fixed. + pub global_lvalues: RefCell, LValue<'gcc>>>, /// Cache of constant strings, pub const_cstr_cache: RefCell>>, @@ -195,6 +198,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { function_instances: Default::default(), vtables: Default::default(), const_globals: Default::default(), + global_lvalues: Default::default(), const_cstr_cache: Default::default(), globals: Default::default(), scalar_types: Default::default(),