v.markused: mark all `pub` functions on `-shared -skip-unused`

pull/9699/head
Delyan Angelov 2021-04-12 09:24:07 +03:00
parent d7a64bbc8a
commit 8193efb379
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 27 additions and 19 deletions

View File

@ -11,20 +11,19 @@ const (
)
fn test_vexe() {
dump(vexe)
// dump(vexe)
assert vexe != ''
dump(os.executable())
dump(@FILE)
dump(cfolder)
dump(so_ext)
dump(library_file_name)
// dump(os.executable())
// dump(@FILE)
// dump(cfolder)
// dump(so_ext)
// dump(library_file_name)
}
fn test_can_compile_library() {
os.chdir(cfolder)
os.rm(library_file_name) or { }
res := v_compile('-d no_backtrace -o library -shared modules/library/library.v')
dump(res)
os.rm(library_file_name) or {}
v_compile('-d no_backtrace -o library -shared modules/library/library.v')
assert os.is_file(library_file_name)
}
@ -32,21 +31,26 @@ fn test_can_compile_main_program() {
os.chdir(cfolder)
assert os.is_file(library_file_name)
result := v_compile('run use.v')
dump(result)
// dump(result)
assert result.output.contains('res: 4')
os.rm(library_file_name) or { }
os.rm(library_file_name) or {}
}
fn test_can_compile_and_use_library_with_skip_unused() {
os.chdir(cfolder)
os.rm(library_file_name) or {}
v_compile('-skip-unused -d no_backtrace -o library -shared modules/library/library.v')
assert os.is_file(library_file_name)
result := v_compile('run use.v')
assert result.output.contains('res: 4')
os.rm(library_file_name) or {}
}
fn v_compile(vopts string) os.Result {
cmd := '"$vexe" -showcc $vopts'
dump(cmd)
// dump(cmd)
res := os.execute_or_panic(cmd)
dump(res)
// assert res.exit_code == 0
$if windows {
os.system('dir $cfolder /a')
} $else {
os.system('ls -al $cfolder')
}
// dump(res)
assert res.exit_code == 0
return res
}

View File

@ -143,6 +143,10 @@ pub fn mark_used(mut table ast.Table, pref &pref.Preferences, ast_files []ast.Fi
continue
}
}
if mfn.is_pub && pref.is_shared {
all_fn_root_names << k
continue
}
}
if pref.is_debug {
all_fn_root_names << 'panic_debug'