From 3a12d033aa7613cda7913b4ef38d02db125619ad Mon Sep 17 00:00:00 2001 From: Michael Hendricks Date: Thu, 18 Jan 2024 06:36:09 -0700 Subject: [PATCH] Disable control flow integrity on OpenBSD Fixes #12903 --- Changes | 4 ++++ configure | 11 +++++++++++ configure.ac | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/Changes b/Changes index 0d15b8bb80cb..8ddd60792339 100644 --- a/Changes +++ b/Changes @@ -2314,6 +2314,10 @@ OCaml 4.14 maintenance version (Xavier Leroy and Anil Madhavapeddy, review by Anil Madhavapeddy and Sébastien Hinderer) +- #12903: Disable control flow integrity on OpenBSD >= 7.4 to avoid + illegal instruction errors on certain CPUs. + (Michael Hendricks, review by Miod Vallat) + ### Bug fixes: - #12878: fix incorrect treatment of injectivity for private recursive types. diff --git a/configure b/configure index fde1f82e28b9..21abebf78caf 100755 --- a/configure +++ b/configure @@ -15429,6 +15429,17 @@ case $host in #( ;; esac +# Disable control flow integrity + +case $host in #( + *-*-openbsd7.[4-9]|*-*-openbsd[89].*) : + oc_ldflags="$oc_ldflags -Wl,-z,nobtcfi" + natdynlinkopts="$natdynlinkopts -Wl,-z,nobtcfi" ;; #( + *) : + ;; +esac + + # Configure native dynlink natdynlink=false diff --git a/configure.ac b/configure.ac index 92037cc85697..3bde30ecca7e 100644 --- a/configure.ac +++ b/configure.ac @@ -1211,6 +1211,14 @@ AS_CASE([$host], [oc_ldflags="$oc_ldflags -Wl,--no-execute-only" natdynlinkopts="$natdynlinkopts -Wl,--no-execute-only"]) +# Disable control flow integrity + +AS_CASE([$host], + [[*-*-openbsd7.[4-9]|*-*-openbsd[89].*]], + [oc_ldflags="$oc_ldflags -Wl,-z,nobtcfi" + natdynlinkopts="$natdynlinkopts -Wl,-z,nobtcfi"]) + + # Configure native dynlink natdynlink=false