all: enable `-gc boehm` by default (#14577)

master
spaceface 2022-06-08 23:44:29 +02:00 committed by GitHub
parent e6580fefaa
commit 4ed9780b80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 62 additions and 25 deletions

View File

@ -45,7 +45,7 @@ jobs:
- name: Compile to raw Android (non-graphic) compatible - name: Compile to raw Android (non-graphic) compatible
run: | run: |
# Test that V can compile non-graphic app to Android compatible code *without* using the -apk flag # Test that V can compile non-graphic app to Android compatible code *without* using the -apk flag
./v -os android examples/toml.v ./v -os android -gc none examples/toml.v
linux-cross: linux-cross:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@ -98,7 +98,7 @@ jobs:
- name: toml.v can be compiled to raw Android C - name: toml.v can be compiled to raw Android C
run: | run: |
# Test that V can compile non-graphic app to Android compatible code *without* using the -apk flag # Test that V can compile non-graphic app to Android compatible code *without* using the -apk flag
./v -os android examples/toml.v ./v -os android -gc none examples/toml.v
windows-cross: windows-cross:

View File

@ -228,7 +228,7 @@ jobs:
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v' if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 180 timeout-minutes: 180
env: env:
VFLAGS: -cc clang VFLAGS: -cc clang -gc none
VJOBS: 1 VJOBS: 1
VTEST_SHOW_START: 1 VTEST_SHOW_START: 1
steps: steps:

View File

@ -17,7 +17,7 @@ jobs:
alpine-docker-musl-gcc: alpine-docker-musl-gcc:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v' if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121 timeout-minutes: 181
container: container:
# Alpine docker pre-built container # Alpine docker pre-built container
image: thevlang/vlang:alpine-build image: thevlang/vlang:alpine-build
@ -58,7 +58,7 @@ jobs:
env: env:
V_CI_MUSL: 1 V_CI_MUSL: 1
V_CI_UBUNTU_MUSL: 1 V_CI_UBUNTU_MUSL: 1
VFLAGS: -cc musl-gcc VFLAGS: -cc musl-gcc -gc none
volumes: volumes:
- ${{github.workspace}}:/opt/vlang - ${{github.workspace}}:/opt/vlang

View File

@ -14,6 +14,7 @@ jobs:
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v' if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121 timeout-minutes: 121
env: env:
VFLAGS: -gc none
VAB_FLAGS: --api 30 --build-tools 29.0.0 -v 3 VAB_FLAGS: --api 30 --build-tools 29.0.0 -v 3
steps: steps:
- uses: actions/setup-java@v2 - uses: actions/setup-java@v2

View File

@ -14,6 +14,8 @@ jobs:
vinix-build: vinix-build:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v' if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
env:
VFLAGS: -gc none
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2

View File

@ -28,6 +28,9 @@ endif
ifeq ($(_SYS),Linux) ifeq ($(_SYS),Linux)
LINUX := 1 LINUX := 1
TCCOS := linux TCCOS := linux
ifneq ($(shell ldd /bin/ls | grep musl),)
TCCOS := linuxmusl
endif
endif endif
ifeq ($(_SYS),Darwin) ifeq ($(_SYS),Darwin)
@ -113,7 +116,7 @@ endif
check_for_working_tcc: check_for_working_tcc:
@$(TMPTCC)/tcc.exe --version > /dev/null 2> /dev/null || echo "The executable '$(TMPTCC)/tcc.exe' does not work." @$(TMPTCC)/tcc.exe --version > /dev/null 2> /dev/null || echo "The executable '$(TMPTCC)/tcc.exe' does not work."
fresh_vc: fresh_vc:
rm -rf $(VC) rm -rf $(VC)
$(GITFASTCLONE) $(VCREPO) $(VC) $(GITFASTCLONE) $(VCREPO) $(VC)

View File

@ -3,16 +3,16 @@ module builtin
$if dynamic_boehm ? { $if dynamic_boehm ? {
$if windows { $if windows {
$if tinyc { $if tinyc {
#flag -I@VEXEROOT/thirdparty/libgc/include #flag -I @VEXEROOT/thirdparty/libgc/include
#flag -L@VEXEROOT/thirdparty/tcc/lib #flag -L @VEXEROOT/thirdparty/tcc/lib
#flag -lgc #flag -lgc
} $else $if msvc { } $else $if msvc {
#flag -DGC_BUILTIN_ATOMIC=1 #flag -DGC_BUILTIN_ATOMIC=1
#flag -I@VEXEROOT/thirdparty/libgc/include #flag -I @VEXEROOT/thirdparty/libgc/include
} $else { } $else {
#flag -DGC_WIN32_THREADS=1 #flag -DGC_WIN32_THREADS=1
#flag -DGC_BUILTIN_ATOMIC=1 #flag -DGC_BUILTIN_ATOMIC=1
#flag -I@VEXEROOT/thirdparty/libgc #flag -I @VEXEROOT/thirdparty/libgc
#flag @VEXEROOT/thirdparty/libgc/gc.o #flag @VEXEROOT/thirdparty/libgc/gc.o
} }
} $else { } $else {
@ -31,7 +31,7 @@ $if dynamic_boehm ? {
#flag -DGC_BUILTIN_ATOMIC=1 #flag -DGC_BUILTIN_ATOMIC=1
$if macos || linux { $if macos || linux {
#flag -DGC_PTHREADS=1 #flag -DGC_PTHREADS=1
#flag -I@VEXEROOT/thirdparty/libgc/include #flag -I @VEXEROOT/thirdparty/libgc/include
$if (prod && !tinyc && !debug) || !(amd64 || arm64 || i386 || arm32) { $if (prod && !tinyc && !debug) || !(amd64 || arm64 || i386 || arm32) {
// TODO: replace the architecture check with a `!$exists("@VEXEROOT/thirdparty/tcc/lib/libgc.a")` comptime call // TODO: replace the architecture check with a `!$exists("@VEXEROOT/thirdparty/tcc/lib/libgc.a")` comptime call
#flag @VEXEROOT/thirdparty/libgc/gc.o #flag @VEXEROOT/thirdparty/libgc/gc.o
@ -45,7 +45,7 @@ $if dynamic_boehm ? {
#flag -DBUS_PAGE_FAULT=T_PAGEFLT #flag -DBUS_PAGE_FAULT=T_PAGEFLT
#flag -DGC_PTHREADS=1 #flag -DGC_PTHREADS=1
$if !tinyc { $if !tinyc {
#flag -I@VEXEROOT/thirdparty/libgc/include #flag -I @VEXEROOT/thirdparty/libgc/include
#flag @VEXEROOT/thirdparty/libgc/gc.o #flag @VEXEROOT/thirdparty/libgc/gc.o
} }
$if tinyc { $if tinyc {
@ -62,11 +62,11 @@ $if dynamic_boehm ? {
#flag -DGC_NOT_DLL=1 #flag -DGC_NOT_DLL=1
#flag -DGC_WIN32_THREADS=1 #flag -DGC_WIN32_THREADS=1
$if tinyc { $if tinyc {
#flag -I@VEXEROOT/thirdparty/libgc/include #flag -I @VEXEROOT/thirdparty/libgc/include
#flag @VEXEROOT/thirdparty/tcc/lib/libgc.a #flag @VEXEROOT/thirdparty/tcc/lib/libgc.a
#flag -luser32 #flag -luser32
} $else { } $else {
#flag -I@VEXEROOT/thirdparty/libgc/include #flag -I @VEXEROOT/thirdparty/libgc/include
#flag @VEXEROOT/thirdparty/libgc/gc.o #flag @VEXEROOT/thirdparty/libgc/gc.o
} }
} $else $if $pkgconfig('bdw-gc') { } $else $if $pkgconfig('bdw-gc') {

View File

@ -93,6 +93,13 @@ fn (mut v Builder) post_process_c_compiler_output(res os.Result) {
} }
return 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 '] { for emsg_marker in [builder.c_verror_message_marker, 'error: include file '] {
if res.output.contains(emsg_marker) { if res.output.contains(emsg_marker) {
emessage := res.output.all_after(emsg_marker).all_before('\n').all_before('\r').trim_right('\r\n') emessage := res.output.all_after(emsg_marker).all_before('\n').all_before('\r').trim_right('\r\n')

View File

@ -117,10 +117,14 @@ pub fn (cflags []CFlag) defines_others_libs() ([]string, []string, []string) {
mut others := []string{} mut others := []string{}
mut libs := []string{} mut libs := []string{}
for copt in copts_without_obj_files { for copt in copts_without_obj_files {
if copt.starts_with('-l') || copt.ends_with('.a') { if copt.starts_with('-l') {
libs << copt libs << copt
continue continue
} }
if copt.ends_with('.a') {
libs << '"$copt"'
continue
}
if copt.starts_with('-D') { if copt.starts_with('-D') {
defines << copt defines << copt
continue continue

View File

@ -85,6 +85,18 @@ pub fn (mut p Preferences) fill_with_defaults() {
} }
rpath_name := os.file_name(rpath) rpath_name := os.file_name(rpath)
p.building_v = !p.is_repl && (rpath_name == 'v' || rpath_name == 'vfmt.v') 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 { if p.os == ._auto {
// No OS specifed? Use current system // No OS specifed? Use current system
p.os = get_host_os() p.os = get_host_os()

View File

@ -24,6 +24,7 @@ pub enum AssertFailureMode {
} }
pub enum GarbageCollectionMode { pub enum GarbageCollectionMode {
unknown
no_gc no_gc
boehm_full // full garbage collection mode boehm_full // full garbage collection mode
boehm_incr // incremental garbage colletion 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. 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 build_options []string // list of options, that should be passed down to `build-module`, if needed for -usecache
cache_manager vcache.CacheManager 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 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 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 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' {
gc_mode := cmdline.option(current_args, '-gc', '') gc_mode := cmdline.option(current_args, '-gc', '')
match gc_mode { match gc_mode {
'', 'none' { 'none' {
res.gc_mode = .no_gc 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' { 'boehm_full' {
res.gc_mode = .boehm_full res.gc_mode = .boehm_full
res.parse_define('gcboehm') 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_incr')
res.parse_define('gcboehm_opt') 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' { 'boehm_leak' {
res.gc_mode = .boehm_leak res.gc_mode = .boehm_leak
res.parse_define('gcboehm') res.parse_define('gcboehm')

View File

@ -86,7 +86,7 @@ fn test_all() {
base_filename := os.file_name(test).replace('.v', '') base_filename := os.file_name(test).replace('.v', '')
exe_filename := '$wrkdir/$base_filename' exe_filename := '$wrkdir/$base_filename'
full_path_to_source_file := os.join_path(vroot, test) 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)}') vprintln('compile cmd: ${bold(compile_cmd)}')
res := os.execute(compile_cmd) res := os.execute(compile_cmd)
if res.exit_code != 0 { if res.exit_code != 0 {

View File

@ -55,7 +55,14 @@ pub fn new_cache_manager(opts []string) CacheManager {
os.write_file(readme_file, readme_content) or { panic(err) } os.write_file(readme_file, readme_content) or { panic(err) }
dlog(@FN, 'created readme_file:\n $readme_file') 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{ return CacheManager{
basepath: vcache_basepath basepath: vcache_basepath
vopts: original_vopts vopts: original_vopts