| @@ -10,7 +10,31 @@ project( · 9 unmodified lines |
| 10 | ], | 10 | ], |
| 11 | ) | 11 | ) |
| 12 | | 12 | |
| 13 | src_dir = meson.current_source_dir() | 13 | sys = host_machine.system() |
| | 14 | cc = meson.get_compiler('c') |
| | 15 | |
| | 16 | add_project_arguments( |
| | 17 | (sys == 'macos' ? [] : [ |
| | 18 | '-U_FORTIFY_SOURCE', |
| | 19 | '-D_FORTIFY_SOURCE=3', |
| | 20 | '-D_GLIBCXX_ASSERTIONS', |
| | 21 | '-fstack-protector-strong', |
| | 22 | ]) |
| | 23 | + (sys == 'openbsd' ? [] : ['-fstack-clash-protection']) |
| | 24 | + ['-fno-strict-overflow', '-fno-delete-null-pointer-checks'], |
| | 25 | language: 'c', |
| | 26 | ) |
| | 27 | |
| | 28 | add_project_link_arguments( |
| | 29 | (sys == 'windows' ? [] : [ |
| | 30 | '-Wl,-z,noexecstack', |
| | 31 | '-Wl,-z,relro', |
| | 32 | '-Wl,-z,now', |
| | 33 | ]) |
| | 34 | + ['-Wl,--as-needed'] |
| | 35 | + (cc.has_link_argument('-Wl,--no-copy-dt-needed-entries') ? ['-Wl,--no-copy-dt-needed-entries'] : []), |
| | 36 | language: 'c', |
| | 37 | ) |
| 14 | | 38 | |
| 15 | sl_c_args_w = [ | 39 | sl_c_args_w = [ |
| 16 | '-Wformat=2', | 40 | '-Wformat=2', |
| @@ -51,6 +75,8 @@ if san == 'address,undefined' or san.contains('undefined') · 34 unmodified lines |
| 51 | sl_c_args += ['-DUBSAN'] | 75 | sl_c_args += ['-DUBSAN'] |
| 52 | endif | 76 | endif |
| 53 | | 77 | |
| | 78 | src_dir = meson.current_source_dir() |
| | 79 | |
| 54 | src_sl = [ | 80 | src_sl = [ |
| 55 | '3rd/fn.c', | 81 | '3rd/fn.c', |
| 56 | '3rd/iswprint.c', | 82 | '3rd/iswprint.c', |
| @@ -92,8 +118,6 @@ else · 35 unmodified lines |
| 92 | src_sl += ['3rd/spooky.c'] | 118 | src_sl += ['3rd/spooky.c'] |
| 93 | endif | 119 | endif |
| 94 | | 120 | |
| 95 | cc = meson.get_compiler('c') | | |
| 96 | | | |
| 97 | if cc.get_id() == 'clang' | 121 | if cc.get_id() == 'clang' |
| 98 | sl_c_args += [ | 122 | sl_c_args += [ |
| 99 | '-Wformat-pedantic', | 123 | '-Wformat-pedantic', |
| @@ -102,6 +126,12 @@ if cc.get_id() == 'clang' · 2 unmodified lines |
| 102 | '-Wgcc-compat', | 126 | '-Wgcc-compat', |
| 103 | '-Wunused-const-variable', | 127 | '-Wunused-const-variable', |
| 104 | ] | 128 | ] |
| | 129 | if cc.version().version_compare('>=16.0.0') |
| | 130 | add_project_arguments( |
| | 131 | '-fstrict-flex-arrays=3', |
| | 132 | language: 'c', |
| | 133 | ) |
| | 134 | endif |
| 105 | else | 135 | else |
| 106 | sl_c_args += [ | 136 | sl_c_args += [ |
| 107 | '-Werror=lto-type-mismatch', | 137 | '-Werror=lto-type-mismatch', |
| @@ -118,6 +148,12 @@ else · 10 unmodified lines |
| 118 | '-Wbidi-chars=any', | 148 | '-Wbidi-chars=any', |
| 119 | ] | 149 | ] |
| 120 | endif | 150 | endif |
| | 151 | if cc.version().version_compare('>=13.0.0') |
| | 152 | add_project_arguments( |
| | 153 | '-fstrict-flex-arrays=3', |
| | 154 | language: 'c', |
| | 155 | ) |
| | 156 | endif |
| 121 | if cc.version().version_compare('>=15.0.0') | 157 | if cc.version().version_compare('>=15.0.0') |
| 122 | sl_c_args += [ | 158 | sl_c_args += [ |
| 123 | '-Wtrailing-whitespace=any', | 159 | '-Wtrailing-whitespace=any', |
| @@ -137,7 +173,6 @@ if bs != 'dos' and bs != 'windows' · 13 unmodified lines |
| 137 | endif | 173 | endif |
| 138 | binc = inc + [include_directories('src'/bs)] | 174 | binc = inc + [include_directories('src'/bs)] |
| 139 | | 175 | |
| 140 | sys = host_machine.system() | | |
| 141 | cpu = host_machine.cpu_family() | 176 | cpu = host_machine.cpu_family() |
| 142 | pic = true | 177 | pic = true |
| 143 | bcc_can = false | 178 | bcc_can = false |
| @@ -178,44 +213,6 @@ endif · 34 unmodified lines |
| 178 | inc += [include_directories('src'/platform)] | 213 | inc += [include_directories('src'/platform)] |
| 179 | src_sl += ['src'/platform/'sys.c'] | 214 | src_sl += ['src'/platform/'sys.c'] |
| 180 | | 215 | |
| 181 | common = static_library( | | |
| 182 | 'common', | | |
| 183 | c_args: sl_c_args, | | |
| 184 | sources: src_common, | | |
| 185 | include_directories: inc, | | |
| 186 | pic: pic, | | |
| 187 | ) | | |
| 188 | | | |
| 189 | math = cc.find_library('m', required: false) | | |
| 190 | | | |
| 191 | brieflz = static_library( | | |
| 192 | 'brieflz', | | |
| 193 | c_args: sl_c_args, | | |
| 194 | sources: [ | | |
| 195 | '3rd/brieflz/brieflz.c', | | |
| 196 | '3rd/brieflz/depacks.c', | | |
| 197 | ], | | |
| 198 | include_directories: inc, | | |
| 199 | pic: pic, | | |
| 200 | ) | | |
| 201 | | | |
| 202 | pcg = static_library( | | |
| 203 | 'pcg', | | |
| 204 | c_args: sl_c_args, | | |
| 205 | sources: [ | | |
| 206 | '3rd/pcg-c/pcg-advance-16.c', | | |
| 207 | '3rd/pcg-c/pcg-advance-32.c', | | |
| 208 | '3rd/pcg-c/pcg-advance-64.c', | | |
| 209 | '3rd/pcg-c/pcg-advance-8.c', | | |
| 210 | '3rd/pcg-c/pcg-output-64.c', | | |
| 211 | '3rd/pcg-c/pcg-output-32.c', | | |
| 212 | '3rd/pcg-c/pcg-rngs-64.c', | | |
| 213 | '3rd/pcg-c/pcg32x2.c', | | |
| 214 | ], | | |
| 215 | include_directories: inc, | | |
| 216 | pic: pic, | | |
| 217 | ) | | |
| 218 | | | |
| 219 | if not ['x86_64', 'x86', 'arm', 'aarch64', 'riscv64'].contains(cpu) | 216 | if not ['x86_64', 'x86', 'arm', 'aarch64', 'riscv64'].contains(cpu) |
| 220 | bcc_can = false | 217 | bcc_can = false |
| 221 | endif | 218 | endif |
| @@ -225,6 +222,12 @@ if get_option('bcc').enabled() and not bcc_can · 3 unmodified lines |
| 225 | elif get_option('bcc').disabled() or not bcc_can | 222 | elif get_option('bcc').disabled() or not bcc_can |
| 226 | bcc = [] | 223 | bcc = [] |
| 227 | src_sl += ['src/bcc_null.c'] | 224 | src_sl += ['src/bcc_null.c'] |
| | 225 | if sys != 'windows' |
| | 226 | add_project_link_arguments( |
| | 227 | '-Wl,-z,nodlopen', |
| | 228 | language: 'c', |
| | 229 | ) |
| | 230 | endif |
| 228 | else | 231 | else |
| 229 | if cpu == 'x86_64' | 232 | if cpu == 'x86_64' |
| 230 | bcc_src_arch = [ | 233 | bcc_src_arch = [ |
| @@ -358,10 +361,48 @@ else · 127 unmodified lines |
| 358 | ], | 361 | ], |
| 359 | pic: pic, | 362 | pic: pic, |
| 360 | ) | 363 | ) |
| 361 | src_sl += ['src/bcc_tcc.c'] | 364 | src_sl += [bcc_config, 'src/bcc_tcc.c'] |
| 362 | inc += ['3rd/tinycc'] | 365 | inc += ['3rd/tinycc'] |
| 363 | endif | 366 | endif |
| 364 | | 367 | |
| | 368 | common = static_library( |
| | 369 | 'common', |
| | 370 | c_args: sl_c_args, |
| | 371 | sources: src_common, |
| | 372 | include_directories: inc, |
| | 373 | pic: pic, |
| | 374 | ) |
| | 375 | |
| | 376 | math = cc.find_library('m', required: false) |
| | 377 | |
| | 378 | brieflz = static_library( |
| | 379 | 'brieflz', |
| | 380 | c_args: sl_c_args, |
| | 381 | sources: [ |
| | 382 | '3rd/brieflz/brieflz.c', |
| | 383 | '3rd/brieflz/depacks.c', |
| | 384 | ], |
| | 385 | include_directories: inc, |
| | 386 | pic: pic, |
| | 387 | ) |
| | 388 | |
| | 389 | pcg = static_library( |
| | 390 | 'pcg', |
| | 391 | c_args: sl_c_args, |
| | 392 | sources: [ |
| | 393 | '3rd/pcg-c/pcg-advance-16.c', |
| | 394 | '3rd/pcg-c/pcg-advance-32.c', |
| | 395 | '3rd/pcg-c/pcg-advance-64.c', |
| | 396 | '3rd/pcg-c/pcg-advance-8.c', |
| | 397 | '3rd/pcg-c/pcg-output-64.c', |
| | 398 | '3rd/pcg-c/pcg-output-32.c', |
| | 399 | '3rd/pcg-c/pcg-rngs-64.c', |
| | 400 | '3rd/pcg-c/pcg32x2.c', |
| | 401 | ], |
| | 402 | include_directories: inc, |
| | 403 | pic: pic, |
| | 404 | ) |
| | 405 | |
| 365 | lzpack = executable( | 406 | lzpack = executable( |
| 366 | 'lzpack', | 407 | 'lzpack', |
| 367 | c_args: sl_c_args, | 408 | c_args: sl_c_args, |