fix build hangs
This commit is contained in:
12
build.cm
12
build.cm
@@ -91,6 +91,7 @@ var SALT_NATIVE = 'native' // native-compiled .cm dylib
|
|||||||
var SALT_MACH = 'mach' // mach bytecode blob
|
var SALT_MACH = 'mach' // mach bytecode blob
|
||||||
var SALT_MCODE = 'mcode' // mcode IR (JSON)
|
var SALT_MCODE = 'mcode' // mcode IR (JSON)
|
||||||
var SALT_DEPS = 'deps' // cached cc -MM dependency list
|
var SALT_DEPS = 'deps' // cached cc -MM dependency list
|
||||||
|
var SALT_FAIL = 'fail' // cached compilation failure
|
||||||
|
|
||||||
function cache_path(content, salt) {
|
function cache_path(content, salt) {
|
||||||
return get_build_dir() + '/' + content_hash(content + '\n' + salt)
|
return get_build_dir() + '/' + content_hash(content + '\n' + salt)
|
||||||
@@ -246,10 +247,18 @@ Build.compile_file = function(pkg, file, target, opts) {
|
|||||||
var file_content = fd.slurp(src_path)
|
var file_content = fd.slurp(src_path)
|
||||||
var quick_content = cmd_str + '\n' + text(file_content)
|
var quick_content = cmd_str + '\n' + text(file_content)
|
||||||
var deps_path = cache_path(quick_content, SALT_DEPS)
|
var deps_path = cache_path(quick_content, SALT_DEPS)
|
||||||
|
var fail_path = cache_path(quick_content, SALT_FAIL)
|
||||||
|
|
||||||
var build_dir = get_build_dir()
|
var build_dir = get_build_dir()
|
||||||
ensure_dir(build_dir)
|
ensure_dir(build_dir)
|
||||||
|
|
||||||
|
// Check for cached failure (skip files that previously failed to compile)
|
||||||
|
if (fd.is_file(fail_path)) {
|
||||||
|
if (_opts.verbose) print('[verbose] skipping ' + file + ' (cached failure)')
|
||||||
|
log.shop('skip ' + file + ' (cached failure)')
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
var deps = null
|
var deps = null
|
||||||
var full_content = null
|
var full_content = null
|
||||||
var obj_path = null
|
var obj_path = null
|
||||||
@@ -310,6 +319,8 @@ Build.compile_file = function(pkg, file, target, opts) {
|
|||||||
if (err_text) print(err_text)
|
if (err_text) print(err_text)
|
||||||
else print('Command: ' + full_cmd)
|
else print('Command: ' + full_cmd)
|
||||||
}
|
}
|
||||||
|
// Cache the failure so we don't retry on every build
|
||||||
|
fd.slurpwrite(fail_path, stone(blob(err_text || 'compilation failed')))
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -944,6 +955,7 @@ Build.SALT_NATIVE = SALT_NATIVE
|
|||||||
Build.SALT_MACH = SALT_MACH
|
Build.SALT_MACH = SALT_MACH
|
||||||
Build.SALT_MCODE = SALT_MCODE
|
Build.SALT_MCODE = SALT_MCODE
|
||||||
Build.SALT_DEPS = SALT_DEPS
|
Build.SALT_DEPS = SALT_DEPS
|
||||||
|
Build.SALT_FAIL = SALT_FAIL
|
||||||
Build.cache_path = cache_path
|
Build.cache_path = cache_path
|
||||||
|
|
||||||
return Build
|
return Build
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "cell.h"
|
#include "cell.h"
|
||||||
|
#include "cell_internal.h"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -306,7 +307,18 @@ static JSValue js_os_rusage(JSContext *js, JSValue self, int argc, JSValue *argv
|
|||||||
|
|
||||||
JSC_SCALL(os_system,
|
JSC_SCALL(os_system,
|
||||||
int err = system(str);
|
int err = system(str);
|
||||||
ret = number2js(js,err);
|
/* Reset actor turn timer after blocking system() call.
|
||||||
|
The scheduler's kill timer may have fired while system() blocked,
|
||||||
|
setting pause_flag = 2. Bump turn_gen so stale timer events are
|
||||||
|
ignored, and clear the pause flag so the VM doesn't raise
|
||||||
|
"interrupted" on the next backward branch. */
|
||||||
|
cell_rt *crt = JS_GetContextOpaque(js);
|
||||||
|
if (crt) {
|
||||||
|
atomic_fetch_add_explicit(&crt->turn_gen, 1, memory_order_relaxed);
|
||||||
|
JS_SetPauseFlag(js, 0);
|
||||||
|
crt->turn_start_ns = cell_ns();
|
||||||
|
}
|
||||||
|
ret = number2js(js, err);
|
||||||
)
|
)
|
||||||
|
|
||||||
JSC_CCALL(os_exit,
|
JSC_CCALL(os_exit,
|
||||||
|
|||||||
Reference in New Issue
Block a user