Commit f0606b61 authored by Benoît Minisini's avatar Benoît Minisini
Browse files

Disable jit compiler if no compiler is found.

* NEW: Disable jit compiler if no compiler is found.

* NEW: Don't crash if no compiler is found, but just tell the interpreter.
parent 18a74ff6
Pipeline #189824696 passed with stage
in 20 minutes and 26 seconds
......@@ -81,6 +81,12 @@ bool JIT_can_compile(ARCHIVE *arch)
return get_state(arch) == JIT_NOT_COMPILED;
static void find_method(GB_FUNCTION *func, const char *method, const char *sign, const char *type)
if (GB_GetFunction(func, CLASS_find_global("Jit"), method, sign, type))
ERROR_panic("Cannot found method 'Jit.&1' in 'gb.jit' component");
void JIT_compile(ARCHIVE *arch)
COMPONENT *current;
......@@ -94,6 +100,8 @@ void JIT_compile(ARCHIVE *arch)
if (!_component_loaded)
char *var;
GB_FUNCTION init_func;
GB_VALUE *ret;
_component_loaded = TRUE;
......@@ -112,10 +120,19 @@ void JIT_compile(ARCHIVE *arch)
fprintf(stderr, "gbx3: loading gb.jit component\n");
if (GB_GetFunction(&_jit_compile_func, CLASS_find_global("Jit"), "_Compile", "s", "b"))
ERROR_panic("Unable to find JIT._Compile() method");
if (GB_GetFunction(&_jit_wait_func, CLASS_find_global("Jit"), "_Wait", "s", "s"))
ERROR_panic("Unable to find JIT._Wait() method");
find_method(&init_func, "_Search", NULL, NULL);
ret = GB_Call(&init_func, 0, FALSE);
if (ret->_boolean.value)
JIT_disabled = TRUE;
fprintf(stderr, "gbx3: no compiler found. JIT is disabled.\n");
find_method(&_jit_compile_func, "_Compile", "s", "b");
find_method(&_jit_wait_func, "_Wait", "s", "s");
arch ? (arch->jit_state = JIT_COMPILING) : (_jit_state = JIT_COMPILING);
......@@ -14,11 +14,13 @@ Private $sResult As String
Private $fTime As Float
Private $hProcess As Process
Static Private Sub Init()
Static Public Sub Init()
Dim sFlag As String
Dim sCompiler As String
If $sCompiler Then Return
sCompiler = Env["GB_JIT_CC"]
If Not sCompiler Then sCompiler = "gcc"
......@@ -52,8 +54,6 @@ Public Sub Run(sInput As String, Optional sOption As String)
'Dim I As Integer
If Not $sCompiler Then Init
' $sCache = File.Dir(File.Dir(Temp$())) &/ "gb.jit"
' Try Mkdir $sCache
......@@ -17,6 +17,12 @@ Private Sub GetArchiveName(sArch As String) As String
Public Sub _Search() As Boolean
Try CCompilation.Init()
If Error Then Return True
Public Sub _Compile(sArch As String) As Boolean
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment