Skip to content

Commit afbeabe

Browse files
committed
[GR-62603] Remove Sulong support.
PullRequest: graalpython/3706
2 parents af9d138 + 8c467c0 commit afbeabe

File tree

446 files changed

+20307
-39122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

446 files changed

+20307
-39122
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,4 @@ pom-mx.xml
9696
.venv
9797
!graalpython/com.oracle.graal.python.test/src/tests/standalone/gradle/gradle-test-project/gradle/wrapper/gradle-wrapper.jar
9898
/*-venv/
99+
.aider*

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ language runtime. The main focus is on user-observable behavior of the engine.
88
* `GRAALPY_VERSION_NUM` C macro now inlcudes the release level and serial number at the end to conform to the `hexversion` format. This shouldn't break any existing comparisons.
99
* `dir(foreign_object)` now returns both foreign methods and Python methods (it used to return only foreign methods).
1010
* Support `__name__`, `__doc__`, `__text_signature__` fields on foreign executables to serve as their proper counterparts on the Python side. This is useful to, for example, use Java functional interfaces in lieu of Python functions for things like LangChain's `@tool` annotation that want to inspect the underlying function.
11+
* Remove support for running C extensions as LLVM bitcode. This also removes the related options `python.UseSystemToolchain` and `python.NativeModules`.
12+
* Remove built-in HPy module. HPy can now be installed and used from the upstream sources.
1113

1214
## Version 24.2.0
1315
* Updated developer metadata of Maven artifacts.

docs/contributor/DEV_TASKS.md

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
### Updating dependencies
44

55
We can use the following command to update our CI jsonnet as well as all
6-
dependencies (truffle, sulong, ...) in one go:
6+
dependencies (truffle, ...) in one go:
77

88
mx python-update-import
99

@@ -26,35 +26,6 @@ It prints a fairly long help. Note that you'll need to make sure you also pushed
2626
your `python-import` branch after doing the update, so that any conflicts you
2727
resolved don't have to be resolved again by the next person.
2828

29-
### Updating hpy
30-
31-
Follow these steps to update HPy.
32-
33-
34-
1. Merge updated hpy sources. To do so, clone hpy somewhere next to
35-
graalpython. Then run the following command on a new branch of graalpython:
36-
37-
mx python-update-hpy-import --pull /path/to/clone/of/hpy
38-
39-
Follow the instructions.
40-
2. We need to fix compilation. We patch the hpy sources, and the merge may
41-
have introduced new API or types, and for these we need to apply
42-
patches. At the time of this writing, we redefine hpy types conditionally
43-
on `#ifdef GRAALVM_PYTHON_LLVM` (grep for this to find some
44-
examples). Also, we use macros to convert between the structured hpy types
45-
and plain pointers for our native interface, see the uses of the `WRAP` and
46-
`UNWRAP` macros.
47-
3. Once compilation is working, we try to run the tests and go on fixing
48-
them. If new API was added, `GraalHPyContext` needs to be adapted with the
49-
new signatures and/or types. This may include:
50-
51-
- Updating the HPyContextMember enum
52-
- Updating the HPyContextSignatureType enum
53-
- Adding `GraalHPyContextFunction` implementations for the new APIs
54-
- Updating the `createMembers` method to assign the appropriate
55-
implementations to the context members
56-
- Updating hpy.c to assign new context members to their native locations
57-
5829
### Updating patch branch
5930
GraalPy's `pip` has an ability to download newer versions of patches from our
6031
GitHub so that we can update patches outside of the release cycle. There should
@@ -64,3 +35,13 @@ release tag commit and then it should change the CI overlay version to point to
6435
the head of branch `graalpy-patch-branch` in order to disable unnecessary gates
6536
on it. The GitHub sync needs to be manually enabled in the mirroring service
6637
configuration.
38+
39+
### Updating hpy
40+
41+
1. Switch to the `hpy-import` branch
42+
2. Delete `graalpython/hpy`
43+
3. Copy the sources from the hpy repo into `graalpython/hpy` (e.g git clone
44+
them there, then delete the `graalpython/hpy/.git` folder)
45+
4. Go back to your previous branch and merge hpy-import.
46+
5. Go to `graalpython/hpy/build.py` and update the `VERSION` constant to
47+
whatever you updated to.

docs/user/Native-Images-with-Python.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ These are:
5454
This uses an `ExecutorService` with a thread pool.
5555
If you want to disallow such extra threads or avoid pulling in `ExecutorService` and related classes, then set this property to `false` and retrieve the `PollPythonAsyncActions` object from the context's polyglot bindings.
5656
This object is executable and can be used to trigger Python asynchronous actions at the locations you desire.
57-
* `python.WithoutJNI=true` - This option removes any code that uses JNI. As a consequence, you cannot use the HPy JNI backend and maybe other parts that rely on JNI.
5857

5958

6059
### Removing Pre-initialized Python Heap

graalpython/com.oracle.graal.python.cext/CEXT-WINDOWS-README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

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

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2023, 2024, Oracle and/or its affiliates.
2+
# Copyright (c) 2023, 2025, Oracle and/or its affiliates.
33
#
44
# All rights reserved.
55
#
@@ -37,17 +37,9 @@ endfunction()
3737

3838
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
3939

40-
if(MSVC)
41-
message(FATAL_ERROR "C API cannot be built with MSVC")
42-
endif()
43-
44-
if(WIN32)
45-
require_var(GRAALVM_LLVM_LIB_DIR)
46-
endif()
4740
require_var(GRAALPY_PARENT_DIR)
4841
require_var(CAPI_INC_DIR)
4942
require_var(PYCONFIG_INCLUDE_DIR)
50-
require_var(TRUFFLE_H_INC)
5143
require_var(TRUFFLE_NFI_H_INC)
5244
require_var(GRAALPY_EXT)
5345

@@ -61,31 +53,67 @@ set(TARGET_LIBPYTHON "python-native")
6153
# common variables and compile/link options (for all build targets)
6254
######################################################################
6355

64-
set(CFLAGS_WARNINGS -Wall -Werror,-Wunknown-warning-option -Wno-unused-function -Wno-unused-variable -Wno-unused-const-variable
56+
if (MSVC)
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+
)
91+
else()
92+
set(CFLAGS_WARNINGS -Wall -Werror -Wno-unused-function -Wno-unused-variable -Wno-unused-const-variable
93+
-Wno-unknown-warning-option
94+
-Wno-discarded-qualifiers # _testbuffer.c
6595
-Wno-tautological-constant-out-of-range-compare # fileutils.c: wchar_t > MAX_UNICODE is always false on Windows
6696
-Wno-unused-but-set-variable # sqlite.c: BOOL bRc
6797
-Wno-ignored-pragmas # sre.c: #pragma optimize("agtw", on)
68-
-Wno-discarded-qualifiers # longobject.c: *pend = str; (gcc only hence: '-Wunknown-warning-option')
6998
-Wno-int-to-pointer-cast -Wno-int-conversion -Wno-void-pointer-to-int-cast
70-
-Wno-incompatible-pointer-types-discards-qualifiers -Wno-pointer-type-mismatch
99+
-Wno-incompatible-pointer-types-discards-qualifiers
71100
-Wno-braced-scalar-init -Wno-deprecated-declarations)
101+
add_compile_options(-ffile-prefix-map=${GRAALPY_PARENT_DIR}=.)
102+
endif()
72103

73-
add_compile_options(-ffile-prefix-map=${GRAALPY_PARENT_DIR}=.)
74104

75105
# preprocessor defines for all platforms
76106
add_compile_definitions(
77107
NDEBUG
78-
GRAALVM_PYTHON_LLVM
79108
)
80109

81-
add_compile_definitions(GRAALVM_PYTHON_LLVM_NATIVE)
82-
83110

84111
if(WIN32)
85112
add_compile_definitions(
86113
MS_WINDOWS
87114
Py_ENABLE_SHARED
88115
HAVE_DECLSPEC_DLL
116+
89117
)
90118
endif()
91119

@@ -155,7 +183,6 @@ include_directories(
155183
"${SRC_DIR}/include"
156184
"${CAPI_INC_DIR}"
157185
"${PYCONFIG_INCLUDE_DIR}"
158-
"${TRUFFLE_H_INC}"
159186
"${TRUFFLE_NFI_H_INC}"
160187
)
161188

@@ -261,9 +288,9 @@ target_compile_definitions(${TARGET_LIBPYTHON} PRIVATE Py_BUILD_CORE Py_BUILD_CO
261288
target_compile_options(${TARGET_LIBPYTHON} PRIVATE ${CFLAGS_WARNINGS})
262289

263290
if(WIN32)
264-
target_link_directories(${TARGET_LIBPYTHON} PRIVATE ${GRAALVM_LLVM_LIB_DIR})
265-
target_compile_options(${TARGET_LIBPYTHON} PRIVATE "-fmsc-version=1920")
266-
target_link_libraries(${TARGET_LIBPYTHON} sulong-native graalvm-llvm)
291+
if (NOT MSVC)
292+
target_compile_options(${TARGET_LIBPYTHON} PRIVATE "-fmsc-version=1920")
293+
endif()
267294
else()
268295
# Link to math library; required for functions like 'hypot' or similar
269296
target_link_libraries(${TARGET_LIBPYTHON} m)

graalpython/com.oracle.graal.python.cext/expat/winconfig.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@
4242
#include <memory.h>
4343
#include <string.h>
4444

45+
#include "expat_config.h"
46+
4547
#endif /* ndef WINCONFIG_H */

