Merge pull request #165 from yvt/fix-const-memattr
Define immutable statics with const qualified types
This commit is contained in:
commit
7e0a42b492
2 changed files with 8 additions and 4 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -41,7 +41,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gccjit"
|
name = "gccjit"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
source = "git+https://github.com/antoyo/gccjit.rs#6c2af0cf733a26740f01a7c679afc20431165a54"
|
source = "git+https://github.com/antoyo/gccjit.rs#bdb86fb5092895ff5589726b33250010c64d93f6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gccjit_sys",
|
"gccjit_sys",
|
||||||
]
|
]
|
||||||
|
@ -49,7 +49,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gccjit_sys"
|
name = "gccjit_sys"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/antoyo/gccjit.rs#6c2af0cf733a26740f01a7c679afc20431165a54"
|
source = "git+https://github.com/antoyo/gccjit.rs#bdb86fb5092895ff5589726b33250010c64d93f6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc 0.1.12",
|
"libc 0.1.12",
|
||||||
]
|
]
|
||||||
|
|
|
@ -47,7 +47,10 @@ impl<'gcc, 'tcx> StaticMethods for CodegenCx<'gcc, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let global_value = self.static_addr_of_mut(cv, align, kind);
|
let global_value = self.static_addr_of_mut(cv, align, kind);
|
||||||
// TODO(antoyo): set global constant.
|
#[cfg(feature = "master")]
|
||||||
|
self.global_lvalues.borrow().get(&global_value)
|
||||||
|
.expect("`static_addr_of_mut` did not add the global to `self.global_lvalues`")
|
||||||
|
.global_set_readonly();
|
||||||
self.const_globals.borrow_mut().insert(cv, global_value);
|
self.const_globals.borrow_mut().insert(cv, global_value);
|
||||||
global_value
|
global_value
|
||||||
}
|
}
|
||||||
|
@ -88,7 +91,8 @@ impl<'gcc, 'tcx> StaticMethods for CodegenCx<'gcc, 'tcx> {
|
||||||
// mutability are placed into read-only memory.
|
// mutability are placed into read-only memory.
|
||||||
if !is_mutable {
|
if !is_mutable {
|
||||||
if self.type_is_freeze(ty) {
|
if self.type_is_freeze(ty) {
|
||||||
// TODO(antoyo): set global constant.
|
#[cfg(feature = "master")]
|
||||||
|
global.global_set_readonly();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue