Skip to content

Commit

Permalink
builder: use some -cstrict flags only with clang (gcc does not unders…
Browse files Browse the repository at this point in the history
…tand them)
  • Loading branch information
spytheman committed May 23, 2021
1 parent ded8897 commit 603e577
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions vlib/v/builder/cc.v
Expand Up @@ -199,17 +199,11 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
'-Wno-unused',
'-Wno-type-limits',
'-Wno-tautological-compare',
'-Wno-tautological-bitwise-compare',
// these cause various issues:
'-Wno-enum-conversion' /* used in vlib/sokol, where C enums in C structs are typed as V structs instead */,
'-Wno-sometimes-uninitialized' /* produced after exhaustive matches */,
'-Wno-shadow' /* the V compiler already catches this for user code, and enabling this causes issues with e.g. the `it` variable */,
'-Wno-int-to-void-pointer-cast',
'-Wno-int-to-pointer-cast' /* gcc version of the above */,
'-Wno-trigraphs' /* see stackoverflow.com/a/8435413 */,
'-Wno-missing-braces' /* see stackoverflow.com/q/13746033 */,
'-Wno-unknown-warning' /* if a C compiler does not understand a certain flag, it should just ignore it */,
'-Wno-unknown-warning-option' /* clang equivalent of the above */,
// enable additional warnings:
'-Wdate-time',
'-Wduplicated-branches',
Expand Down Expand Up @@ -265,6 +259,14 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
if have_flto {
optimization_options << '-flto'
}
ccoptions.wargs << [
'-Wno-tautological-bitwise-compare',
'-Wno-enum-conversion' /* used in vlib/sokol, where C enums in C structs are typed as V structs instead */,
'-Wno-sometimes-uninitialized' /* produced after exhaustive matches */,
'-Wno-int-to-void-pointer-cast',
'-Wno-unknown-warning' /* if a C compiler does not understand a certain flag, it should just ignore it */,
'-Wno-unknown-warning-option' /* clang equivalent of the above */,
]
}
if ccoptions.is_cc_gcc {
if ccoptions.debug_mode {
Expand Down Expand Up @@ -316,6 +318,7 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
if ccoptions.debug_mode && os.user_os() != 'windows' && v.pref.build_mode != .build_module {
ccoptions.linker_flags << '-rdynamic' // needed for nicer symbolic backtraces
}

if ccompiler != 'msvc' && v.pref.os != .freebsd {
ccoptions.wargs << '-Werror=implicit-function-declaration'
}
Expand Down

0 comments on commit 603e577

Please sign in to comment.