diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0ff56c5cd..921896034 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -423,6 +423,32 @@ jobs: -DANDROID_PLATFORM=24 -DANDROID_ABI=arm64-v8a -DBUILD_SHARED_LIBS=OFF -DWITH_VM=OFF cmake --build build + check-abi: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + name: Checkout current + - uses: actions/checkout@v6 + name: Checkout 1.15 + with: + path: hashlink_1.15 + ref: 1.15 + - run: | + sudo apt-get update + sudo apt-get install abigail-tools + name: Setup abi tools + - run: | + make DEBUG=1 -j8 libhl.so + name: Build current + - run: | + make -C hashlink_1.15 DEBUG=1 -j8 libhl + name: Build 1.15 + - run: | + (cd hashlink_1.15 && abidw --header-file src/hl.h libhl.so > libhl.abi) + abidw --header-file src/hl.h libhl.so > libhl.abi + + abidiff hashlink_1.15/libhl.abi libhl.abi --no-added-syms --suppr other/abidiff.suppr + haxe-test-suite: needs: build strategy: @@ -527,7 +553,7 @@ jobs: publish-latest-release: ########################################################### runs-on: ubuntu-latest - needs: [build, haxe-test-suite] + needs: [build, check-abi, haxe-test-suite] if: github.ref == 'refs/heads/master' concurrency: publish-latest-release # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idconcurrency diff --git a/other/abidiff.suppr b/other/abidiff.suppr new file mode 100644 index 000000000..882dc60a9 --- /dev/null +++ b/other/abidiff.suppr @@ -0,0 +1,27 @@ +[suppress_type] + type_kind = enum + name = hl_type_kind + changed_enumerators = HLAST + +# pcre2 was accidentally exported by libhl.so +[suppress_function] + symbol_name_regexp = ^_?pcre(2|16)_ + drop = yes + +[suppress_variable] + symbol_name_regexp = ^_?pcre(2|16)_ + drop = yes + +# accidentally exported, but never part of hl.h +[suppress_function] + symbol_name_regexp = hl_(cache_init|internal_capture_stack|mlookup_alloc|mlookup_find|mlookup_set_impl) + drop = yes + +[suppress_function] + symbol_name_regexp = gc_get_mark_threads + drop = yes + +# exported explicitly, but never part of hl.h +[suppress_variable] + symbol_name_regexp = hl_closure_stack_capture + drop = yes diff --git a/src/hl.h b/src/hl.h index 2da71da81..f5be95ebd 100644 --- a/src/hl.h +++ b/src/hl.h @@ -630,7 +630,7 @@ typedef struct { } hl_setup_t; HL_API hl_setup_t hl_setup; -HL_API void hl_sys_init(); +HL_API void hl_sys_init( void **args, int nargs, void *hlfile ); HL_API double hl_nan( void ); HL_API bool hl_is_dynamic( hl_type *t ); @@ -1020,6 +1020,15 @@ HL_API hl_track_info hl_track; #endif +// -------------- COMPAT ------------------------------------ + +HL_API void hl_setup_longjump( void *j ); +HL_API void hl_setup_exception( void *resolve_symbol, void *capture_stack ); +HL_API void hl_set_debug_mode( bool b ); +HL_API void hl_setup_callbacks(void* sc, void* gw); +HL_API void hl_setup_callbacks2(void* sc, void* gw, int flags); +HL_API void hl_setup_reload_check( void *freload, void *param ); + C_FUNCTION_END #endif diff --git a/src/hlc_main.c b/src/hlc_main.c index e69a39a83..21cc5948e 100644 --- a/src/hlc_main.c +++ b/src/hlc_main.c @@ -160,7 +160,7 @@ int main(int argc, char *argv[]) { hl_setup.get_wrapper = hlc_get_wrapper; hl_setup.sys_args = (pchar**)(argv + 1); hl_setup.sys_nargs = argc - 1; - hl_sys_init(); + hl_sys_init(NULL, 0, NULL); tf.ret = &hlt_void; clt.kind = HFUN; clt.fun = &tf; diff --git a/src/main.c b/src/main.c index a25b673cc..8c00041ab 100644 --- a/src/main.c +++ b/src/main.c @@ -272,7 +272,7 @@ int main(int argc, pchar *argv[]) { hl_setup.file_path = file; hl_setup.sys_args = (pchar**)argv; hl_setup.sys_nargs = argc; - hl_sys_init(); + hl_sys_init(NULL, 0, NULL); hl_register_thread(&ctx); main_ctx = &ctx; ctx.file = file; diff --git a/src/std/error.c b/src/std/error.c index 8849cf2ab..e27100396 100644 --- a/src/std/error.c +++ b/src/std/error.c @@ -52,12 +52,27 @@ HL_PRIM uchar *hl_resolve_symbol( void *addr, uchar *out, int *outSize ) { return hl_setup.resolve_symbol(addr, out, outSize); } +static void (*throw_jump)( jmp_buf, int ) = NULL; + +HL_PRIM void hl_setup_longjump( void *j ) { + throw_jump = j; +} + +HL_PRIM void hl_setup_exception( void *resolve_symbol, void *capture_stack ) { + hl_setup.resolve_symbol = resolve_symbol; + hl_setup.capture_stack = capture_stack; +} + HL_PRIM void hl_set_error_handler( vclosure *d ) { hl_thread_info *t = hl_get_thread(); t->trap_uncaught = t->trap_current; t->exc_handler = d; } +HL_PRIM void hl_set_debug_mode( bool b ) { + hl_setup.is_debugger_enabled = b; +} + static bool break_on_trap( hl_thread_info *t, hl_trap_ctx *trap, vdynamic *v ) { bool unwrapped = false; vdynamic *vvalue = NULL; diff --git a/src/std/fun.c b/src/std/fun.c index fafa8177e..4ec5ad22e 100644 --- a/src/std/fun.c +++ b/src/std/fun.c @@ -113,6 +113,20 @@ HL_PRIM bool hl_fun_compare( vdynamic *a, vdynamic *b ) { // ------------ DYNAMIC CALLS +typedef void *(*fptr_static_call)(void *fun, hl_type *t, void **args, vdynamic *out); +typedef void *(*fptr_get_wrapper)(hl_type *t); + +HL_PRIM void hl_setup_callbacks2( void *c, void *w, int flags ) { + hl_setup.static_call = (fptr_static_call)c; + hl_setup.get_wrapper = (fptr_get_wrapper)w; + hl_setup.static_call_ref = flags & 1; +} + +HL_PRIM void hl_setup_callbacks( void *c, void *w ) { + hl_setup.static_call = (fptr_static_call)c; + hl_setup.get_wrapper = (fptr_get_wrapper)w; +} + #define HL_MAX_ARGS 9 HL_PRIM vdynamic* hl_call_method( vdynamic *c, varray *args ) { diff --git a/src/std/sys.c b/src/std/sys.c index 7cfeb0d7d..e8217e91b 100644 --- a/src/std/sys.c +++ b/src/std/sys.c @@ -159,6 +159,11 @@ HL_PRIM void hl_sys_print( vbyte *msg ) { hl_blocking(false); } +HL_PRIM void hl_setup_profiler( void *profile_event, void *before_exit ) { + hl_setup.before_exit = before_exit; + hl_setup.profile_event = profile_event; +} + HL_PRIM void hl_sys_profile_event( int code, vbyte *data, int dataLen ) { if( hl_setup.profile_event ) hl_setup.profile_event(code, data, dataLen); } @@ -168,6 +173,18 @@ HL_PRIM void hl_sys_exit( int code ) { exit(code); } +static void *f_vtune_init = NULL; +static void *g_vtune_module = NULL; +static void setup_vtune_wrapper() { + ((void(*)(void*))f_vtune_init)(g_vtune_module); +} + +HL_PRIM void hl_setup_vtune( void *vtune_init, void *m ) { + f_vtune_init = vtune_init; + g_vtune_module = m; + hl_setup.vtune_init = setup_vtune_wrapper; +} + HL_PRIM void hl_sys_vtune_init() { if( hl_setup.vtune_init ) hl_setup.vtune_init(); } @@ -674,10 +691,16 @@ HL_PRIM varray *hl_sys_args() { return a; } -HL_PRIM void hl_sys_init() { +HL_PRIM void hl_sys_init(void **args, int nargs, void *hlfile) { #ifdef HL_WIN QueryPerformanceFrequency(&qpcFrequency); #endif + if (hlfile) + hl_setup.file_path = (pchar*)hlfile; + if (args) + hl_setup.sys_args = (pchar**)args; + if (nargs) + hl_setup.sys_nargs = nargs; # ifdef HL_WIN_DESKTOP setlocale(LC_CTYPE, ""); // printf to current locale # endif @@ -687,6 +710,18 @@ HL_PRIM vbyte *hl_sys_hl_file() { return (vbyte*)hl_setup.file_path; } +static void *compat_reload_fun = NULL; +static void *compat_reload_param = NULL; +static bool reload_wrapper() { + return ((bool(*)(void*))compat_reload_fun)(compat_reload_param); +} + +HL_PRIM void hl_setup_reload_check( void *freload, void *param ) { + compat_reload_fun = freload; + compat_reload_param = param; + hl_setup.reload_check = reload_wrapper; +} + HL_PRIM bool hl_sys_check_reload( vbyte *debug_alt_file ) { return hl_setup.reload_check != NULL && hl_setup.reload_check(debug_alt_file); } @@ -696,7 +731,7 @@ HL_PRIM bool hl_sys_has_debugger() { } #ifndef HL_MOBILE -const char *hl_sys_special( const char *key ) { +HL_PRIM const char *hl_sys_special( const char *key ) { hl_error("Unknown sys_special key"); return NULL; } diff --git a/src/std/sys_android.c b/src/std/sys_android.c index df9519539..469685793 100644 --- a/src/std/sys_android.c +++ b/src/std/sys_android.c @@ -227,7 +227,7 @@ static const char* hl_sys_android_get_internal_storage_path(void) return hl_android_internal_files_path; } -const char *hl_sys_special( const char *key ) { +HL_PRIM const char *hl_sys_special( const char *key ) { if (strcmp(key, "android_external_storage_path")==0) return hl_sys_android_get_external_storage_path(); else if (strcmp(key, "android_internal_storage_path")==0) @@ -239,4 +239,4 @@ const char *hl_sys_special( const char *key ) { DEFINE_PRIM(_BYTES, sys_special, _BYTES); -#endif \ No newline at end of file +#endif diff --git a/src/std/sys_ios.m b/src/std/sys_ios.m index 602d0453e..7cae88686 100644 --- a/src/std/sys_ios.m +++ b/src/std/sys_ios.m @@ -54,7 +54,7 @@ static int ios_get_retina_scale_factor() return [[UIScreen mainScreen] scale]; } -const char *hl_sys_special( const char *key ) { +HL_PRIM const char *hl_sys_special( const char *key ) { if (strcmp(key, "ios_resource_path")==0) return ios_get_resource_path(); else if (strcmp(key, "ios_document_path")==0)