Skip to content

Commit 5112e78

Browse files
committed
Use per-machine symbol_versions in policy.json
The symbol versions exposed by glibc/gcc/libstdc++ are different for a single "semver" version depending on the machine running. This commit reflects that fact by defining symbol_versions per machine.
1 parent a798547 commit 5112e78

File tree

4 files changed

+134
-64
lines changed

4 files changed

+134
-64
lines changed

auditwheel/policy/__init__.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,6 @@
1212
bits = 8 * (8 if sys.maxsize > 2 ** 32 else 4)
1313

1414

15-
_PLATFORM_REPLACEMENT_MAP = {}
16-
for _policy in {'manylinux1', 'manylinux2010'}:
17-
for _arch in {'x86_64', 'i686'}:
18-
_key = '{}_{}'.format(_policy, _arch)
19-
_value = 'linux_{}'.format(_arch)
20-
_PLATFORM_REPLACEMENT_MAP[_key] = [_value]
21-
22-
for _policy in {'manylinux2014'}:
23-
for _arch in {
24-
'x86_64', 'i686', 'aarch64', 'armv7l', 'ppc64', 'ppc64le', 's390x'
25-
}:
26-
_key = '{}_{}'.format(_policy, _arch)
27-
_value = 'linux_{}'.format(_arch)
28-
_PLATFORM_REPLACEMENT_MAP[_key] = [_value]
29-
30-
3115
def get_arch_name():
3216
machine = _platform_module.machine()
3317
if machine not in {'x86_64', 'i686'}:
@@ -43,9 +27,10 @@ def get_arch_name():
4327
_POLICIES = []
4428
_policies_temp = json.load(f)
4529
for _p in _policies_temp:
46-
_name = _p['name'] + '_' + _ARCH_NAME
47-
if _name in _PLATFORM_REPLACEMENT_MAP or _name.startswith('linux'):
48-
_p['name'] = _name
30+
if _ARCH_NAME in _p['symbol_versions'].keys() or _p['name'] == 'linux':
31+
if _p['name'] != 'linux':
32+
_p['symbol_versions'] = _p['symbol_versions'][_ARCH_NAME]
33+
_p['name'] = _p['name'] + '_' + _ARCH_NAME
4934
_POLICIES.append(_p)
5035

