Skip to content

Commit

Permalink
fix: file.modpath and file.workdir function cache cross different mod…
Browse files Browse the repository at this point in the history
…ules (#1427)

Signed-off-by: peefy <xpf6677@163.com>
  • Loading branch information
Peefy committed Jun 20, 2024
1 parent 63b2368 commit 6fd3a09
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
32 changes: 16 additions & 16 deletions kclvm/compiler/src/codegen/llvm/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1390,22 +1390,6 @@ impl<'ctx> LLVMCodeGenContext<'ctx> {
self.pkgpath_stack.borrow_mut().push(pkgpath.clone());
}
}
// Set the kcl module path to the runtime context
self.build_void_call(
&ApiFunc::kclvm_context_set_kcl_modpath.name(),
&[
self.current_runtime_ctx_ptr(),
self.native_global_string_value(&self.program.root),
],
);
// Set the kcl workdir to the runtime context
self.build_void_call(
&ApiFunc::kclvm_context_set_kcl_workdir.name(),
&[
self.current_runtime_ctx_ptr(),
self.native_global_string_value(&self.workdir),
],
);
if !self.import_names.is_empty() {
let import_names = self.dict_value();
for (k, v) in &self.import_names {
Expand Down Expand Up @@ -1438,6 +1422,22 @@ impl<'ctx> LLVMCodeGenContext<'ctx> {
}
self.ret_void();
} else {
// Set the kcl module path to the runtime context only in the main package.
self.build_void_call(
&ApiFunc::kclvm_context_set_kcl_modpath.name(),
&[
self.current_runtime_ctx_ptr(),
self.native_global_string_value(&self.program.root),
],
);
// Set the kcl workdir to the runtime context
self.build_void_call(
&ApiFunc::kclvm_context_set_kcl_workdir.name(),
&[
self.current_runtime_ctx_ptr(),
self.native_global_string_value(&self.workdir),
],
);
// Init scope and all builtin functions
self.init_scope(MAIN_PKG_PATH);
let main_pkg_modules = self
Expand Down
2 changes: 1 addition & 1 deletion kclvm/version/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Copyright The KCL Authors. All rights reserved.

pub const VERSION: &str = include_str!("./../../../VERSION");
pub const CHECK_SUM: &str = "0c20ab3eb4b9179219d6837a57f5d352";
pub const CHECK_SUM: &str = "c020ab3eb4b9179219d6837a57f5d323";

/// Get kCL full version string with the format `{version}-{check_sum}`.
#[inline]
Expand Down

0 comments on commit 6fd3a09

Please sign in to comment.