History

use more of OpenSSF's advised compilation options whenever possible

Sigrid Solveig Haflínudóttir committed 10 months ago

Commit 76ac96f1 parent f40de553 files · +86 −45Browse files

Unified · Split

3 files
  1. 3rd/tinycc +1 −1
  2. meson.build +84 −43
  3. src/macos/sys.c +1 −1
3rd/tinycc+1−1
@@ -1 +1 @@
1Subproject commit ed648ddd120d73cce6861b86c043c728c91a44501Subproject commit 9cd8873522b0371f4b626b753c63ad970d70fc40
meson.build+84−43
@@ -10,7 +10,31 @@ project( · 9 unmodified lines
10 ],10 ],
11)11)
12 12
13src_dir = meson.current_source_dir()13sys = host_machine.system()
14cc = meson.get_compiler('c')
15
16add_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
28add_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
15sl_c_args_w = [39sl_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']
52endif76endif
53 77
78src_dir = meson.current_source_dir()
79
54src_sl = [80src_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']
93endif119endif
94 120
95cc = meson.get_compiler('c')
96
97if cc.get_id() == 'clang'121if 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
105else135else
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 endif150 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
137endif173endif
138binc = inc + [include_directories('src'/bs)]174binc = inc + [include_directories('src'/bs)]
139 175
140sys = host_machine.system()
141cpu = host_machine.cpu_family()176cpu = host_machine.cpu_family()
142pic = true177pic = true
143bcc_can = false178bcc_can = false
@@ -178,44 +213,6 @@ endif · 34 unmodified lines
178inc += [include_directories('src'/platform)]213inc += [include_directories('src'/platform)]
179src_sl += ['src'/platform/'sys.c']214src_sl += ['src'/platform/'sys.c']
180 215
181common = static_library(
182 'common',
183 c_args: sl_c_args,
184 sources: src_common,
185 include_directories: inc,
186 pic: pic,
187)
188
189math = cc.find_library('m', required: false)
190
191brieflz = 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
202pcg = 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
219if not ['x86_64', 'x86', 'arm', 'aarch64', 'riscv64'].contains(cpu)216if not ['x86_64', 'x86', 'arm', 'aarch64', 'riscv64'].contains(cpu)
220 bcc_can = false217 bcc_can = false
221endif218endif
@@ -225,6 +222,12 @@ if get_option('bcc').enabled() and not bcc_can · 3 unmodified lines
225elif get_option('bcc').disabled() or not bcc_can222elif 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
228else231else
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']
363endif366endif
364 367
368common = static_library(
369 'common',
370 c_args: sl_c_args,
371 sources: src_common,
372 include_directories: inc,
373 pic: pic,
374)
375
376math = cc.find_library('m', required: false)
377
378brieflz = 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
389pcg = 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
365lzpack = executable(406lzpack = executable(
366 'lzpack',407 'lzpack',
367 c_args: sl_c_args,408 c_args: sl_c_args,
src/macos/sys.c+1−1
@@ -147,7 +147,7 @@ sys_init(void) · 146 unmodified lines
147{147{
148}148}
149 149
150char os_version[10];150char os_version[12];
151 151
152static const u8int boot[] = {152static const u8int boot[] = {
153#include "sl.boot.h"153#include "sl.boot.h"

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t