Skip to content

Commit 210ec69

Browse files
committed
Add Distro.gcc_version
Exposes the default gcc major.minor version shipped by each distribution. Lets consumers gate per-distro workarounds (e.g. the GCC 15 default-`-std=gnu23` change that breaks OCaml < 5.1) on the actual compiler version rather than maintaining a hand-written list of affected distros. Versions were measured by booting each Docker image and running `gcc --version` after installing the distro's gcc/gcc-c++ package. Returns None for Windows/Cygwin (no inherent default gcc on the base image) and for releases whose images are no longer pullable from Docker Hub (Ubuntu 15.04, openSUSE Leap 42.1/42.2).
1 parent e13814e commit 210ec69

3 files changed

Lines changed: 127 additions & 0 deletions

File tree

CHANGES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
unreleased
2+
----------
3+
4+
- Add `Distro.gcc_version` to expose the default gcc major.minor version
5+
shipped by each distribution. This lets consumers gate per-distro
6+
workarounds (e.g. the GCC 15 default-`-std=gnu23` change that breaks
7+
OCaml < 5.1) on the actual compiler version rather than maintaining a
8+
hand-written list of affected distros (@mtelvers)
9+
110
v8.3.9 2026-05-12
211
-----------------
312

src-opam/distro.ml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,117 @@ let bubblewrap_version (t : t) =
12271227
| `Windows _ -> None
12281228
| `WindowsServer _ -> None
12291229

