forked from M-Labs/nac3
1
0
Fork 0

[artiq] symbol_resolver: Set private linkage for constants

This commit is contained in:
David Mak 2024-08-19 14:17:31 +08:00 committed by sb10q
parent a0f6961e0e
commit 0b074c2cf2
1 changed files with 4 additions and 2 deletions

View File

@ -1,4 +1,6 @@
use crate::PrimitivePythonId;
use inkwell::{ use inkwell::{
module::Linkage,
types::{BasicType, BasicTypeEnum}, types::{BasicType, BasicTypeEnum},
values::BasicValueEnum, values::BasicValueEnum,
AddressSpace, AddressSpace,
@ -34,8 +36,6 @@ use std::{
}, },
}; };
use crate::PrimitivePythonId;
pub enum PrimitiveValue { pub enum PrimitiveValue {
I32(i32), I32(i32),
I64(i64), I64(i64),
@ -133,6 +133,8 @@ impl StaticValue for PythonValue {
format!("{}_const", self.id).as_str(), format!("{}_const", self.id).as_str(),
); );
global.set_constant(true); global.set_constant(true);
// Set linkage of global to private to avoid name collisions
global.set_linkage(Linkage::Private);
global.set_initializer(&ctx.ctx.const_struct( global.set_initializer(&ctx.ctx.const_struct(
&[ctx.ctx.i32_type().const_int(u64::from(id), false).into()], &[ctx.ctx.i32_type().const_int(u64::from(id), false).into()],
false, false,