Skip to content

Commit 44052b5

Browse files
nohlsonhugovkblurb-it[bot]
authored
pythongh-124064: Make warning emitting compiler options opt-in (python#124070)
Co-authored-by: Hugo van Kemenade <[email protected]> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
1 parent 05235e3 commit 44052b5

8 files changed

+809
-115
lines changed

.github/workflows/reusable-macos.yml

+16-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
path: config.cache
3636
key: ${{ github.job }}-${{ inputs.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
3737
- name: Install Homebrew dependencies
38-
run: brew install pkg-config [email protected] xz gdbm tcl-tk
38+
run: brew install pkg-config [email protected] xz gdbm tcl-tk make
3939
- name: Configure CPython
4040
run: |
4141
GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \
@@ -44,14 +44,27 @@ jobs:
4444
--config-cache \
4545
--with-pydebug \
4646
--enable-slower-safety \
47+
--enable-safety \
4748
${{ inputs.free-threading && '--disable-gil' || '' }} \
4849
--prefix=/opt/python-dev \
4950
--with-openssl="$(brew --prefix [email protected])"
5051
- name: Build CPython
51-
run: set -o pipefail; make -j8 2>&1 | tee compiler_output.txt
52+
if : ${{ inputs.free-threading || inputs.os != 'macos-13' }}
53+
run: gmake -j8
54+
- name: Build CPython for compiler warning check
55+
if : ${{ !inputs.free-threading && inputs.os == 'macos-13' }}
56+
run: set -o pipefail; gmake -j8 --output-sync 2>&1 | tee compiler_output_macos.txt
5257
- name: Display build info
5358
run: make pythoninfo
5459
- name: Check compiler warnings
55-
run: python3 Tools/build/check_warnings.py --compiler-output-file-path=compiler_output.txt --warning-ignore-file-path=Tools/build/.warningignore_macos --compiler-output-type=clang
60+
if : ${{ !inputs.free-threading && inputs.os == 'macos-13' }}
61+
run: >-
62+
python3 Tools/build/check_warnings.py
63+
--compiler-output-file-path=compiler_output_macos.txt
64+
--warning-ignore-file-path=Tools/build/.warningignore_macos
65+
--compiler-output-type=clang
66+
--fail-on-regression
67+
--fail-on-improvement
68+
--path-prefix="./"
5669
- name: Tests
5770
run: make test

.github/workflows/reusable-ubuntu.yml

+16-3
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,33 @@ jobs:
6767
working-directory: ${{ env.CPYTHON_BUILDDIR }}
6868
run: >-
6969
../cpython-ro-srcdir/configure
70-
CFLAGS="-fdiagnostics-format=json"
7170
--config-cache
7271
--with-pydebug
7372
--enable-slower-safety
73+
--enable-safety
7474
--with-openssl=$OPENSSL_DIR
7575
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
7676
- name: Build CPython out-of-tree
77+
if: ${{ inputs.free-threading }}
7778
working-directory: ${{ env.CPYTHON_BUILDDIR }}
78-
run: set -o pipefail; make -j4 2>&1 | tee compiler_output.txt
79+
run: make -j4
80+
- name: Build CPython out-of-tree (for compiler warning check)
81+
if: ${{ !inputs.free-threading}}
82+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
83+
run: set -o pipefail; make -j4 --output-sync 2>&1 | tee compiler_output_ubuntu.txt
7984
- name: Display build info
8085
working-directory: ${{ env.CPYTHON_BUILDDIR }}
8186
run: make pythoninfo
8287
- name: Check compiler warnings
83-
run: python Tools/build/check_warnings.py --compiler-output-file-path=${{ env.CPYTHON_BUILDDIR }}/compiler_output.txt --warning-ignore-file-path ${GITHUB_WORKSPACE}/Tools/build/.warningignore_ubuntu --compiler-output-type=json
88+
if: ${{ !inputs.free-threading }}
89+
run: >-
90+
python Tools/build/check_warnings.py
91+
--compiler-output-file-path=${{ env.CPYTHON_BUILDDIR }}/compiler_output_ubuntu.txt
92+
--warning-ignore-file-path ${GITHUB_WORKSPACE}/Tools/build/.warningignore_ubuntu
93+
--compiler-output-type=gcc
94+
--fail-on-regression
95+
--fail-on-improvement
96+
--path-prefix="../cpython-ro-srcdir/"
8497
- name: Remount sources writable for tests
8598
# some tests write to srcdir, lack of pyc files slows down testing
8699
run: sudo mount $CPYTHON_RO_SRCDIR -oremount,rw
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Enable compiler options that warn of potential security vulnerabilities.

Tools/build/.warningignore_macos

+227
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,230 @@
33
# Keep lines sorted lexicographically to help avoid merge conflicts.
44
# Format example:
55
# /path/to/file (number of warnings in file)
6+
Include/internal/mimalloc/mimalloc/internal.h 4
7+
Include/internal/pycore_backoff.h 1
8+
Include/internal/pycore_dict.h 2
9+
Include/internal/pycore_gc.h 1
10+
Include/internal/pycore_long.h 2
11+
Include/internal/pycore_object.h 4
12+
Modules/_asynciomodule.c 3
13+
Modules/_bisectmodule.c 2
14+
Modules/_bz2module.c 5
15+
Modules/_collectionsmodule.c 2
16+
Modules/_csv.c 3
17+
Modules/_ctypes/_ctypes.c 37
18+
Modules/_ctypes/_ctypes_test_generated.c.h 141
19+
Modules/_ctypes/callbacks.c 6
20+
Modules/_ctypes/callproc.c 15
21+
Modules/_ctypes/cfield.c 56
22+
Modules/_ctypes/malloc_closure.c 3
23+
Modules/_ctypes/stgdict.c 17
24+
Modules/_cursesmodule.c 24
25+
Modules/_datetimemodule.c 28
26+
Modules/_dbmmodule.c 8
27+
Modules/_decimal/_decimal.c 15
28+
Modules/_elementtree.c 42
29+
Modules/_functoolsmodule.c 6
30+
Modules/_gdbmmodule.c 5
31+
Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c 84
32+
Modules/_hacl/Hacl_Hash_Blake2s_Simd128.c 84
33+
Modules/_hacl/include/krml/FStar_UInt_8_16_32_64.h 24
34+
Modules/_hashopenssl.c 16
35+
Modules/_interpchannelsmodule.c 1
36+
Modules/_interpqueuesmodule.c 1
37+
Modules/_io/_iomodule.c 1
38+
Modules/_io/bufferedio.c 4
39+
Modules/_io/bytesio.c 11
40+
Modules/_io/fileio.c 9
41+
Modules/_io/stringio.c 8
42+
Modules/_io/textio.c 11
43+
Modules/_json.c 19
44+
Modules/_localemodule.c 3
45+
Modules/_lzmamodule.c 10
46+
Modules/_multiprocessing/semaphore.c 2
47+
Modules/_operator.c 5
48+
Modules/_pickle.c 71
49+
Modules/_posixsubprocess.c 8
50+
Modules/_queuemodule.c 4
51+
Modules/_randommodule.c 3
52+
Modules/_scproxy.c 3
53+
Modules/_sqlite/connection.c 4
54+
Modules/_sqlite/cursor.c 3
55+
Modules/_sqlite/module.c 2
56+
Modules/_sre/sre.c 18
57+
Modules/_sre/sre_lib.h 62
58+
Modules/_ssl.c 29
59+
Modules/_struct.c 1
60+
Modules/_testbuffer.c 22
61+
Modules/_testcapi/heaptype.c 1
62+
Modules/_testcapi/long.c 2
63+
Modules/_testcapi/mem.c 2
64+
Modules/_testcapi/monitoring.c 3
65+
Modules/_testcapi/pyatomic.c 1
66+
Modules/_testcapi/unicode.c 2
67+
Modules/_testcapi/vectorcall.c 3
68+
Modules/_testcapi/watchers.c 3
69+
Modules/_testcapimodule.c 3
70+
Modules/_testclinic.c 14
71+
Modules/_testexternalinspection.c 8
72+
Modules/_testinternalcapi.c 8
73+
Modules/_testinternalcapi/pytime.c 8
74+
Modules/_testinternalcapi/test_critical_sections.c 1
75+
Modules/_testinternalcapi/test_lock.c 2
76+
Modules/_testlimitedcapi/heaptype_relative.c 4
77+
Modules/_testlimitedcapi/object.c 2
78+
Modules/_testlimitedcapi/unicode.c 2
79+
Modules/_threadmodule.c 2
80+
Modules/_tkinter.c 6
81+
Modules/_xxtestfuzz/_xxtestfuzz.c 1
82+
Modules/_xxtestfuzz/fuzzer.c 11
83+
Modules/_zoneinfo.c 14
84+
Modules/arraymodule.c 32
85+
Modules/atexitmodule.c 1
86+
Modules/binascii.c 206
87+
Modules/blake2module.c 6
88+
Modules/cjkcodecs/_codecs_cn.c 1
89+
Modules/cjkcodecs/_codecs_iso2022.c 2
90+
Modules/cjkcodecs/_codecs_jp.c 14
91+
Modules/cjkcodecs/_codecs_kr.c 3
92+
Modules/cjkcodecs/cjkcodecs.h 1
93+
Modules/cjkcodecs/multibytecodec.c 2
94+
Modules/clinic/_testclinic.c.h 1
95+
Modules/clinic/arraymodule.c.h 1
96+
Modules/clinic/unicodedata.c.h 10
97+
Modules/cmathmodule.c 1
98+
Modules/expat/siphash.h 8
99+
Modules/expat/xmlparse.c 45
100+
Modules/expat/xmltok.c 17
101+
Modules/expat/xmltok_impl.c 34
102+
Modules/faulthandler.c 3
103+
Modules/fcntlmodule.c 1
104+
Modules/getpath.c 7
105+
Modules/grpmodule.c 4
106+
Modules/itertoolsmodule.c 7
107+
Modules/main.c 2
108+
Modules/mathmodule.c 15
109+
Modules/mmapmodule.c 20
110+
Modules/posixmodule.c 67
111+
Modules/pwdmodule.c 4
112+
Modules/pyexpat.c 20
113+
Modules/readline.c 1
114+
Modules/resource.c 3
115+
Modules/rotatingtree.c 1
116+
Modules/selectmodule.c 6
117+
Modules/sha3module.c 4
118+
Modules/signalmodule.c 1
119+
Modules/socketmodule.c 44
120+
Modules/syslogmodule.c 3
121+
Modules/timemodule.c 4
122+
Modules/unicodedata.c 28
123+
Modules/unicodedata_db.h 1
124+
Modules/xxsubtype.c 2
125+
Modules/zlibmodule.c 16
126+
Objects/abstract.c 2
127+
Objects/bytearrayobject.c 34
128+
Objects/bytes_methods.c 9
129+
Objects/bytesobject.c 35
130+
Objects/call.c 13
131+
Objects/classobject.c 4
132+
Objects/codeobject.c 15
133+
Objects/descrobject.c 2
134+
Objects/dictobject.c 28
135+
Objects/fileobject.c 3
136+
Objects/floatobject.c 30
137+
Objects/frameobject.c 19
138+
Objects/funcobject.c 1
139+
Objects/genobject.c 5
140+
Objects/listobject.c 43
141+
Objects/longobject.c 46
142+
Objects/memoryobject.c 6
143+
Objects/methodobject.c 1
144+
Objects/mimalloc/alloc.c 6
145+
Objects/mimalloc/arena.c 6
146+
Objects/mimalloc/heap.c 1
147+
Objects/mimalloc/init.c 2
148+
Objects/mimalloc/options.c 1
149+
Objects/mimalloc/os.c 4
150+
Objects/mimalloc/page-queue.c 2
151+
Objects/mimalloc/page.c 1
152+
Objects/mimalloc/prim/osx/../unix/prim.c 2
153+
Objects/mimalloc/random.c 1
154+
Objects/mimalloc/segment.c 11
155+
Objects/mimalloc/stats.c 1
156+
Objects/moduleobject.c 2
157+
Objects/object.c 1
158+
Objects/obmalloc.c 6
159+
Objects/odictobject.c 3
160+
Objects/rangeobject.c 10
161+
Objects/setobject.c 13
162+
Objects/sliceobject.c 4
163+
Objects/stringlib/codecs.h 26
164+
Objects/stringlib/eq.h 1
165+
Objects/stringlib/fastsearch.h 14
166+
Objects/stringlib/join.h 1
167+
Objects/stringlib/replace.h 4
168+
Objects/stringlib/repr.h 21
169+
Objects/stringlib/transmogrify.h 5
170+
Objects/structseq.c 14
171+
Objects/tupleobject.c 10
172+
Objects/typeobject.c 17
173+
Objects/unicodectype.c 7
174+
Objects/unicodeobject.c 113
175+
Parser/action_helpers.c 4
176+
Parser/lexer/buffer.c 1
177+
Parser/lexer/lexer.c 12
178+
Parser/parser.c 116
179+
Parser/pegen.c 7
180+
Parser/string_parser.c 7
181+
Parser/tokenizer/file_tokenizer.c 8
182+
Parser/tokenizer/helpers.c 7
183+
Parser/tokenizer/readline_tokenizer.c 3
184+
Programs/_freeze_module.c 1
185+
Python/Python-ast.c 15
186+
Python/asdl.c 3
187+
Python/assemble.c 7
188+
Python/ast_opt.c 7
189+
Python/bltinmodule.c 9
190+
Python/bootstrap_hash.c 4
191+
Python/ceval.c 8
192+
Python/ceval_gil.c 2
193+
Python/codecs.c 32
194+
Python/codegen.c 6
195+
Python/compile.c 2
196+
Python/context.c 1
197+
Python/crossinterp.c 2
198+
Python/crossinterp_data_lookup.h 1
199+
Python/dtoa.c 34
200+
Python/errors.c 1
201+
Python/fileutils.c 7
202+
Python/flowgraph.c 8
203+
Python/formatter_unicode.c 7
204+
Python/frame.c 4
205+
Python/gc.c 8
206+
Python/generated_cases.c.h 35
207+
Python/getargs.c 11
208+
Python/import.c 5
209+
Python/initconfig.c 11
210+
Python/instrumentation.c 31
211+
Python/intrinsics.c 1
212+
Python/legacy_tracing.c 3
213+
Python/lock.c 4
214+
Python/marshal.c 11
215+
Python/modsupport.c 3
216+
Python/mystrtoul.c 4
217+
Python/pathconfig.c 1
218+
Python/preconfig.c 2
219+
Python/pyarena.c 1
220+
Python/pyhash.c 2
221+
Python/pylifecycle.c 7
222+
Python/pystate.c 6
223+
Python/pystrhex.c 19
224+
Python/pystrtod.c 3
225+
Python/qsbr.c 2
226+
Python/specialize.c 10
227+
Python/suggestions.c 12
228+
Python/symtable.c 18
229+
Python/sysmodule.c 2
230+
Python/thread_pthread.h 1
231+
Python/traceback.c 6
232+
Python/tracemalloc.c 6

0 commit comments

Comments
 (0)