1230+
(* Default gcc major.minor as reported by [gcc --version] after installing
1231+
the distro's gcc/gcc-c++ package. Measured by booting each Docker image
1232+
and running the install. Distros whose images are no longer pullable
1233+
(Ubuntu 15.04, openSUSE Leap 42.1/42.2) are [None]. *)
1234+
let gcc_version (t : t) =
1235+
match resolve_alias t with
1236+
| `Alpine `V3_3 -> Some (5, 3)
1237+
| `Alpine `V3_4 -> Some (5, 3)
1238+
| `Alpine `V3_5 -> Some (6, 2)
1239+
| `Alpine `V3_6 -> Some (6, 3)
1240+
| `Alpine `V3_7 -> Some (6, 4)
1241+
| `Alpine `V3_8 -> Some (6, 4)
1242+
| `Alpine `V3_9 -> Some (8, 3)
1243+
| `Alpine `V3_10 -> Some (8, 3)
1244+
| `Alpine `V3_11 -> Some (9, 3)
1245+
| `Alpine `V3_12 -> Some (9, 3)
1246+
| `Alpine `V3_13 -> Some (10, 2)
1247+
| `Alpine `V3_14 -> Some (10, 3)
1248+
| `Alpine `V3_15 -> Some (10, 3)
1249+
| `Alpine `V3_16 -> Some (11, 2)
1250+
| `Alpine `V3_17 -> Some (12, 2)
1251+
| `Alpine `V3_18 -> Some (12, 2)
1252+
| `Alpine `V3_19 -> Some (13, 2)
1253+
| `Alpine `V3_20 -> Some (13, 2)
1254+
| `Alpine `V3_21 -> Some (14, 2)
1255+
| `Alpine `V3_22 -> Some (14, 2)
1256+
| `Alpine `V3_23 -> Some (15, 2)
1257+
| `Archlinux `Latest -> Some (16, 1)
1258+
| `CentOS `V6 -> Some (4, 4)
1259+
| `CentOS `V7 -> Some (4, 8)
1260+
| `CentOS `V8 -> Some (8, 5)
1261+
| `CentOS `V9 -> Some (11, 5)
1262+
| `CentOS `V10 -> Some (14, 3)
1263+
| `Debian `V7 -> Some (4, 7)
1264+
| `Debian `V8 -> Some (4, 9)
1265+
| `Debian `V9 -> Some (6, 3)
1266+
| `Debian `V10 -> Some (8, 3)
1267+
| `Debian `V11 -> Some (10, 2)
1268+
| `Debian `V12 -> Some (12, 2)
1269+
| `Debian `V13 -> Some (14, 2)
1270+
| `Debian `Testing -> Some (15, 2)
1271+
| `Debian `Unstable -> Some (15, 2)
1272+
| `Fedora `V21 -> Some (4, 9)
1273+
| `Fedora `V22 -> Some (5, 3)
1274+
| `Fedora `V23 -> Some (5, 3)
1275+
| `Fedora `V24 -> Some (6, 3)
1276+
| `Fedora `V25 -> Some (6, 4)
1277+
| `Fedora `V26 -> Some (7, 3)
1278+
| `Fedora `V27 -> Some (7, 3)
1279+
| `Fedora `V28 -> Some (8, 3)
1280+
| `Fedora `V29 -> Some (8, 3)
1281+
| `Fedora `V30 -> Some (9, 3)
1282+
| `Fedora `V31 -> Some (9, 3)
1283+
| `Fedora `V32 -> Some (10, 3)
1284+
| `Fedora `V33 -> Some (10, 3)
1285+
| `Fedora `V34 -> Some (11, 3)
1286+
| `Fedora `V35 -> Some (11, 3)
1287+
| `Fedora `V36 -> Some (12, 2)
1288+
| `Fedora `V37 -> Some (12, 3)
1289+
| `Fedora `V38 -> Some (13, 2)
1290+
| `Fedora `V39 -> Some (13, 3)
1291+
| `Fedora `V40 -> Some (14, 2)
1292+
| `Fedora `V41 -> Some (14, 3)
1293+
| `Fedora `V42 -> Some (15, 2)
1294+
| `Fedora `V43 -> Some (15, 2)
1295+
| `Fedora `V44 -> Some (16, 1)
1296+
| `OpenSUSE `V42_1 -> None (* image no longer pullable *)
1297+
| `OpenSUSE `V42_2 -> None (* image no longer pullable *)
1298+
| `OpenSUSE `V42_3 -> Some (4, 8)
1299+
| `OpenSUSE `V15_0 -> Some (7, 4)
1300+
| `OpenSUSE `V15_1 -> Some (7, 5)
1301+
| `OpenSUSE `V15_2 -> Some (7, 5)
1302+
| `OpenSUSE `V15_3 -> Some (7, 5)
1303+
| `OpenSUSE `V15_4 -> Some (7, 5)
1304+
| `OpenSUSE `V15_5 -> Some (7, 5)
1305+
| `OpenSUSE `V15_6 -> Some (7, 5)
1306+
| `OpenSUSE `V16_0 -> Some (15, 2)
1307+
| `OpenSUSE `Tumbleweed -> Some (15, 2)
1308+
| `OracleLinux `V7 -> Some (4, 8)
1309+
| `OracleLinux `V8 -> Some (8, 5)
1310+
| `OracleLinux `V9 -> Some (11, 5)
1311+
| `OracleLinux `V10 -> Some (14, 3)
1312+
| `Ubuntu `V12_04 -> Some (4, 6)
1313+
| `Ubuntu `V14_04 -> Some (4, 8)
1314+
| `Ubuntu `V15_04 -> None (* image no longer pullable *)
1315+
| `Ubuntu `V15_10 -> Some (5, 2)
1316+
| `Ubuntu `V16_04 -> Some (5, 4)
1317+
| `Ubuntu `V16_10 -> Some (6, 2)
1318+
| `Ubuntu `V17_04 -> Some (6, 3)
1319+
| `Ubuntu `V17_10 -> Some (7, 2)
1320+
| `Ubuntu `V18_04 -> Some (7, 5)
1321+
| `Ubuntu `V18_10 -> Some (8, 3)
1322+
| `Ubuntu `V19_04 -> Some (8, 3)
1323+
| `Ubuntu `V19_10 -> Some (9, 2)
1324+
| `Ubuntu `V20_04 -> Some (9, 4)
1325+
| `Ubuntu `V20_10 -> Some (10, 3)
1326+
| `Ubuntu `V21_04 -> Some (10, 3)
1327+
| `Ubuntu `V21_10 -> Some (11, 2)
1328+
| `Ubuntu `V22_04 -> Some (11, 4)
1329+
| `Ubuntu `V22_10 -> Some (12, 2)
1330+
| `Ubuntu `V23_04 -> Some (12, 3)
1331+
| `Ubuntu `V23_10 -> Some (13, 2)
1332+
| `Ubuntu `V24_04 -> Some (13, 3)
1333+
| `Ubuntu `V24_10 -> Some (14, 2)
1334+
| `Ubuntu `V25_04 -> Some (14, 2)
1335+
| `Ubuntu `V25_10 -> Some (15, 2)
1336+
| `Ubuntu `V26_04 -> Some (15, 2)
1337+
| `Cygwin _ -> None
1338+
| `Windows _ -> None
1339+
| `WindowsServer _ -> None
1340+
12301341
let base_distro_tag ?(arch = `X86_64) d =
12311342
match resolve_alias d with
12321343
| `Alpine v -> (

src-opam/distro.mli

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,13 @@ val bubblewrap_version : t -> (int * int * int) option
302302
(** [bubblewrap_version t] returns the version of bubblewrap available on that
303303
distribution. *)
304304

305+
val gcc_version : t -> (int * int) option
306+
(** [gcc_version t] returns the default version of gcc shipped on that
307+
distribution (i.e. what [gcc --version] reports after installing the
308+
distribution's [gcc] / [gcc-c++] package). Returns [None] for distros
309+
where gcc is not the default compiler (Windows, Cygwin) or where the
310+
image is no longer pullable from Docker Hub. *)
311+
305312
(** {2 Docker Hub addresses} *)
306313

307314
val tag_of_distro : t -> string

0 commit comments

Comments
 (0)