mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cc: experimental -fast option for tcc/codegen in the future
This commit is contained in:
parent
987f5fd2a1
commit
91df08f56d
@ -90,7 +90,7 @@ fn array_repeat_old(val voidptr, nr_repeats, elm_size int) array {
|
|||||||
return arr
|
return arr
|
||||||
}
|
}
|
||||||
|
|
||||||
// array.repeat returns new array with the given array elements
|
// array.repeat returns new array with the given array elements
|
||||||
// repeated `nr_repeat` times
|
// repeated `nr_repeat` times
|
||||||
pub fn (a array) repeat(nr_repeats int) array {
|
pub fn (a array) repeat(nr_repeats int) array {
|
||||||
if nr_repeats < 0 {
|
if nr_repeats < 0 {
|
||||||
@ -184,7 +184,7 @@ pub fn (a array) left(n int) array {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// array.right returns an array using same buffer as the given array
|
// array.right returns an array using same buffer as the given array
|
||||||
// but starting with the element of the given array beyond the index `n`.
|
// but starting with the element of the given array beyond the index `n`.
|
||||||
// If `n` is bigger or equal to the length of the given array,
|
// If `n` is bigger or equal to the length of the given array,
|
||||||
// returns an empty array of the same type as the given array.
|
// returns an empty array of the same type as the given array.
|
||||||
pub fn (a array) right(n int) array {
|
pub fn (a array) right(n int) array {
|
||||||
@ -204,8 +204,8 @@ fn (a array) slice2(start, _end int, end_max bool) array {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// array.slice returns an array using the same buffer as original array
|
// array.slice returns an array using the same buffer as original array
|
||||||
// but starting from the `start` element and ending with the element before
|
// but starting from the `start` element and ending with the element before
|
||||||
// the `end` element of the original array with the length and capacity
|
// the `end` element of the original array with the length and capacity
|
||||||
// set to the number of the elements in the slice.
|
// set to the number of the elements in the slice.
|
||||||
pub fn (a array) slice(start, _end int) array {
|
pub fn (a array) slice(start, _end int) array {
|
||||||
mut end := _end
|
mut end := _end
|
||||||
@ -251,7 +251,7 @@ pub fn (a mut array) push_many(val voidptr, size int) {
|
|||||||
a.len += size
|
a.len += size
|
||||||
}
|
}
|
||||||
|
|
||||||
// array.reverse returns a new array with the elements of
|
// array.reverse returns a new array with the elements of
|
||||||
// the original array in reverse order.
|
// the original array in reverse order.
|
||||||
pub fn (a array) reverse() array {
|
pub fn (a array) reverse() array {
|
||||||
arr := array {
|
arr := array {
|
||||||
@ -325,7 +325,7 @@ pub fn (a []bool) str() string {
|
|||||||
return sb.str()
|
return sb.str()
|
||||||
}
|
}
|
||||||
|
|
||||||
// []byte.hex returns a string with the hexadecimal representation
|
// []byte.hex returns a string with the hexadecimal representation
|
||||||
// of the byte elements of the array
|
// of the byte elements of the array
|
||||||
pub fn (b []byte) hex() string {
|
pub fn (b []byte) hex() string {
|
||||||
mut hex := malloc(b.len*2+1)
|
mut hex := malloc(b.len*2+1)
|
||||||
|
@ -64,27 +64,31 @@ fn (v mut V) cc() {
|
|||||||
// TCC on Linux by default, unless -cc was provided
|
// TCC on Linux by default, unless -cc was provided
|
||||||
// TODO if -cc = cc, TCC is still used, default compiler should be
|
// TODO if -cc = cc, TCC is still used, default compiler should be
|
||||||
// used instead.
|
// used instead.
|
||||||
$if linux {
|
if v.pref.fast {
|
||||||
$if !android {
|
$if linux {
|
||||||
vdir := os.dir(vexe)
|
$if !android {
|
||||||
tcc_3rd := '$vdir/thirdparty/tcc/bin/tcc'
|
vdir := os.dir(vexe)
|
||||||
//println('tcc third "$tcc_3rd"')
|
tcc_3rd := '$vdir/thirdparty/tcc/bin/tcc'
|
||||||
tcc_path := '/var/tmp/tcc/bin/tcc'
|
//println('tcc third "$tcc_3rd"')
|
||||||
if os.file_exists(tcc_3rd) && !os.file_exists(tcc_path) {
|
tcc_path := '/var/tmp/tcc/bin/tcc'
|
||||||
//println('moving tcc')
|
if os.file_exists(tcc_3rd) && !os.file_exists(tcc_path) {
|
||||||
// if there's tcc in thirdparty/, that means this is
|
//println('moving tcc')
|
||||||
// a prebuilt V_linux.zip.
|
// if there's tcc in thirdparty/, that means this is
|
||||||
// Until the libtcc1.a bug is fixed, we neeed to move
|
// a prebuilt V_linux.zip.
|
||||||
// it to /var/tmp/
|
// Until the libtcc1.a bug is fixed, we neeed to move
|
||||||
os.system('mv $vdir/thirdparty/tcc /var/tmp/')
|
// it to /var/tmp/
|
||||||
|
os.system('mv $vdir/thirdparty/tcc /var/tmp/')
|
||||||
|
}
|
||||||
|
if v.pref.ccompiler == 'cc' && os.file_exists(tcc_path) {
|
||||||
|
// TODO tcc bug, needs an empty libtcc1.a fila
|
||||||
|
//os.mkdir('/var/tmp/tcc/lib/tcc/')
|
||||||
|
//os.create('/var/tmp/tcc/lib/tcc/libtcc1.a')
|
||||||
|
v.pref.ccompiler = tcc_path
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if v.pref.ccompiler == 'cc' && os.file_exists(tcc_path) {
|
} $else {
|
||||||
// TODO tcc bug, needs an empty libtcc1.a fila
|
verror('-fast is only supported on Linux right now')
|
||||||
//os.mkdir('/var/tmp/tcc/lib/tcc/')
|
}
|
||||||
//os.create('/var/tmp/tcc/lib/tcc/libtcc1.a')
|
|
||||||
v.pref.ccompiler = tcc_path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//linux_host := os.user_os() == 'linux'
|
//linux_host := os.user_os() == 'linux'
|
||||||
v.log('cc() isprod=$v.pref.is_prod outname=$v.out_name')
|
v.log('cc() isprod=$v.pref.is_prod outname=$v.out_name')
|
||||||
|
@ -114,6 +114,7 @@ pub mut:
|
|||||||
// work on the builtin module itself.
|
// work on the builtin module itself.
|
||||||
//generating_vh bool
|
//generating_vh bool
|
||||||
comptime_define string // -D vfmt for `if $vfmt {`
|
comptime_define string // -D vfmt for `if $vfmt {`
|
||||||
|
fast bool // use tcc/x64 codegen
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should be called by main at the end of the compilation process, to cleanup
|
// Should be called by main at the end of the compilation process, to cleanup
|
||||||
@ -930,6 +931,7 @@ pub fn new_v(args[]string) &V {
|
|||||||
is_run: 'run' in args
|
is_run: 'run' in args
|
||||||
autofree: '-autofree' in args
|
autofree: '-autofree' in args
|
||||||
compress: '-compress' in args
|
compress: '-compress' in args
|
||||||
|
fast: '-fast' in args
|
||||||
is_repl: is_repl
|
is_repl: is_repl
|
||||||
build_mode: build_mode
|
build_mode: build_mode
|
||||||
cflags: cflags
|
cflags: cflags
|
||||||
|
Loading…
x
Reference in New Issue
Block a user