log available

This commit is contained in:
2026-02-16 19:51:00 -06:00
parent dce0b5cc89
commit 1f3e53587d
2 changed files with 40 additions and 37 deletions

View File

@@ -260,48 +260,50 @@ Build.build_module_dylib = function(pkg, file, target, opts) {
var build_dir = get_build_dir() var build_dir = get_build_dir()
ensure_dir(build_dir) ensure_dir(build_dir)
var dylib_path = build_dir + '/' + link_key + '.' + _target + dylib_ext var dylib_path = build_dir + '/' + link_key + '.' + _target + dylib_ext
var cmd_parts = null
var cmd_str = null
var ret = null
if (fd.is_file(dylib_path)) if (!fd.is_file(dylib_path)) {
return dylib_path cmd_parts = [cc, '-shared', '-fPIC']
var cmd_parts = [cc, '-shared', '-fPIC'] if (tc.system == 'darwin') {
cmd_parts = array(cmd_parts, [
'-undefined', 'dynamic_lookup',
'-Wl,-dead_strip',
'-Wl,-rpath,@loader_path/../local',
'-Wl,-rpath,' + local_dir
])
} else if (tc.system == 'linux') {
cmd_parts = array(cmd_parts, [
'-Wl,--allow-shlib-undefined',
'-Wl,--gc-sections',
'-Wl,-rpath,$ORIGIN/../local',
'-Wl,-rpath,' + local_dir
])
} else if (tc.system == 'windows') {
push(cmd_parts, '-Wl,--allow-shlib-undefined')
}
if (tc.system == 'darwin') { push(cmd_parts, '-L"' + local_dir + '"')
cmd_parts = array(cmd_parts, [ push(cmd_parts, '"' + obj + '"')
'-undefined', 'dynamic_lookup', arrfor(_extra, function(extra_obj) {
'-Wl,-dead_strip', push(cmd_parts, '"' + extra_obj + '"')
'-Wl,-rpath,@loader_path/../local', })
'-Wl,-rpath,' + local_dir cmd_parts = array(cmd_parts, resolved_ldflags)
]) cmd_parts = array(cmd_parts, target_ldflags)
} else if (tc.system == 'linux') { push(cmd_parts, '-o')
cmd_parts = array(cmd_parts, [ push(cmd_parts, '"' + dylib_path + '"')
'-Wl,--allow-shlib-undefined',
'-Wl,--gc-sections', cmd_str = text(cmd_parts, ' ')
'-Wl,-rpath,$ORIGIN/../local', log.console('Linking module ' + file + ' -> ' + fd.basename(dylib_path))
'-Wl,-rpath,' + local_dir ret = os.system(cmd_str)
]) if (ret != 0) {
} else if (tc.system == 'windows') { print('Linking failed: ' + file); disrupt
push(cmd_parts, '-Wl,--allow-shlib-undefined') }
} }
push(cmd_parts, '-L"' + local_dir + '"') // Always install to deterministic lib/<pkg>/<stem>.dylib
push(cmd_parts, '"' + obj + '"')
arrfor(_extra, function(extra_obj) {
push(cmd_parts, '"' + extra_obj + '"')
})
cmd_parts = array(cmd_parts, resolved_ldflags)
cmd_parts = array(cmd_parts, target_ldflags)
push(cmd_parts, '-o')
push(cmd_parts, '"' + dylib_path + '"')
var cmd_str = text(cmd_parts, ' ')
log.console('Linking module ' + file + ' -> ' + fd.basename(dylib_path))
var ret = os.system(cmd_str)
if (ret != 0) {
print('Linking failed: ' + file); disrupt
}
// Install to deterministic lib/<pkg>/<stem>.dylib
// Strip .c/.cpp extension so the loader can find it by module name // Strip .c/.cpp extension so the loader can find it by module name
var file_stem = file var file_stem = file
if (ends_with(file_stem, '.cpp')) file_stem = text(file_stem, 0, -4) if (ends_with(file_stem, '.cpp')) file_stem = text(file_stem, 0, -4)

View File

@@ -382,6 +382,7 @@ os.run_ast_fn = run_ast_fn
os.run_ast_noopt_fn = run_ast_noopt_fn os.run_ast_noopt_fn = run_ast_noopt_fn
core_extras.core_json = json core_extras.core_json = json
core_extras.actor_api = $_ core_extras.actor_api = $_
core_extras.log = log
core_extras.runtime_env = runtime_env core_extras.runtime_env = runtime_env
core_extras.content_hash = content_hash core_extras.content_hash = content_hash
core_extras.cache_path = cache_path core_extras.cache_path = cache_path