graalpython/com.oracle.graal.python.cext/include/internal/pycore_gc.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2022, 2024, Oracle and/or its affiliates.
1+
/* Copyright (c) 2022, 2025, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2022 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -174,7 +174,8 @@ struct _gc_runtime_state {
174174

175175
extern void _PyGC_InitState(struct _gc_runtime_state *);
176176

177-
extern Py_ssize_t _PyGC_CollectNoFail(PyThreadState *tstate);
177+
// GraalPy change: exporting _PyGC_CollectNoFail
178+
extern PyAPI_FUNC(Py_ssize_t) _PyGC_CollectNoFail(PyThreadState *tstate);
178179

179180

180181
// Functions to clear types free lists

graalpython/com.oracle.graal.python.cext/include/internal/pycore_global_objects.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2024, Oracle and/or its affiliates.
1+
/* Copyright (c) 2024, 2025, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2023 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -53,6 +53,7 @@ struct _Py_global_objects {
5353
_PyGC_Head_UNUSED _tuple_empty_gc_not_used;
5454
PyTupleObject tuple_empty;
5555
*/
56+
char GraalDummyField;
5657
} singletons;
5758
};
5859

graalpython/com.oracle.graal.python.cext/include/internal/pycore_object.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2022, 2024, Oracle and/or its affiliates.
1+
/* Copyright (c) 2022, 2025, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2022 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -251,7 +251,7 @@ _PyType_PreHeaderSize(PyTypeObject *tp)
251251

252252
void _PyObject_GC_Link(PyObject *op);
253253

254-
void _GraalPyObject_GC_NotifyOwnershipTransfer(PyObject *op);
254+
PyAPI_FUNC(void) _GraalPyObject_GC_NotifyOwnershipTransfer(PyObject *op);
255255

256256
// Usage: assert(_Py_CheckSlotResult(obj, "__getitem__", result != NULL));
257257
extern int _Py_CheckSlotResult(

graalpython/com.oracle.graal.python.cext/include/pythonrun.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2018, 2023, Oracle and/or its affiliates.
1+
/* Copyright (c) 2018, 2025, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2020 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -27,11 +27,13 @@ PyAPI_DATA(int) (*PyOS_InputHook)(void);
2727
to an 8k margin. */
2828
#define PYOS_STACK_MARGIN 2048
2929

