Merge pull request #115 from bjorn3/foreign_statics
Correctly import foreign statics
This commit is contained in:
commit
fc236785a2
10 changed files with 25 additions and 18 deletions
2
cargo.sh
2
cargo.sh
|
|
@ -8,7 +8,7 @@ pushd $(dirname "$0") >/dev/null
|
|||
source config.sh
|
||||
|
||||
# read nightly compiler from rust-toolchain file
|
||||
TOOLCHAIN=$(cat rust-toolchain)
|
||||
TOOLCHAIN=$(cat rust-toolchain | grep channel | sed 's/channel = "\(.*\)"/\1/')
|
||||
|
||||
popd >/dev/null
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#!/bin/bash --verbose
|
||||
set -e
|
||||
|
||||
rustup component add rust-src rustc-dev llvm-tools-preview
|
||||
./build_sysroot/prepare_sysroot_src.sh
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
nightly-2021-12-30
|
||||
[toolchain]
|
||||
channel = "nightly-2021-12-30"
|
||||
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use gccjit::{LValue, RValue, ToRValue, Type};
|
||||
use gccjit::{GlobalKind, LValue, RValue, ToRValue, Type};
|
||||
use rustc_codegen_ssa::traits::{BaseTypeMethods, ConstMethods, DerivedTypeMethods, StaticMethods};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::Node;
|
||||
|
|
@ -218,7 +218,13 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
|||
}
|
||||
|
||||
let is_tls = fn_attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL);
|
||||
let global = self.declare_global(&sym, llty, is_tls, fn_attrs.link_section);
|
||||
let global = self.declare_global(
|
||||
&sym,
|
||||
llty,
|
||||
GlobalKind::Exported,
|
||||
is_tls,
|
||||
fn_attrs.link_section,
|
||||
);
|
||||
|
||||
if !self.tcx.is_reachable_non_generic(def_id) {
|
||||
// TODO(antoyo): set visibility.
|
||||
|
|
@ -389,6 +395,6 @@ fn check_and_apply_linkage<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, attrs: &Codeg
|
|||
// don't do this then linker errors can be generated where the linker
|
||||
// complains that one object files has a thread local version of the
|
||||
// symbol and another one doesn't.
|
||||
cx.declare_global(&sym, llty, is_tls, attrs.link_section)
|
||||
cx.declare_global(&sym, llty, GlobalKind::Imported, is_tls, attrs.link_section)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
|||
global
|
||||
}
|
||||
else {
|
||||
self.declare_global(name, ty, is_tls, link_section)
|
||||
self.declare_global(name, ty, GlobalKind::Exported, is_tls, link_section)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -47,8 +47,8 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
|||
unsafe { std::mem::transmute(func) }
|
||||
}*/
|
||||
|
||||
pub fn declare_global(&self, name: &str, ty: Type<'gcc>, is_tls: bool, link_section: Option<Symbol>) -> LValue<'gcc> {
|
||||
let global = self.context.new_global(None, GlobalKind::Exported, ty, name);
|
||||
pub fn declare_global(&self, name: &str, ty: Type<'gcc>, global_kind: GlobalKind, is_tls: bool, link_section: Option<Symbol>) -> LValue<'gcc> {
|
||||
let global = self.context.new_global(None, global_kind, ty, name);
|
||||
if is_tls {
|
||||
global.set_tls_model(self.tls_model);
|
||||
}
|
||||
|
|
|
|||
2
test.sh
2
test.sh
|
|
@ -145,7 +145,7 @@ function test_rustc() {
|
|||
echo
|
||||
echo "[TEST] rust-lang/rust"
|
||||
|
||||
rust_toolchain=$(cat rust-toolchain)
|
||||
rust_toolchain=$(cat rust-toolchain | grep channel | sed 's/channel = "\(.*\)"/\1/')
|
||||
|
||||
git clone https://github.com/rust-lang/rust.git || true
|
||||
cd rust
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ mod libc {
|
|||
pub fn fflush(stream: *mut i32) -> i32;
|
||||
pub fn printf(format: *const i8, ...) -> i32;
|
||||
|
||||
pub static STDOUT: *mut i32;
|
||||
pub static stdout: *mut i32;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ mod intrinsics {
|
|||
pub fn panic(_msg: &str) -> ! {
|
||||
unsafe {
|
||||
libc::puts("Panicking\0" as *const str as *const u8);
|
||||
libc::fflush(libc::STDOUT);
|
||||
libc::fflush(libc::stdout);
|
||||
intrinsics::abort();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ mod libc {
|
|||
pub fn puts(s: *const u8) -> i32;
|
||||
pub fn fflush(stream: *mut i32) -> i32;
|
||||
|
||||
pub static STDOUT: *mut i32;
|
||||
pub static stdout: *mut i32;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ mod intrinsics {
|
|||
pub fn panic(_msg: &str) -> ! {
|
||||
unsafe {
|
||||
libc::puts("Panicking\0" as *const str as *const u8);
|
||||
libc::fflush(libc::STDOUT);
|
||||
libc::fflush(libc::stdout);
|
||||
intrinsics::abort();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ mod libc {
|
|||
pub fn fflush(stream: *mut i32) -> i32;
|
||||
pub fn printf(format: *const i8, ...) -> i32;
|
||||
|
||||
pub static STDOUT: *mut i32;
|
||||
pub static stdout: *mut i32;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ mod intrinsics {
|
|||
pub fn panic(_msg: &str) -> ! {
|
||||
unsafe {
|
||||
libc::puts("Panicking\0" as *const str as *const u8);
|
||||
libc::fflush(libc::STDOUT);
|
||||
libc::fflush(libc::stdout);
|
||||
intrinsics::abort();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ mod libc {
|
|||
pub fn puts(s: *const u8) -> i32;
|
||||
pub fn fflush(stream: *mut i32) -> i32;
|
||||
|
||||
pub static STDOUT: *mut i32;
|
||||
pub static stdout: *mut i32;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ mod intrinsics {
|
|||
pub fn panic(_msg: &str) -> ! {
|
||||
unsafe {
|
||||
libc::puts("Panicking\0" as *const str as *const u8);
|
||||
libc::fflush(libc::STDOUT);
|
||||
libc::fflush(libc::stdout);
|
||||
intrinsics::abort();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue