Skip to content

Commit 355c019

Browse files
committed
Make MSVC use release builds and enable warnings as errors
1 parent eab35f5 commit 355c019

File tree

9 files changed

+42
-10
lines changed

9 files changed

+42
-10
lines changed

graalpython/com.oracle.graal.python.cext/CMakeLists.txt

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,40 @@ set(TARGET_LIBPYTHON "python-native")
5454
######################################################################
5555

5656
if (MSVC)
57-
# set(CFLAGS_WARNINGS /Wall /WX)
57+
SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "" FORCE)
58+
SET(CFLAGS_WARNINGS /Wall /WX
59+
# Many warnings that are just MSVC being a bit pedantic
60+
/wd4255 # no function prototype given: converting '()' to '(void)'
61+
/wd4820 # padding added after data member
62+
/wd4100 # unreferenced formal parameter
63+
/wd4200 # nonstandard extension used: zero-sized array in struct/union
64+
/wd4996 # This function or variable may be unsafe ... see _CRT_SECURE_NO_WARNINGS
65+
/wd4668 # ... is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
66+
/wd4115 # named type definition in parentheses
67+
/wd4152 # nonstandard extension, function/data pointer conversion in expression
68+
/wd5045 # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
69+
/wd4047 # 'int64_t' differs in levels of indirection from 'char []' / 'void *'
70+
/wd4242 # conversion from 'int' to 'char', possible loss of data
71+
/wd4244 # conversion from 'long' to 'char', possible loss of data
72+
/wd4267 # conversion from 'size_t' to 'int', possible loss of data
73+
/wd4127 # conditional expression is constant
74+
/wd4702 # unreachable code
75+
/wd4101 # unreferenced local variable
76+
/wd4456 # declaration hides previous local declaration
77+
/wd4459 # declaration hides global declaration
78+
/wd4061 # enumerator X in switch of enum Y is not explicitly handled by a case label
79+
/wd4464 # relative include path contains '..'
80+
/wd4710 # 'fprintf': function not inlined
81+
/wd4706 # assignment within conditional expression
82+
83+
# Some that I'm not so happy about
84+
/wd4232 # sre: nonstandard extension used: 'ml_meth': address of dllimport 'Py_GenericAlias' is not static, identity not guaranteed
85+
/wd4191 # sre and sqlite: 'type cast': like unsafe conversion from 'PyObject *(__cdecl *)(MatchObject *,PyObject *const *,Py_ssize_t)' to 'void (__cdecl *)(void)'
86+
/wd4918 # sre: invalid character in pragma optimization list
87+
/wd4701 # cpython_unicodedata: potentially uninitialized local variable 'rc' used
88+
/wd4574 # sqlite: 'SQLITE_ATOMIC_INTRINSICS' is defined to be '0': did you mean to use '#if SQLITE_ATOMIC_INTRINSICS'?
89+
/wd4310 # xmlparse: cast truncates constant value
90+
)
5891
else()
5992
set(CFLAGS_WARNINGS -Wall -Werror -Wno-unused-function -Wno-unused-variable -Wno-unused-const-variable
6093
-Wno-unknown-warning-option

graalpython/com.oracle.graal.python.cext/src/abstract.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ binary_op(PyObject *v, PyObject *w, const int op_slot, const char *op_name)
952952
if (result == Py_NotImplemented) {
953953
Py_DECREF(result);
954954

955-
if (op_slot == NB_SLOT(nb_rshift) &&
955+
if (op_slot == (int)NB_SLOT(nb_rshift) &&
956956
PyCFunction_CheckExact(v) &&
957957
strcmp(((PyCFunctionObject *)v)->m_ml->ml_name, "print") == 0)
958958
{

graalpython/com.oracle.graal.python.cext/src/bytesobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ PyBytes_FromFormatV(const char *format, va_list vargs)
166166
(__buffer)[(__pos)++] = (__spec);\
167167
} while(0)
168168

169-
for(int i=0; i < sizeof(buffer); i++) {
169+
for(int i=0; i < (int)sizeof(buffer); i++) {
170170
buffer[i] = '\0';
171171
}
172172

graalpython/com.oracle.graal.python.cext/src/capi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static int cdata_getbuffer(PyObject* type, Py_buffer* view, int flags) {
262262
}
263263

264264
static void cdata_releasebuffer(PyObject* obj, Py_buffer* view) {
265-
return GraalPyTruffleCData_ReleaseBuffer(obj, view);
265+
GraalPyTruffleCData_ReleaseBuffer(obj, view);
266266
}
267267

268268
PyAPI_FUNC(void) PyTruffleCData_InitBufferProtocol(PyObject* type) {
@@ -801,7 +801,7 @@ PyAPI_FUNC(int) tuffle_check_basesize_for_getstate(PyTypeObject* type, int slot_
801801
if (type->tp_weaklistoffset)
802802
basicsize += sizeof(PyObject *);
803803
if (slot_num)
804-
basicsize += sizeof(PyObject *) * PyList_GET_SIZE(slot_num);
804+
basicsize += sizeof(PyObject *) * slot_num;
805805
return type->tp_basicsize > basicsize;
806806
}
807807

graalpython/com.oracle.graal.python.cext/src/gcmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1593,7 +1593,8 @@ gc_collect_main(PyThreadState *tstate, int generation,
15931593
PyGC_Head unreachable; /* non-problematic unreachable trash */
15941594
PyGC_Head finalizers; /* objects with, & reachable from, __del__ */
15951595
PyGC_Head *gc;
1596-
_PyTime_t t1 = 0; /* initialize to prevent a compiler warning */
1596+
// GraalPy change: t1 usage commented out
1597+
// _PyTime_t t1 = 0; /* initialize to prevent a compiler warning */
15971598
GCState *gcstate = graalpy_get_gc_state(tstate); // GraalPy change
15981599

15991600
if (GraalPyTruffle_DisableReferneceQueuePolling()) {

graalpython/com.oracle.graal.python.cext/src/listobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ PyTypeObject PyList_Type = {
133133

134134
// alias for internal function, currently used in PyO3
135135
PyAPI_FUNC(void) _PyList_SET_ITEM(PyObject* a, Py_ssize_t b, PyObject* c) {
136-
return PyList_SET_ITEM(a, b, c);
136+
PyList_SET_ITEM(a, b, c);
137137
}
138138

139139
static inline int

graalpython/com.oracle.graal.python.cext/src/longobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ PyLong_FromVoidPtr(void *p)
888888
{
889889
// GraalPy change: different implementation
890890
// directly do the upcall to avoid a cast to primitive and reference counting
891-
return ((PyObject* (*)(void*))GraalPyLong_FromUnsignedLongLong)(p);
891+
return GraalPyLong_FromUnsignedLongLong((uint64_t)p);
892892
}
893893

894894
#if 0 // GraalPy change

graalpython/com.oracle.graal.python.cext/src/obmalloc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ _GraalPyMem_PrepareAlloc(GraalPyMem_t *state, size_t size)
384384
__func__, state->native_memory_gc_barrier, size, state->allocated_memory);
385385

386386
size_t delay = 0;
387-
int iteration = 0;
388387
for (int iteration = 0; iteration < MAX_COLLECTION_RETRIES;
389388
iteration++) {
390389
GraalPyTruffle_TriggerGC(delay);

graalpython/com.oracle.graal.python.cext/src/unicodeobject.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,6 @@ PyUnicode_New(Py_ssize_t size, Py_UCS4 maxchar)
13811381
{
13821382
// GraalPy change: different implementation
13831383
/* add one to size for the null character */
1384-
int is_ascii = 0;
13851384
if (maxchar < 128) {
13861385
/* We intentionally use 'size' (which is one element less than the allocated array)
13871386
* because interop users should not see the null character. */

0 commit comments

Comments
 (0)