Skip to content

Commit 0d66ee5

Browse files
authored
python: Use more generic march for rosetta compatibiity (#44644)
See: #38076 Related: chainguard-dev/customer-issues#2094 Signed-off-by: Pris Nasrat <[email protected]> --------- Signed-off-by: Pris Nasrat <[email protected]>
1 parent 0357e80 commit 0d66ee5

File tree

4 files changed

+69
-26
lines changed

4 files changed

+69
-26
lines changed

Diff for: python-3.10.yaml

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package:
22
name: python-3.10
33
version: 3.10.16
4-
epoch: 1
4+
epoch: 2
55
description: "the Python programming language"
66
copyright:
77
- license: PSF-2.0
@@ -61,6 +61,22 @@ pipeline:
6161

6262
- name: Configure
6363
runs: |
64+
# Use more generic -march for rosetta2 compatibility
65+
# Add additional flag overrides here
66+
case "${{build.arch}}" in
67+
"aarch64")
68+
common_flags=""
69+
;;
70+
"x86_64")
71+
common_flags="-march=x86-64"
72+
;;
73+
esac
74+
75+
export CFLAGS="${CFLAGS/-Os/-O2} $common_flags"
76+
export CXXFLAGS="${CXXFLAGS/-Os/-O2} $common_flags"
77+
export CPPFLAGS="${CPPFLAGS/-Os/-O2} $common_flags"
78+
79+
6480
./configure \
6581
--host=${{host.triplet.gnu}} \
6682
--build=${{host.triplet.gnu}} \

Diff for: python-3.11.yaml

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package:
22
name: python-3.11
33
version: 3.11.11
4-
epoch: 1
4+
epoch: 2
55
description: "the Python programming language"
66
copyright:
77
- license: PSF-2.0
@@ -61,6 +61,21 @@ pipeline:
6161

6262
- name: Configure
6363
runs: |
64+
# Use more generic -march for rosetta2 compatibility
65+
# Add additional flag overrides here
66+
case "${{build.arch}}" in
67+
"aarch64")
68+
common_flags=""
69+
;;
70+
"x86_64")
71+
common_flags="-march=x86-64"
72+
;;
73+
esac
74+
75+
export CFLAGS="${CFLAGS/-Os/-O2} $common_flags"
76+
export CXXFLAGS="${CXXFLAGS/-Os/-O2} $common_flags"
77+
export CPPFLAGS="${CPPFLAGS/-Os/-O2} $common_flags"
78+
6479
./configure \
6580
--host=${{host.triplet.gnu}} \
6681
--build=${{host.triplet.gnu}} \

Diff for: python-3.12.yaml

+18-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package:
22
name: python-3.12
33
version: "3.12.9"
4-
epoch: 2
4+
epoch: 3
55
description: "the Python programming language"
66
copyright:
77
- license: PSF-2.0
@@ -68,6 +68,21 @@ pipeline:
6868

6969
- name: Configure
7070
runs: |
71+
# Use more generic -march for rosetta2 compatibility
72+
# Add additional flag overrides here
73+
case "${{build.arch}}" in
74+
"aarch64")
75+
common_flags=""
76+
;;
77+
"x86_64")
78+
common_flags="-march=x86-64"
79+
;;
80+
esac
81+
82+
export CFLAGS="${CFLAGS/-Os/-O2} $common_flags"
83+
export CXXFLAGS="${CXXFLAGS/-Os/-O2} $common_flags"
84+
export CPPFLAGS="${CPPFLAGS/-Os/-O2} $common_flags"
85+
7186
./configure \
7287
--host=${{host.triplet.gnu}} \
7388
--build=${{host.triplet.gnu}} \
@@ -213,18 +228,9 @@ subpackages:
213228
- runs: |
214229
mkdir -p "${{targets.contextdir}}/usr/bin"
215230
cp "${{targets.outdir}}/${{package.name}}-base/usr/bin/${{vars.python}}" "${{targets.contextdir}}/usr/bin/"
231+
# Note this sets the capability the test using getcap fails but the
232+
# capability is set in images with this package.
216233
setcap cap_net_bind_service=+eip "${{targets.contextdir}}/usr/bin/${{vars.python}}"
217-
test:
218-
environment:
219-
contents:
220-
packages:
221-
- libcap-utils
222-
pipeline:
223-
- runs: |
224-
stat "/usr/bin/${{vars.python}}"
225-
- name: Test file capabilities
226-
runs: |
227-
getcap /usr/bin/${{vars.python}} | cut -d ' ' -f2 | grep -q -E '^cap_net_bind_service=eip$'
228234
229235
- name: "${{package.name}}-tk"
230236
dependencies:

Diff for: python-3.13.yaml

+18-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package:
22
name: python-3.13
33
version: "3.13.2"
4-
epoch: 2
4+
epoch: 3
55
description: "the Python programming language"
66
copyright:
77
- license: PSF-2.0
@@ -68,6 +68,21 @@ pipeline:
6868

6969
- name: Configure
7070
runs: |
71+
# Use more generic -march for rosetta2 compatibility
72+
# Add additional flag overrides here
73+
case "${{build.arch}}" in
74+
"aarch64")
75+
common_flags=""
76+
;;
77+
"x86_64")
78+
common_flags="-march=x86-64"
79+
;;
80+
esac
81+
82+
export CFLAGS="${CFLAGS/-Os/-O2} $common_flags"
83+
export CXXFLAGS="${CXXFLAGS/-Os/-O2} $common_flags"
84+
export CPPFLAGS="${CPPFLAGS/-Os/-O2} $common_flags"
85+
7186
./configure \
7287
--host=${{host.triplet.gnu}} \
7388
--build=${{host.triplet.gnu}} \
@@ -213,18 +228,9 @@ subpackages:
213228
- runs: |
214229
mkdir -p "${{targets.contextdir}}/usr/bin"
215230
cp "${{targets.outdir}}/${{package.name}}-base/usr/bin/${{vars.python}}" "${{targets.contextdir}}/usr/bin/"
231+
# Note this sets the capability the test using getcap fails but the
232+
# capability is set in images with this package.
216233
setcap cap_net_bind_service=+eip "${{targets.contextdir}}/usr/bin/${{vars.python}}"
217-
test:
218-
environment:
219-
contents:
220-
packages:
221-
- libcap-utils
222-
pipeline:
223-
- runs: |
224-
stat /usr/bin/${{vars.python}}
225-
- name: Test file capabilities
226-
runs: |
227-
getcap /usr/bin/${{vars.python}} | cut -d ' ' -f2 | grep -q -E '^cap_net_bind_service=eip$'
228234
229235
- name: "${{package.name}}-tk"
230236
dependencies:

0 commit comments

Comments
 (0)