mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v.builder: remove default link flags -lm, -ldl, -lpthread (use module specific link flags instead) (#10099)
This commit is contained in:
parent
b728d89069
commit
20a22453cf
@ -2,6 +2,10 @@ module dl
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
$if linux {
|
||||
#flag -ldl
|
||||
}
|
||||
|
||||
pub const (
|
||||
rtld_now = C.RTLD_NOW
|
||||
rtld_lazy = C.RTLD_LAZY
|
||||
|
@ -9,6 +9,15 @@ $if gcboehm ? {
|
||||
}
|
||||
#include "fontstash.h"
|
||||
#flag -I /usr/local/Cellar/freetype/2.10.2/include/freetype2
|
||||
|
||||
$if windows {
|
||||
$if tinyc {
|
||||
#flag @VEXEROOT/thirdparty/tcc/lib/openlibm.o
|
||||
}
|
||||
} $else {
|
||||
#flag -lm
|
||||
}
|
||||
|
||||
//#flag -lfreetype
|
||||
pub const (
|
||||
// TODO: fontstash.used_import is used to keep v from warning about unused imports
|
||||
|
@ -4,11 +4,15 @@
|
||||
module math
|
||||
|
||||
#include <math.h>
|
||||
|
||||
$if windows {
|
||||
$if tinyc {
|
||||
#flag @VEXEROOT/thirdparty/tcc/lib/openlibm.o
|
||||
}
|
||||
} $else {
|
||||
#flag -lm
|
||||
}
|
||||
|
||||
fn C.acos(x f64) f64
|
||||
|
||||
fn C.asin(x f64) f64
|
||||
|
@ -40,6 +40,8 @@ $if ios {
|
||||
#flag solaris -DSOKOL_NO_ENTRY
|
||||
// TODO end
|
||||
|
||||
#flag linux -ldl
|
||||
|
||||
$if gcboehm ? {
|
||||
#define SOKOL_MALLOC GC_MALLOC
|
||||
#define SOKOL_CALLOC(n,m) GC_MALLOC((n)*(m))
|
||||
|
13
vlib/sync/threads/threads.c.v
Normal file
13
vlib/sync/threads/threads.c.v
Normal file
@ -0,0 +1,13 @@
|
||||
module threads
|
||||
|
||||
// This module adds the necessary compiler flags for using threads.
|
||||
// It is automatically imported by code that does `go func()` .
|
||||
// See vlib/v/parser/pratt.v, search for ast.GoExpr .
|
||||
// The goal is that programs, that do not use threads at all will not need
|
||||
// to link to -lpthread etc.
|
||||
// NB: on some platforms like Android, linking -lpthread is not needed too.
|
||||
// See https://stackoverflow.com/a/31277163/1904615
|
||||
|
||||
$if !windows && !android {
|
||||
#flag -lpthread
|
||||
}
|
4
vlib/sync/threads/threads.v
Normal file
4
vlib/sync/threads/threads.v
Normal file
@ -0,0 +1,4 @@
|
||||
module threads
|
||||
|
||||
// This file is just a placeholder.
|
||||
// The actual implementation is backend/platform specific, so see threads.c.v, threads.js.v etc.
|
@ -380,20 +380,11 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
|
||||
// || os.user_os() == 'linux'
|
||||
if !v.pref.is_bare && v.pref.build_mode != .build_module
|
||||
&& v.pref.os in [.linux, .freebsd, .openbsd, .netbsd, .dragonfly, .solaris, .haiku] {
|
||||
ccoptions.linker_flags << '-lm'
|
||||
ccoptions.linker_flags << '-lpthread'
|
||||
// -ldl is a Linux only thing. BSDs have it in libc.
|
||||
if v.pref.os == .linux {
|
||||
ccoptions.linker_flags << '-ldl'
|
||||
}
|
||||
if v.pref.os in [.freebsd, .netbsd] {
|
||||
// Free/NetBSD: backtrace needs execinfo library while linking
|
||||
ccoptions.linker_flags << '-lexecinfo'
|
||||
}
|
||||
}
|
||||
if !v.pref.is_bare && v.pref.os == .js && os.user_os() == 'linux' {
|
||||
ccoptions.linker_flags << '-lm'
|
||||
}
|
||||
ccoptions.env_cflags = os.getenv('CFLAGS')
|
||||
ccoptions.env_ldflags = os.getenv('LDFLAGS')
|
||||
$if trace_ccoptions ? {
|
||||
|
@ -519,6 +519,7 @@ fn (mut p Parser) go_expr() ast.GoExpr {
|
||||
}
|
||||
}
|
||||
pos := spos.extend(p.prev_tok.position())
|
||||
p.register_auto_import('sync.threads')
|
||||
return ast.GoExpr{
|
||||
call_expr: call_expr
|
||||
pos: pos
|
||||
|
Loading…
Reference in New Issue
Block a user