Fix hot code reloading on linux

pull/1056/head
Delyan Angelov 2019-07-09 21:54:23 +03:00 committed by Alexander Medvednikov
parent 3f916efb64
commit 932f6d1bef
1 changed files with 5 additions and 3 deletions

View File

@ -386,9 +386,11 @@ string _STR_TMP(const char *fmt, ...) {
#include <dlfcn.h> #include <dlfcn.h>
void* live_lib; void* live_lib;
int load_so(byteptr path) { int load_so(byteptr path) {
//printf("load_so %s\\n", path); char cpath[1024];
sprintf(cpath,"./%s", path);
//printf("load_so %s\\n", cpath);
if (live_lib) dlclose(live_lib); if (live_lib) dlclose(live_lib);
live_lib = dlopen(path, RTLD_LAZY); live_lib = dlopen(cpath, RTLD_LAZY);
if (!live_lib) {puts("open failed"); exit(1); return 0;} if (!live_lib) {puts("open failed"); exit(1); return 0;}
') ')
for so_fn in cgen.so_fns { for so_fn in cgen.so_fns {
@ -534,7 +536,7 @@ fn (v mut V) cc() {
flags := v.table.flags.join(' ') flags := v.table.flags.join(' ')
//mut shared := '' //mut shared := ''
if v.pref.is_so { if v.pref.is_so {
a << '-shared -fPIC'// -Wl,-z,defs' a << '-shared -fPIC '// -Wl,-z,defs'
v.out_name = v.out_name + '.so' v.out_name = v.out_name + '.so'
} }
if v.pref.is_prod { if v.pref.is_prod {