Skip to content

Commit 1d17c11

Browse files
committed
Fix review comment
1 parent 1d6074e commit 1d17c11

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/consts.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use gccjit::{LValue, RValue, ToRValue, Type};
1+
use gccjit::{GlobalKind, LValue, RValue, ToRValue, Type};
22
use rustc_codegen_ssa::traits::{BaseTypeMethods, ConstMethods, DerivedTypeMethods, StaticMethods};
33
use rustc_hir as hir;
44
use rustc_hir::Node;
@@ -218,7 +218,13 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
218218
}
219219

220220
let is_tls = fn_attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL);
221-
let global = self.declare_global(&sym, llty, false, is_tls, fn_attrs.link_section);
221+
let global = self.declare_global(
222+
&sym,
223+
llty,
224+
GlobalKind::Exported,
225+
is_tls,
226+
fn_attrs.link_section,
227+
);
222228

223229
if !self.tcx.is_reachable_non_generic(def_id) {
224230
// TODO(antoyo): set visibility.
@@ -389,6 +395,6 @@ fn check_and_apply_linkage<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, attrs: &Codeg
389395
// don't do this then linker errors can be generated where the linker
390396
// complains that one object files has a thread local version of the
391397
// symbol and another one doesn't.
392-
cx.declare_global(&sym, llty, true, is_tls, attrs.link_section)
398+
cx.declare_global(&sym, llty, GlobalKind::Imported, is_tls, attrs.link_section)
393399
}
394400
}

src/declare.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
2222
global
2323
}
2424
else {
25-
self.declare_global(name, ty, false, is_tls, link_section)
25+
self.declare_global(name, ty, GlobalKind::Exported, is_tls, link_section)
2626
}
2727
}
2828

@@ -47,8 +47,8 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
4747
unsafe { std::mem::transmute(func) }
4848
}*/
4949

50-
pub fn declare_global(&self, name: &str, ty: Type<'gcc>, is_import: bool, is_tls: bool, link_section: Option<Symbol>) -> LValue<'gcc> {
51-
let global = self.context.new_global(None, if is_import { GlobalKind::Imported } else { GlobalKind::Exported }, ty, name);
50+
pub fn declare_global(&self, name: &str, ty: Type<'gcc>, global_kind: GlobalKind, is_tls: bool, link_section: Option<Symbol>) -> LValue<'gcc> {
51+
let global = self.context.new_global(None, global_kind, ty, name);
5252
if is_tls {
5353
global.set_tls_model(self.tls_model);
5454
}

0 commit comments

Comments
 (0)