1
0
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:
Alexander Medvednikov
2019-11-01 00:37:24 +03:00
parent 987f5fd2a1
commit 91df08f56d
3 changed files with 32 additions and 26 deletions

View File

@ -64,27 +64,31 @@ fn (v mut V) cc() {
// TCC on Linux by default, unless -cc was provided
// TODO if -cc = cc, TCC is still used, default compiler should be
// used instead.
$if linux {
$if !android {
vdir := os.dir(vexe)
tcc_3rd := '$vdir/thirdparty/tcc/bin/tcc'
//println('tcc third "$tcc_3rd"')
tcc_path := '/var/tmp/tcc/bin/tcc'
if os.file_exists(tcc_3rd) && !os.file_exists(tcc_path) {
//println('moving tcc')
// if there's tcc in thirdparty/, that means this is
// a prebuilt V_linux.zip.
// Until the libtcc1.a bug is fixed, we neeed to move
// it to /var/tmp/
os.system('mv $vdir/thirdparty/tcc /var/tmp/')
if v.pref.fast {
$if linux {
$if !android {
vdir := os.dir(vexe)
tcc_3rd := '$vdir/thirdparty/tcc/bin/tcc'
//println('tcc third "$tcc_3rd"')
tcc_path := '/var/tmp/tcc/bin/tcc'
if os.file_exists(tcc_3rd) && !os.file_exists(tcc_path) {
//println('moving tcc')
// if there's tcc in thirdparty/, that means this is
// a prebuilt V_linux.zip.
// Until the libtcc1.a bug is fixed, we neeed to move
// 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) {
// 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
}
}
} $else {
verror('-fast is only supported on Linux right now')
}
}
//linux_host := os.user_os() == 'linux'
v.log('cc() isprod=$v.pref.is_prod outname=$v.out_name')