diff --git a/internal/shop.cm b/internal/shop.cm index e1743c9b..136c4596 100644 --- a/internal/shop.cm +++ b/internal/shop.cm @@ -517,25 +517,17 @@ function resolve_locator(path, ctx) // Generate symbol name for a C module file // Uses the same format as Shop.c_symbol_for_file -// Resolves linked packages to their actual target first +// Symbol names are based on canonical package names, not link targets function make_c_symbol(pkg, file) { - // Check if this package is linked - if so, use the link target for symbol name - var link_target = link.get_target(pkg) - var resolved_pkg = link_target ? link_target : pkg - - var pkg_safe = resolved_pkg.replace(/\//g, '_').replace(/\./g, '_').replace(/-/g, '_') + var pkg_safe = pkg.replace(/\//g, '_').replace(/\./g, '_').replace(/-/g, '_') var file_safe = file.replace(/\//g, '_').replace(/\./g, '_').replace(/-/g, '_') return 'js_' + pkg_safe + '_' + file_safe + '_use' } // Get the library path for a package in .cell/lib -// Resolves linked packages to their actual target first +// Library names are based on canonical package names, not link targets function get_lib_path(pkg) { - // Check if this package is linked - if so, use the link target - var link_target = link.get_target(pkg) - var resolved_pkg = link_target ? link_target : pkg - - var lib_name = resolved_pkg.replace(/\//g, '_').replace(/\./g, '_').replace(/-/g, '_') + var lib_name = pkg.replace(/\//g, '_').replace(/\./g, '_').replace(/-/g, '_') return global_shop_path + '/lib/' + lib_name + dylib_ext } diff --git a/package.cm b/package.cm index f1270800..7ca1d7f8 100644 --- a/package.cm +++ b/package.cm @@ -2,9 +2,13 @@ var package = {} var fd = use('fd') var toml = use('toml') +var json = use('json') var os = use('os') var link = use('link') +// Cache for loaded configs to avoid toml re-parsing corruption +var config_cache = {} + // Convert package name to a safe directory name // For absolute paths (local packages), replace / with _ // For remote packages, keep slashes as they use nested directories @@ -42,6 +46,11 @@ function get_path(name) package.load_config = function(name) { var config_path = get_path(name) + '/cell.toml' + + // Return cached config if available + if (config_cache[config_path]) + return config_cache[config_path] + if (!fd.is_file(config_path)) throw Error(`${config_path} does not exist`) @@ -54,6 +63,10 @@ package.load_config = function(name) return {} } + // Deep copy to avoid toml module's shared state bug and cache it + result = json.decode(json.encode(result)) + config_cache[config_path] = result + return result }