compiler: fix #1193 . Flag -c_options is now named -cflags.

You can also pass -cflags '-Os -fno-inline-small-functions'
pull/1236/head
Delyan Angelov 2019-07-18 20:00:49 +03:00 committed by Alexander Medvednikov
parent 97e97222ee
commit 38c58f9f1b
1 changed files with 9 additions and 8 deletions

View File

@ -91,9 +91,10 @@ mut:
sanitize bool // use Clang's new "-fsanitize" option sanitize bool // use Clang's new "-fsanitize" option
is_debug bool // keep compiled C files is_debug bool // keep compiled C files
no_auto_free bool // `v -nofree` disable automatic `free()` insertion for better performance in some applications (e.g. compilers) no_auto_free bool // `v -nofree` disable automatic `free()` insertion for better performance in some applications (e.g. compilers)
c_options string // Additional options which will be passed to the C compiler. cflags string // Additional options which will be passed to the C compiler.
// For example, passing -c_options=-Os will cause the C compiler to optimize the generated binaries for size. // For example, passing -cflags -Os will cause the C compiler to optimize the generated binaries for size.
// You could pass several -c_options=XXX arguments. They will be merged with each other. // You could pass several -cflags XXX arguments. They will be merged with each other.
// You can also quote several options at the same time: -cflags '-Os -fno-inline-small-functions'.
} }
@ -536,7 +537,7 @@ fn (v mut V) cc() {
} }
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')
mut a := [v.pref.c_options, '-w'] // arguments for the C compiler mut a := [v.pref.cflags, '-w'] // arguments for the C compiler
flags := v.table.flags.join(' ') flags := v.table.flags.join(' ')
//mut shared := '' //mut shared := ''
if v.pref.is_so { if v.pref.is_so {
@ -987,10 +988,10 @@ fn new_v(args[]string) *V {
} }
} }
mut c_options := '' mut cflags := ''
for ci, cv in args { for ci, cv in args {
if cv.starts_with('-c_options=') { if cv == '-cflags' {
c_options += cv.replace('-c_options=','') + ' ' cflags += args[ci+1] + ' '
} }
} }
@ -1013,7 +1014,7 @@ fn new_v(args[]string) *V {
is_run: args.contains('run') is_run: args.contains('run')
is_repl: args.contains('-repl') is_repl: args.contains('-repl')
build_mode: build_mode build_mode: build_mode
c_options: c_options cflags: cflags
} }
if pref.is_so { if pref.is_so {