X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=meson.build;h=43ae9744ce599fa5604f4413aaac04ec1469c007;hb=e6111686d731af1e621ea9f38babef50610f7717;hp=488230e8fc43eaa5e78051d1f6722f97414e6253;hpb=9c577bd201009f14b4cb5d8540b6dc03246f6165;p=tinc diff --git a/meson.build b/meson.build index 488230e8..43ae9744 100644 --- a/meson.build +++ b/meson.build @@ -50,6 +50,34 @@ endif cc_flags = [cc_defs] ld_flags = [] +if cc_name != 'msvc' + cc_flags += [ + '-Qunused-arguments', + '-Wbad-function-cast', + '-Wduplicated-branches', + '-Wduplicated-cond', + '-Wformat-overflow=2', + '-Wformat-truncation=1', # 2 prints too much noise + '-Wformat=2', + '-Wlogical-op', + '-Wmissing-declarations', + '-Wmissing-noreturn', + '-Wmissing-prototypes', + '-Wno-embedded-directive', + '-Wold-style-definition', + '-Wredundant-decls', + '-Wreturn-type', + '-Wstrict-prototypes', + '-Wswitch-enum', + '-Wtrampolines', # may require executable stack which is disabled + '-Wvla', # VLAs are not supported by MSVC + '-Wwrite-strings', + '-fdiagnostics-show-option', + '-fno-strict-overflow', + '-fstrict-aliasing', + ] +endif + if opt_static.auto() static = os_name == 'windows' else @@ -74,26 +102,15 @@ if opt_harden else cc_flags += [ '-D_FORTIFY_SOURCE=2', - '-fwrapv', - '-fno-strict-overflow', - '-Wreturn-type', - '-Wold-style-definition', - '-Wmissing-declarations', - '-Wmissing-prototypes', - '-Wstrict-prototypes', - '-Wredundant-decls', - '-Wbad-function-cast', - '-Wwrite-strings', - '-fdiagnostics-show-option', - '-fstrict-aliasing', - '-Wmissing-noreturn', + '-fcf-protection=full', + '-fstack-protector-strong', ] - if cc_name == 'clang' - cc_flags += '-Qunused-arguments' - endif - ld_flags += ['-Wl,-z,relro', '-Wl,-z,now'] + ld_flags += ['-Wl,-z,relro', '-Wl,-z,now', '-Wl,-z,noexecstack'] if os_name == 'windows' ld_flags += ['-Wl,--dynamicbase', '-Wl,--nxcompat'] + else + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90458 + cc_flags += '-fstack-clash-protection' endif endif endif @@ -139,6 +156,12 @@ if os_name == 'linux' and not opt_systemd.disabled() endif run_target('reformat', command: [ - find_program('python3'), - '@SOURCE_ROOT@/reformat.py', + python, + '@SOURCE_ROOT@/lint.py', + '--fix', +]) + +run_target('lint', command: [ + python, + '@SOURCE_ROOT@/lint.py', ])