5136
POLICY_PRIORITY_HIGHEST = max(p['priority'] for p in _POLICIES)
@@ -93,7 +78,9 @@ def get_replace_platforms(name: str):
9378
['linux_i686']
9479
9580
"""
96-
return _PLATFORM_REPLACEMENT_MAP.get(name, [])
81+
if name.startswith('linux'):
82+
return []
83+
return ['linux_' + '_'.join(name.split('_')[1:])]
9784

9885

9986
# These have to be imported here to avoid a circular import.

auditwheel/policy/policy-schema.json

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,69 @@
11
{
2+
"$schema": "http://json-schema.org/draft-06/schema#",
23
"type": "array",
34
"items": {
4-
"type": "object",
5-
"properties": {
6-
"name": {"type": "string"},
7-
"priority": {"type": "integer"},
8-
"symbol_versions": {
9-
"type": "object",
10-
"patternProperties": {
11-
".*": {"type": "array",
12-
"items": {"type": "string"}}
5+
"$ref": "#/definitions/PolicyElement"
6+
},
7+
"definitions": {
8+
"PolicyElement": {
9+
"type": "object",
10+
"additionalProperties": false,
11+
"properties": {
12+
"name": {
13+
"type": "string"
14+
},
15+
"priority": {
16+
"type": "integer"
17+
},
18+
"symbol_versions": {
19+
"$ref": "#/definitions/SymbolVersion"
20+
},
21+
"lib_whitelist": {
22+
"type": "array",
23+
"items": {
24+
"type": "string"
25+
}
1326
}
1427
},
15-
"lib_whitelist": {
16-
"type": "array",
17-
"items": {"type": "string"}
18-
}
28+
"required": [
29+
"lib_whitelist",
30+
"name",
31+
"priority",
32+
"symbol_versions"
33+
],
34+
"title": "PolicyElement"
35+
},
36+
"SymbolVersion": {
37+
"type": "object",
38+
"additionalProperties": false,
39+
"properties": {
40+
"CXXABI": {
41+
"type": "array",
42+
"items": {
43+
"type": "string"
44+
}
45+
},
46+
"GCC": {
47+
"type": "array",
48+
"items": {
49+
"type": "string"
50+
}
51+
},
52+
"GLIBC": {
53+
"type": "array",
54+
"items": {
55+
"type": "string"
56+
}
57+
},
58+
"GLIBCXX": {
59+
"type": "array",
60+
"items": {
61+
"type": "string"
62+
}
63+
}
64+
},
65+
"required": [],
66+
"title": "SymbolVersion"
1967
}
2068
}
2169
}

auditwheel/policy/policy.json

Lines changed: 65 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@
77
{"name": "manylinux1",
88
"priority": 100,
99
"symbol_versions": {
10-
"GLIBC": ["2.0", "2.1", "2.1.1", "2.1.2", "2.1.3", "2.2", "2.2.1",
11-
"2.2.2", "2.2.3", "2.2.4", "2.2.5", "2.2.6", "2.3", "2.3.2",
12-
"2.3.3", "2.3.4", "2.4", "2.5"],
13-
"CXXABI": ["1.3", "1.3.1"],
14-
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6",
15-
"3.4.7", "3.4.8"],
16-
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "3.4.4", "4.0.0",
17-
"4.2.0"]
10+
"i686": {
11+
"CXXABI": ["1.3", "1.3.1"],
12+
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "3.4.4", "4.0.0", "4.2.0"],
13+
"GLIBC": ["2.0", "2.1", "2.1.1", "2.1.2", "2.1.3", "2.2", "2.2.1", "2.2.2", "2.2.3", "2.2.4", "2.2.5", "2.2.6", "2.3", "2.3.2", "2.3.3", "2.3.4", "2.4", "2.5"],
14+
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8"]
15+
},
16+
"x86_64": {
17+
"CXXABI": ["1.3", "1.3.1"],
18+
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "3.4.4", "4.0.0", "4.2.0"],
19+
"GLIBC": ["2.2.5", "2.2.6", "2.3", "2.3.2", "2.3.3", "2.3.4", "2.4", "2.5"],
20+
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8"]
21+
}
1822
},
1923
"lib_whitelist": [
2024
"libpanelw.so.5", "libncursesw.so.5",
@@ -29,16 +33,18 @@
2933
{"name": "manylinux2010",
3034
"priority": 90,
3135
"symbol_versions": {
32-
"GLIBC": ["2.0", "2.1", "2.1.1", "2.1.2", "2.1.3", "2.2", "2.2.1",
33-
"2.2.2", "2.2.3", "2.2.4", "2.2.5", "2.2.6", "2.3", "2.3.2",
34-
"2.3.3", "2.3.4", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9",
35-
"2.10", "2.11", "2.12"],
36+
"i686": {
3637
"CXXABI": ["1.3", "1.3.1", "1.3.2", "1.3.3"],
37-
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5",
38-
"3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11",
39-
"3.4.12", "3.4.13"],
40-
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "3.4.4", "4.0.0",
41-
"4.2.0", "4.3.0", "4.4.0", "4.5.0"]
38+
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "4.0.0", "4.2.0", "4.3.0", "4.4.0", "4.5.0"],
39+
"GLIBC": ["2.0", "2.1", "2.1.1", "2.1.2", "2.1.3", "2.2", "2.2.1", "2.2.2", "2.2.3", "2.2.4", "2.2.6", "2.3", "2.3.2", "2.3.3", "2.3.4", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10", "2.11", "2.12"],
40+
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11", "3.4.12", "3.4.13"]
41+
},
42+
"x86_64": {
43+
"CXXABI": ["1.3", "1.3.1", "1.3.2", "1.3.3"],
44+
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "3.4.4", "4.0.0", "4.2.0", "4.3.0"],
45+
"GLIBC": ["2.2.5", "2.2.6", "2.3", "2.3.2", "2.3.3", "2.3.4", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10", "2.11", "2.12"],
46+
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11", "3.4.12", "3.4.13"]
47+
}
4248
},
4349
"lib_whitelist": [
4450
"libgcc_s.so.1",
@@ -52,19 +58,48 @@
5258
{"name": "manylinux2014",
5359
"priority": 80,
5460
"symbol_versions": {
55-
"GLIBC": ["2.0", "2.1", "2.1.1", "2.1.2", "2.1.3", "2.2", "2.2.1",
56-
"2.2.2", "2.2.3", "2.2.4", "2.2.5", "2.2.6", "2.3", "2.3.2",
57-
"2.3.3", "2.3.4", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9",
58-
"2.10", "2.11", "2.12", "2.13", "2.14", "2.15", "2.16",
59-
"2.17"],
60-
"CXXABI": ["1.3", "1.3.1", "1.3.2", "1.3.3", "1.3.4", "1.3.5",
61-
"1.3.6", "1.3.7", "TM_1"],
62-
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5",
63-
"3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11",
64-
"3.4.12", "3.4.13", "3.4.14", "3.4.15", "3.4.16",
65-
"3.4.17", "3.4.18", "3.4.19"],
66-
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "3.4.4", "4.0.0",
67-
"4.2.0", "4.3.0", "4.4.0", "4.5.0", "4.7.0", "4.8.0"]
61+
"i686": {
62+
"CXXABI": ["1.3", "1.3.1", "1.3.2", "1.3.3", "1.3.4", "1.3.5", "1.3.6", "1.3.7", "TM_1"],
63+
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "4.0.0", "4.2.0", "4.3.0", "4.4.0", "4.5.0", "4.7.0", "4.8.0"],
64+
"GLIBC": ["2.0", "2.1", "2.1.1", "2.1.2", "2.1.3", "2.2", "2.2.1", "2.2.2", "2.2.3", "2.2.4", "2.2.6", "2.3", "2.3.2", "2.3.3", "2.3.4", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10", "2.11", "2.12", "2.13", "2.14", "2.15", "2.16", "2.17"],
65+
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11", "3.4.12", "3.4.13", "3.4.14", "3.4.15", "3.4.16", "3.4.17", "3.4.18", "3.4.19"]
66+
},
67+
"x86_64": {
68+
"CXXABI": ["1.3", "1.3.1", "1.3.2", "1.3.3", "1.3.4", "1.3.5", "1.3.6", "1.3.7", "TM_1"],
69+
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "3.4.4", "4.0.0", "4.2.0", "4.3.0", "4.7.0", "4.8.0"],
70+
"GLIBC": ["2.2.5", "2.2.6", "2.3", "2.3.2", "2.3.3", "2.3.4", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10", "2.11", "2.12", "2.13", "2.14", "2.15", "2.16", "2.17"],
71+
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11", "3.4.12", "3.4.13", "3.4.14", "3.4.15", "3.4.16", "3.4.17", "3.4.18", "3.4.19"]
72+
},
73+
"aarch64": {
74+
"CXXABI": ["1.3", "1.3.1", "1.3.2", "1.3.3", "1.3.4", "1.3.5", "1.3.6", "1.3.7", "TM_1"],
75+
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "3.4.4", "4.0.0", "4.2.0", "4.3.0", "4.5.0", "4.7.0"],
76+
"GLIBC": ["2.0", "2.17", "2.18"],
77+
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11", "3.4.12", "3.4.13", "3.4.14", "3.4.15", "3.4.16", "3.4.17", "3.4.18", "3.4.19"]
78+
},
79+
"ppc64": {
80+
"CXXABI": ["1.3", "1.3.1", "1.3.2", "1.3.3", "1.3.4", "1.3.5", "1.3.6", "1.3.7", "TM_1"],
81+
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "3.4.4", "4.0.0", "4.2.0", "4.3.0", "4.4.0", "4.5.0", "4.7.0", "4.8.0"],
82+
"GLIBC": ["2.0", "2.1", "2.1.1", "2.1.2", "2.1.3", "2.2", "2.2.1", "2.2.2", "2.2.3", "2.2.4", "2.2.5", "2.2.6", "2.3", "2.3.2", "2.3.3", "2.3.4", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10", "2.11", "2.12", "2.13", "2.14", "2.15", "2.16", "2.17"],
83+
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11", "3.4.12", "3.4.13", "3.4.14", "3.4.15", "3.4.16", "3.4.17", "3.4.18", "3.4.19"]
84+
},
85+
"ppc64le": {
86+
"CXXABI": ["1.3", "1.3.1", "1.3.2", "1.3.3", "1.3.4", "1.3.5", "1.3.6", "1.3.7", "LDBL_1.3", "TM_1"],
87+
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "3.4.4", "4.0.0", "4.2.0", "4.3.0", "4.7.0"],
88+
"GLIBC": ["2.0", "2.17"],
89+
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11", "3.4.12", "3.4.13", "3.4.14", "3.4.15", "3.4.16", "3.4.17", "3.4.18", "3.4.19", "LDBL_3.4", "LDBL_3.4.10", "LDBL_3.4.7"]
90+
},
91+
"s390x": {
92+
"CXXABI": ["1.3", "1.3.1", "1.3.2", "1.3.3", "1.3.4", "1.3.5", "1.3.6", "1.3.7", "LDBL_1.3", "TM_1"],
93+
"GCC": ["3.0", "3.3", "3.3.1", "3.4", "3.4.2", "3.4.4", "4.0.0", "4.1.0", "4.2.0", "4.3.0", "4.7.0"],
94+
"GLIBC": ["2.2", "2.2.1", "2.2.2", "2.2.3", "2.2.4", "2.2.6", "2.3", "2.3.2", "2.3.3", "2.3.4", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10", "2.11", "2.12", "2.13", "2.14", "2.15", "2.16", "2.17"],
95+
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11", "3.4.12", "3.4.13", "3.4.14", "3.4.15", "3.4.16", "3.4.17", "3.4.18", "3.4.19", "LDBL_3.4", "LDBL_3.4.10", "LDBL_3.4.7"]
96+
},
97+
"armv7l": {
98+
"CXXABI": ["1.3", "1.3.1", "1.3.2", "1.3.3", "1.3.4", "1.3.5", "1.3.6", "1.3.7", "ARM_1.3.3", "TM_1"],
99+
"GCC": ["3.0", "3.3", "3.3.1", "3.3.4", "3.4", "3.4.2", "3.5", "4.0.0", "4.2.0", "4.3.0", "4.7.0"],
100+
"GLIBC": ["2.0", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10", "2.11", "2.12", "2.13", "2.14", "2.15", "2.16", "2.17"],
101+
"GLIBCXX": ["3.4", "3.4.1", "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7", "3.4.8", "3.4.9", "3.4.10", "3.4.11", "3.4.12", "3.4.13", "3.4.14", "3.4.15", "3.4.16", "3.4.17", "3.4.18", "3.4.19"]
102+
}
68103
},
69104
"lib_whitelist": [
70105
"libgcc_s.so.1",

tests/integration/test_policy_files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_policy():
1212

1313

1414
def test_policy_checks_glibc():
15-
policy = versioned_symbols_policy({"some_library.so": {"GLIBC_2.5"}})
15+
policy = versioned_symbols_policy({"some_library.so": {"GLIBC_2.17"}})
1616
assert policy > POLICY_PRIORITY_LOWEST
1717
policy = versioned_symbols_policy({"some_library.so": {"GLIBC_999"}})
1818
assert policy == POLICY_PRIORITY_LOWEST

0 commit comments

Comments
 (0)