mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: enable -gc boehm
by default (#14577)
This commit is contained in:
@ -3,16 +3,16 @@ module builtin
|
||||
$if dynamic_boehm ? {
|
||||
$if windows {
|
||||
$if tinyc {
|
||||
#flag -I@VEXEROOT/thirdparty/libgc/include
|
||||
#flag -L@VEXEROOT/thirdparty/tcc/lib
|
||||
#flag -I @VEXEROOT/thirdparty/libgc/include
|
||||
#flag -L @VEXEROOT/thirdparty/tcc/lib
|
||||
#flag -lgc
|
||||
} $else $if msvc {
|
||||
#flag -DGC_BUILTIN_ATOMIC=1
|
||||
#flag -I@VEXEROOT/thirdparty/libgc/include
|
||||
#flag -I @VEXEROOT/thirdparty/libgc/include
|
||||
} $else {
|
||||
#flag -DGC_WIN32_THREADS=1
|
||||
#flag -DGC_BUILTIN_ATOMIC=1
|
||||
#flag -I@VEXEROOT/thirdparty/libgc
|
||||
#flag -I @VEXEROOT/thirdparty/libgc
|
||||
#flag @VEXEROOT/thirdparty/libgc/gc.o
|
||||
}
|
||||
} $else {
|
||||
@ -31,7 +31,7 @@ $if dynamic_boehm ? {
|
||||
#flag -DGC_BUILTIN_ATOMIC=1
|
||||
$if macos || linux {
|
||||
#flag -DGC_PTHREADS=1
|
||||
#flag -I@VEXEROOT/thirdparty/libgc/include
|
||||
#flag -I @VEXEROOT/thirdparty/libgc/include
|
||||
$if (prod && !tinyc && !debug) || !(amd64 || arm64 || i386 || arm32) {
|
||||
// TODO: replace the architecture check with a `!$exists("@VEXEROOT/thirdparty/tcc/lib/libgc.a")` comptime call
|
||||
#flag @VEXEROOT/thirdparty/libgc/gc.o
|
||||
@ -45,7 +45,7 @@ $if dynamic_boehm ? {
|
||||
#flag -DBUS_PAGE_FAULT=T_PAGEFLT
|
||||
#flag -DGC_PTHREADS=1
|
||||
$if !tinyc {
|
||||
#flag -I@VEXEROOT/thirdparty/libgc/include
|
||||
#flag -I @VEXEROOT/thirdparty/libgc/include
|
||||
#flag @VEXEROOT/thirdparty/libgc/gc.o
|
||||
}
|
||||
$if tinyc {
|
||||
@ -62,11 +62,11 @@ $if dynamic_boehm ? {
|
||||
#flag -DGC_NOT_DLL=1
|
||||
#flag -DGC_WIN32_THREADS=1
|
||||
$if tinyc {
|
||||
#flag -I@VEXEROOT/thirdparty/libgc/include
|
||||
#flag -I @VEXEROOT/thirdparty/libgc/include
|
||||
#flag @VEXEROOT/thirdparty/tcc/lib/libgc.a
|
||||
#flag -luser32
|
||||
} $else {
|
||||
#flag -I@VEXEROOT/thirdparty/libgc/include
|
||||
#flag -I @VEXEROOT/thirdparty/libgc/include
|
||||
#flag @VEXEROOT/thirdparty/libgc/gc.o
|
||||
}
|
||||
} $else $if $pkgconfig('bdw-gc') {
|
||||
|
@ -93,6 +93,13 @@ fn (mut v Builder) post_process_c_compiler_output(res os.Result) {
|
||||
}
|
||||
return
|
||||
}
|
||||
if res.exit_code != 0 && v.pref.gc_mode != .no_gc && res.output.contains('libgc.a') {
|
||||
$if windows {
|
||||
verror(r'Your V installation may be out-of-date. Try removing `thirdparty\tcc\` and running `.\make.bat`')
|
||||
} $else {
|
||||
verror('Your V installation may be out-of-date. Try removing `thirdparty/tcc/` and running `make`')
|
||||
}
|
||||
}
|
||||
for emsg_marker in [builder.c_verror_message_marker, 'error: include file '] {
|
||||
if res.output.contains(emsg_marker) {
|
||||
emessage := res.output.all_after(emsg_marker).all_before('\n').all_before('\r').trim_right('\r\n')
|
||||
|
@ -117,10 +117,14 @@ pub fn (cflags []CFlag) defines_others_libs() ([]string, []string, []string) {
|
||||
mut others := []string{}
|
||||
mut libs := []string{}
|
||||
for copt in copts_without_obj_files {
|
||||
if copt.starts_with('-l') || copt.ends_with('.a') {
|
||||
if copt.starts_with('-l') {
|
||||
libs << copt
|
||||
continue
|
||||
}
|
||||
if copt.ends_with('.a') {
|
||||
libs << '"$copt"'
|
||||
continue
|
||||
}
|
||||
if copt.starts_with('-D') {
|
||||
defines << copt
|
||||
continue
|
||||
|
@ -85,6 +85,18 @@ pub fn (mut p Preferences) fill_with_defaults() {
|
||||
}
|
||||
rpath_name := os.file_name(rpath)
|
||||
p.building_v = !p.is_repl && (rpath_name == 'v' || rpath_name == 'vfmt.v')
|
||||
if p.gc_mode == .unknown {
|
||||
if p.backend != .c || p.building_v || p.is_bare || p.ccompiler == 'msvc' {
|
||||
p.gc_mode = .no_gc
|
||||
p.build_options << ['-gc', 'none']
|
||||
} else {
|
||||
// enable the GC by default
|
||||
p.gc_mode = .boehm_full_opt
|
||||
p.parse_define('gcboehm')
|
||||
p.parse_define('gcboehm_full')
|
||||
p.parse_define('gcboehm_opt')
|
||||
}
|
||||
}
|
||||
if p.os == ._auto {
|
||||
// No OS specifed? Use current system
|
||||
p.os = get_host_os()
|
||||
|
@ -24,6 +24,7 @@ pub enum AssertFailureMode {
|
||||
}
|
||||
|
||||
pub enum GarbageCollectionMode {
|
||||
unknown
|
||||
no_gc
|
||||
boehm_full // full garbage collection mode
|
||||
boehm_incr // incremental garbage colletion mode
|
||||
@ -204,7 +205,7 @@ pub mut:
|
||||
cleanup_files []string // list of temporary *.tmp.c and *.tmp.c.rsp files. Cleaned up on successfull builds.
|
||||
build_options []string // list of options, that should be passed down to `build-module`, if needed for -usecache
|
||||
cache_manager vcache.CacheManager
|
||||
gc_mode GarbageCollectionMode = .no_gc // .no_gc, .boehm, .boehm_leak, ...
|
||||
gc_mode GarbageCollectionMode = .unknown // .no_gc, .boehm, .boehm_leak, ...
|
||||
assert_failure_mode AssertFailureMode // whether to call abort() or print_backtrace() after an assertion failure
|
||||
message_limit int = 100 // the maximum amount of warnings/errors/notices that will be accumulated
|
||||
nofloat bool // for low level code, like kernels: replaces f32 with u32 and f64 with u64
|
||||
@ -327,9 +328,15 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
|
||||
'-gc' {
|
||||
gc_mode := cmdline.option(current_args, '-gc', '')
|
||||
match gc_mode {
|
||||
'', 'none' {
|
||||
'none' {
|
||||
res.gc_mode = .no_gc
|
||||
}
|
||||
'', 'boehm' {
|
||||
res.gc_mode = .boehm_full_opt // default mode
|
||||
res.parse_define('gcboehm')
|
||||
res.parse_define('gcboehm_full')
|
||||
res.parse_define('gcboehm_opt')
|
||||
}
|
||||
'boehm_full' {
|
||||
res.gc_mode = .boehm_full
|
||||
res.parse_define('gcboehm')
|
||||
@ -352,12 +359,6 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
|
||||
res.parse_define('gcboehm_incr')
|
||||
res.parse_define('gcboehm_opt')
|
||||
}
|
||||
'boehm' {
|
||||
res.gc_mode = .boehm_full_opt // default mode
|
||||
res.parse_define('gcboehm')
|
||||
res.parse_define('gcboehm_full')
|
||||
res.parse_define('gcboehm_opt')
|
||||
}
|
||||
'boehm_leak' {
|
||||
res.gc_mode = .boehm_leak
|
||||
res.parse_define('gcboehm')
|
||||
|
@ -86,7 +86,7 @@ fn test_all() {
|
||||
base_filename := os.file_name(test).replace('.v', '')
|
||||
exe_filename := '$wrkdir/$base_filename'
|
||||
full_path_to_source_file := os.join_path(vroot, test)
|
||||
compile_cmd := '${os.quoted_path(vexe)} -o ${os.quoted_path(exe_filename)} -cg -cflags "-w" -experimental -autofree ${os.quoted_path(full_path_to_source_file)}'
|
||||
compile_cmd := '${os.quoted_path(vexe)} -o ${os.quoted_path(exe_filename)} -cg -cflags "-w" -experimental -gc none -autofree ${os.quoted_path(full_path_to_source_file)}'
|
||||
vprintln('compile cmd: ${bold(compile_cmd)}')
|
||||
res := os.execute(compile_cmd)
|
||||
if res.exit_code != 0 {
|
||||
|
@ -55,7 +55,14 @@ pub fn new_cache_manager(opts []string) CacheManager {
|
||||
os.write_file(readme_file, readme_content) or { panic(err) }
|
||||
dlog(@FN, 'created readme_file:\n $readme_file')
|
||||
}
|
||||
original_vopts := opts.join('|')
|
||||
mut deduped_opts := map[string]bool{}
|
||||
for o in opts {
|
||||
deduped_opts[o] = true
|
||||
}
|
||||
deduped_opts_keys := deduped_opts.keys().filter(it != '' && !it.starts_with("['gcboehm', "))
|
||||
// TODO: do not filter the gcboehm options here, instead just start `v build-module vlib/builtin` without the -d gcboehm etc.
|
||||
// Note: the current approach of filtering the gcboehm keys may interfere with (potential) other gc modes.
|
||||
original_vopts := deduped_opts_keys.join('|')
|
||||
return CacheManager{
|
||||
basepath: vcache_basepath
|
||||
vopts: original_vopts
|
||||
|
Reference in New Issue
Block a user