From 960225f7a79f53609388347e8955987954c1dcac Mon Sep 17 00:00:00 2001 From: lemon Date: Thu, 21 Apr 2022 06:12:17 +0900 Subject: [PATCH] builtin: fix `-cc gcc -gc boehm` on linux and macos (#14115) --- cmd/tools/vtest-all.v | 12 ++++++++++++ vlib/builtin/builtin_d_gcboehm.c.v | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cmd/tools/vtest-all.v b/cmd/tools/vtest-all.v index 78823c1c8f..bc534041a7 100644 --- a/cmd/tools/vtest-all.v +++ b/cmd/tools/vtest-all.v @@ -81,6 +81,18 @@ fn get_all_commands() []Command { runcmd: .execute expect: 'Hello, World!\n' } + if os.getenv('V_CI_MUSL').len == 0 { + for compiler_name in ['clang', 'gcc'] { + if _ := os.find_abs_path_of_executable(compiler_name) { + res << Command{ + line: '$vexe -cc $compiler_name -gc boehm run examples/hello_world.v' + okmsg: '`v -cc $compiler_name -gc boehm run examples/hello_world.v` works' + runcmd: .execute + expect: 'Hello, World!\n' + } + } + } + } res << Command{ line: '$vexe interpret examples/hello_world.v' okmsg: 'V can interpret hello world.' diff --git a/vlib/builtin/builtin_d_gcboehm.c.v b/vlib/builtin/builtin_d_gcboehm.c.v index d50275fd13..02b74e7209 100644 --- a/vlib/builtin/builtin_d_gcboehm.c.v +++ b/vlib/builtin/builtin_d_gcboehm.c.v @@ -32,13 +32,14 @@ $if dynamic_boehm ? { $if macos || linux { #flag -DGC_PTHREADS=1 #flag -I@VEXEROOT/thirdparty/libgc/include - #flag -lpthread -ldl + #flag -lpthread $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 } $else { #flag @VEXEROOT/thirdparty/tcc/lib/libgc.a } + #flag -ldl } $else $if freebsd { // Tested on FreeBSD 13.0-RELEASE-p3, with clang, gcc and tcc: #flag -DBUS_PAGE_FAULT=T_PAGEFLT