30+
#if 0 // GraalPy change
3031
#if defined(WIN32) && !defined(MS_WIN64) && !defined(_M_ARM) && defined(_MSC_VER) && _MSC_VER >= 1300
3132
/* Enable stack checking under Microsoft C */
3233
// When changing the platforms, ensure PyOS_CheckStack() docs are still correct
3334
#define USE_STACKCHECK
3435
#endif
36+
#endif
3537

3638
#ifdef USE_STACKCHECK
3739
/* Check that we aren't overflowing our stack */

graalpython/com.oracle.graal.python.cext/modules/_cpython_sre/sre.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2018, 2024, Oracle and/or its affiliates.
1+
/* Copyright (c) 2018, 2025, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2020 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -1052,19 +1052,6 @@ _sre_SRE_Pattern_split_impl(PatternObject *self, PyObject *string,
10521052

10531053
}
10541054

1055-
__attribute__((always_inline))
1056-
inline static void *_memchr(const void *s, int c, Py_ssize_t n) {
1057-
unsigned char *p = (unsigned char*)s;
1058-
while(n--) {
1059-
if(*p != (unsigned char)c) {
1060-
p++;
1061-
} else {
1062-
return p;
1063-
}
1064-
}
1065-
return 0;
1066-
}
1067-
10681055
static PyObject*
10691056
pattern_subx(_sremodulestate* module_state,
10701057
PatternObject* self,
@@ -1099,7 +1086,7 @@ pattern_subx(_sremodulestate* module_state,
10991086
ptr = getstring(ptemplate, &n, &isbytes, &charsize, &view);
11001087
if (ptr) {
11011088
if (charsize == 1)
1102-
literal = _memchr(ptr, '\\', n) == NULL;
1089+
literal = memchr(ptr, '\\', n) == NULL;
11031090
else
11041091
literal = PyUnicode_FindChar(ptemplate, '\\', 0, n, 1) == -1;
11051092
} else {

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2024, Oracle and/or its affiliates.
1+
/* Copyright (c) 2024, 2025, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2024 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -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

0 commit comments

Comments
 (0)