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 @@
1−Subproject commit ed648ddd120d73cce6861b86c043c728c91a4450
1+Subproject commit 9cd8873522b0371f4b626b753c63ad970d70fc40
meson.build+84−43
@@ -10,7 +10,31 @@ project( · 9 unmodified lines
1010 ],
1111 )
1212
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+)
1438
1539 sl_c_args_w = [
1640 '-Wformat=2',
@@ -51,6 +75,8 @@ if san == 'address,undefined' or san.contains('undefined') · 34 unmodified lines
5175 sl_c_args += ['-DUBSAN']
5276 endif
5377
78+src_dir = meson.current_source_dir()
79+
5480 src_sl = [
5581 '3rd/fn.c',
5682 '3rd/iswprint.c',
@@ -92,8 +118,6 @@ else · 35 unmodified lines
92118 src_sl += ['3rd/spooky.c']
93119 endif
94120
95−cc = meson.get_compiler('c')
96−
97121 if cc.get_id() == 'clang'
98122 sl_c_args += [
99123 '-Wformat-pedantic',
@@ -102,6 +126,12 @@ if cc.get_id() == 'clang' · 2 unmodified lines
102126 '-Wgcc-compat',
103127 '-Wunused-const-variable',
104128 ]
129+ if cc.version().version_compare('>=16.0.0')
130+ add_project_arguments(
131+ '-fstrict-flex-arrays=3',
132+ language: 'c',
133+ )
134+ endif
105135 else
106136 sl_c_args += [
107137 '-Werror=lto-type-mismatch',
@@ -118,6 +148,12 @@ else · 10 unmodified lines
118148 '-Wbidi-chars=any',
119149 ]
120150 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
121157 if cc.version().version_compare('>=15.0.0')
122158 sl_c_args += [
123159 '-Wtrailing-whitespace=any',
@@ -137,7 +173,6 @@ if bs != 'dos' and bs != 'windows' · 13 unmodified lines
137173 endif
138174 binc = inc + [include_directories('src'/bs)]
139175
140−sys = host_machine.system()
141176 cpu = host_machine.cpu_family()
142177 pic = true
143178 bcc_can = false
@@ -178,44 +213,6 @@ endif · 34 unmodified lines
178213 inc += [include_directories('src'/platform)]
179214 src_sl += ['src'/platform/'sys.c']
180215
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−
219216 if not ['x86_64', 'x86', 'arm', 'aarch64', 'riscv64'].contains(cpu)
220217 bcc_can = false
221218 endif
@@ -225,6 +222,12 @@ if get_option('bcc').enabled() and not bcc_can · 3 unmodified lines
225222 elif get_option('bcc').disabled() or not bcc_can
226223 bcc = []
227224 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
228231 else
229232 if cpu == 'x86_64'
230233 bcc_src_arch = [
@@ -358,10 +361,48 @@ else · 127 unmodified lines
358361 ],
359362 pic: pic,
360363 )
361− src_sl += ['src/bcc_tcc.c']
364+ src_sl += [bcc_config, 'src/bcc_tcc.c']
362365 inc += ['3rd/tinycc']
363366 endif
364367
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+
365406 lzpack = executable(
366407 'lzpack',
367408 c_args: sl_c_args,
src/macos/sys.c+1−1
@@ -147,7 +147,7 @@ sys_init(void) · 146 unmodified lines
147147 {
148148 }
149149
150−char os_version[10];
150+char os_version[12];
151151
152152 static const u8int boot[] = {
153153 #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