hot reload: no -sanitize is needed anymore, -live is now enough on both Linux and MacOS X

* hot reload for GL programs: force the main executable (the shared library loader) to be build with -rdynamic flag, when -live is passed to v compiler.

* hot reload: optimize away a redundant load_so/0 call at the start of the reload_so thread.

* hot code reload for MacOSX requires -flat_namespace flag instead of -rdynamic (on linux).
pull/1160/head
Delyan Angelov 2019-07-15 18:32:00 +03:00 committed by Alexander Medvednikov
parent 7c6f59afa6
commit 37aff9b107
2 changed files with 11 additions and 2 deletions

View File

@ -390,7 +390,7 @@ int load_so(byteptr path) {
cgen.genln('return 1; }
void reload_so() {
int last = 0;
int last = os__file_last_mod_unix(tos2("$file"));
while (1) {
// TODO use inotify
int now = os__file_last_mod_unix(tos2("$file"));
@ -536,6 +536,15 @@ fn (v mut V) cc() {
else {
a << '-g'
}
if v.pref.is_live || v.pref.is_so {
// See 'man dlopen', and test running a GUI program compiled with -live
if (v.os == .linux || os.user_os() == 'linux'){
a << '-rdynamic'
}
if (v.os == .mac || os.user_os() == 'mac'){
a << '-flat_namespace'
}
}
mut libs := ''// builtin.o os.o http.o etc
if v.pref.build_mode == .build {
a << '-c'

View File

@ -1,5 +1,5 @@
// Build this example with
// v -live -sanitize bounce.v
// v -live bounce.v
module main
import gx