Skip to content

Commit f35bfbf

Browse files
committed
[GR-65446] Add an ABI check github job
PullRequest: graalpython/4308
2 parents 78aae2b + 15b8538 commit f35bfbf

File tree

7 files changed

+15738
-1
lines changed

7 files changed

+15738
-1
lines changed

.github/workflows/ci-unittests.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,36 @@ on:
55
workflow_dispatch:
66

77
jobs:
8+
abi-check:
9+
if: github.event.pull_request.draft == false
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v6
13+
14+
- name: Install libabigail
15+
shell: bash
16+
run: |
17+
sudo apt-get update
18+
sudo apt-get install -y abigail-tools
19+
20+
- name: Get mx and labsjdk
21+
shell: bash
22+
run: |
23+
git config --global http.timeout 600
24+
git clone https://github.com/graalvm/mx
25+
./mx/mx fetch-jdk -A --jdk-id labsjdk-ce-latest
26+
27+
- name: Setup mx and JAVA_HOME
28+
shell: bash
29+
run: |
30+
echo "$(pwd)/mx/" >> "$GITHUB_PATH"
31+
echo "JAVA_HOME=$HOME/.mx/jdks/labsjdk-ce-latest" >> "$GITHUB_ENV"
32+
echo "JVMCI_VERSION_CHECK=ignore" >> "$GITHUB_ENV"
33+
34+
- name: Run abi-check
35+
shell: bash
36+
run: mx abi-check
37+
838
build-standalone-artifacts:
939
if: github.event.pull_request.draft == false && success()
1040
uses: ./.github/workflows/ci-matrix-gen.yml

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ repos:
4242
- id: check-toml
4343
exclude: '^graalpython/lib-python/.*'
4444
- id: check-added-large-files
45+
exclude: '^abi/abi-.*\.xml'
4546
- id: check-symlinks

AGENTS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# PROJECT KNOWLEDGE BASE
22

33
## OVERVIEW
4-
GraalPy (GraalVM Python) implementation: Java (Truffle) + C (CPython C-API compatibility) + Python stdlib/overrides, built and tested via the `mx` build tool.
4+
GraalPy is an alternative implementation of Python. The reference implementation of Python is CPython and GraalPy aims to be as compatible with CPython as possible.
5+
It consists of: Java (Truffle) + C (CPython C-API compatibility) + Python stdlib/overrides, built and tested via the `mx` build tool.
56

67
## STRUCTURE
78
```text

abi/abi-graalpy250.xml

Lines changed: 15652 additions & 0 deletions
Large diffs are not rendered by default.

abi/suppressions-base.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[suppress_function]
2+
label = GraalPy private symbols
3+
symbol_name_regexp = ^GraalPyPrivate.*
4+
drop = true
5+
6+
[suppress_variable]
7+
label = GraalPy private symbols
8+
symbol_name_regexp = ^GraalPyPrivate.*
9+
drop = true

abi/suppressions-graalpy250.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[suppress_variable]
2+
label = Removed ctypes private exported type objects
3+
symbol_name_regexp = ^(PyCArrayType_Type|PyCData_Type|PyCPointerType_Type|PyCSimpleType|PyCStructType_Type|Simple_Type|UnionType_Type)$
4+
drop = true

mx.graalpython/mx_graalpython.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2501,6 +2501,45 @@ def python_coverage(args):
25012501
mx.run(cmdargs)
25022502

25032503

2504+
def abi_check(_args):
2505+
for tool in ("abidw", "abidiff"):
2506+
if not shutil.which(tool):
2507+
mx.abort(f"Required tool '{tool}' was not found on PATH")
2508+
2509+
standalone_home = graalpy_standalone_home('jvm', dev=True, build=True)
2510+
shared_library = os.path.join(
2511+
standalone_home,
2512+
'lib',
2513+
f'graalpy{graal_version_short("major_minor")}',
2514+
'libpython-native.so',
2515+
)
2516+
if not os.path.exists(shared_library):
2517+
mx.abort(f"Could not find shared library to check: {shared_library}")
2518+
2519+
baseline = os.path.join(SUITE.dir, 'abi', f'abi-{GRAALPY_ABI_VERSION}.xml')
2520+
if not os.path.exists(baseline):
2521+
mx.abort(f"Could not find ABI baseline: {baseline}")
2522+
2523+
args = ['--suppressions', os.path.join(SUITE.dir, 'abi', 'suppressions-base.ini')]
2524+
versioned_suppressions = os.path.join(SUITE.dir, 'abi', f'suppressions-{GRAALPY_ABI_VERSION}.ini')
2525+
if os.path.exists(versioned_suppressions):
2526+
args += ['--suppressions', versioned_suppressions]
2527+
2528+
with tempfile.TemporaryDirectory(prefix='graalpy-abi-') as tmpdir:
2529+
dump_path = os.path.join(tmpdir, 'abi-current.xml')
2530+
run([
2531+
'abidw',
2532+
'--out-file', dump_path,
2533+
shared_library,
2534+
])
2535+
run([
2536+
'abidiff',
2537+
*args,
2538+
baseline,
2539+
dump_path,
2540+
], nonZeroIsFatal=True)
2541+
2542+
25042543
class GraalpythonBuildTask(mx.ProjectBuildTask):
25052544
class PrefixingOutput():
25062545
def __init__(self, prefix, printfunc):
@@ -2932,6 +2971,7 @@ def update_github_unittest_tags(*args):
29322971
'nativeclean': [nativeclean, ''],
29332972
'python-src-import': [mx_graalpython_import.import_python_sources, ''],
29342973
'python-coverage': [python_coverage, ''],
2974+
'abi-check': [abi_check, ''],
29352975
'punittest': [punittest, ''],
29362976
'graalpytest': [graalpytest, '[-h] [--python PYTHON] [TESTS]'],
29372977
'clean': [python_clean, '[--just-pyc]'],

0 commit comments

Comments
 (0)