@@ -97,8 +97,10 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
9797 // def_id).
9898 let var_name = format ! ( "{:?}" , global) ;
9999 if var_name. contains ( "FN" ) && var_name. contains ( "memchr" ) {
100- println ! ( "Var name: {:?}" , var_name) ;
100+ //println!("Var name: {:?}", var_name);
101+ println ! ( "INITIALIZE: {:?} = {:?}" , var_name, value) ;
101102
103+ /*
102104 let ptr_type = value.get_type().make_pointer();
103105
104106 // TODO: remove \x01
@@ -108,8 +110,9 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
108110 imp_name.push_str(&var_name);
109111
110112 // FIXME: if I understand correctly the code in cg_llvm, the kind should be Imported.
111- /*let imp_global = self.context.new_global(None, GlobalKind::Exported, ptr_type, &imp_name);
112- imp_global.global_set_initializer_rvalue(global.get_address(None));*/
113+ let imp_global = self.context.new_global(None, GlobalKind::Exported, ptr_type, &imp_name);
114+ imp_global.global_set_initializer_rvalue(global.get_address(None));
115+ */
113116
114117 /*
115118 /*let context = gccjit::Context::default();
@@ -122,7 +125,6 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
122125 let my_name = format!("MY_NAME${}", var_name);
123126 //let global = self.context.new_global(None, GlobalKind::Exported, fn_ptr_type, my_name);
124127 //global.add_attribute(VarAttribute::Used);
125- println!("{:?} = {:?}", var_name, value);
126128
127129 let my_func_name = format!("MY_FUNC${}", var_name);
128130 let func = self.context.new_function(None, FunctionType::Exported, void_type, &[], &my_func_name, false);
@@ -166,6 +168,7 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
166168 //let value = self.context.new_bitcast(None, value, fn_ptr_type); // Also WORKS
167169 let value = self.context.new_bitcast(None, value, val_llty);*/
168170 global. global_set_initializer_rvalue ( value) ;
171+ println ! ( "=== AFTER INITIALIZE" ) ;
169172 }
170173 else {
171174 global. global_set_initializer_rvalue ( value) ;
@@ -326,10 +329,13 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
326329 }
327330
328331 let is_tls = fn_attrs. flags . contains ( CodegenFnAttrFlags :: THREAD_LOCAL ) ;
332+ if sym. contains ( "memchr" ) && sym. contains ( "FN" ) {
333+ println ! ( "** DECLARE" ) ;
334+ }
329335 let global = self . declare_global (
330336 sym,
331337 gcc_type,
332- GlobalKind :: Exported ,
338+ GlobalKind :: Imported ,
333339 is_tls,
334340 fn_attrs. link_section ,
335341 ) ;
0 commit comments