Commit d1fddea
committed
unix: support building Linux x86-64 from macOS aarch64
Docker on aarch64 macOS will automagically virtualize x86-64 containers
if containers are spawned with `platform=linux/amd64`. Performance of
spawned containers is a bit slower than native, but not horrible. This
functionality means it is viable to develop Linux x86-64 from modern
Apple hardware.
This commit teaches the build system to support cross-compiling
Linux x86-64 from macOS aarch64.
Implementing this wasn't too difficult: we need to pass `platform` into
Docker's APIs for building and creating containers. We need to teach
code to resolve the effective host platform when this scenario is
detected. And we need to advertise support for cross-compiling in the
`targets.yml` file.
In case you are wondering, yes, a similar solution could be employed for
Linux too by using emulation. But this requires Docker be configured to
support emulation, which isn't common. Rosetta on macOS "just works" and
is therefore the lowest hanging fruit to implement.1 parent 77c46f1 commit d1fddea
File tree
5 files changed
+86
-42
lines changed- cpython-unix
- pythonbuild
5 files changed
+86
-42
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
146 | 153 | | |
147 | 154 | | |
148 | 155 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
29 | 34 | | |
30 | 35 | | |
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
| 41 | + | |
36 | 42 | | |
37 | 43 | | |
38 | 44 | | |
| |||
98 | 104 | | |
99 | 105 | | |
100 | 106 | | |
101 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
102 | 114 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
114 | 124 | | |
115 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
116 | 134 | | |
117 | 135 | | |
118 | 136 | | |
| |||
960 | 978 | | |
961 | 979 | | |
962 | 980 | | |
963 | | - | |
964 | | - | |
965 | | - | |
966 | | - | |
967 | | - | |
968 | | - | |
969 | | - | |
970 | | - | |
971 | | - | |
972 | | - | |
973 | 981 | | |
974 | 982 | | |
975 | 983 | | |
| |||
1031 | 1039 | | |
1032 | 1040 | | |
1033 | 1041 | | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
1034 | 1053 | | |
1035 | 1054 | | |
1036 | 1055 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
| 559 | + | |
559 | 560 | | |
560 | 561 | | |
561 | 562 | | |
| |||
605 | 606 | | |
606 | 607 | | |
607 | 608 | | |
| 609 | + | |
608 | 610 | | |
609 | 611 | | |
610 | 612 | | |
| |||
655 | 657 | | |
656 | 658 | | |
657 | 659 | | |
| 660 | + | |
658 | 661 | | |
659 | 662 | | |
660 | 663 | | |
| |||
705 | 708 | | |
706 | 709 | | |
707 | 710 | | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
708 | 714 | | |
709 | 715 | | |
710 | 716 | | |
| |||
755 | 761 | | |
756 | 762 | | |
757 | 763 | | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
758 | 767 | | |
759 | 768 | | |
760 | 769 | | |
| |||
802 | 811 | | |
803 | 812 | | |
804 | 813 | | |
| 814 | + | |
805 | 815 | | |
806 | 816 | | |
807 | 817 | | |
| |||
850 | 860 | | |
851 | 861 | | |
852 | 862 | | |
| 863 | + | |
853 | 864 | | |
854 | 865 | | |
855 | 866 | | |
| |||
898 | 909 | | |
899 | 910 | | |
900 | 911 | | |
| 912 | + | |
901 | 913 | | |
902 | 914 | | |
903 | 915 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
269 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
270 | 273 | | |
271 | 274 | | |
272 | 275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
32 | 42 | | |
33 | 43 | | |
34 | 44 | | |
35 | 45 | | |
36 | 46 | | |
37 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
38 | 53 | | |
39 | 54 | | |
40 | | - | |
41 | | - | |
| 55 | + | |
| 56 | + | |
42 | 57 | | |
43 | 58 | | |
44 | 59 | | |
| |||
111 | 126 | | |
112 | 127 | | |
113 | 128 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
| |||
0 commit comments