From b4d6fe9fab248add7c1e93365a0c209866b70222 Mon Sep 17 00:00:00 2001 From: Julien Portalier Date: Tue, 22 Oct 2024 17:59:08 +0200 Subject: [PATCH] OpenBSD: disable indirect branch tracking (#13665) OpenBSD 7.4+ enforces Indirect Branch Tracking but we're not yet compatible in Crystal, so we disable the feature for the time being. --- src/compiler/crystal/compiler.cr | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/compiler/crystal/compiler.cr b/src/compiler/crystal/compiler.cr index 6c7664bacc25..9668fa92b423 100644 --- a/src/compiler/crystal/compiler.cr +++ b/src/compiler/crystal/compiler.cr @@ -500,6 +500,13 @@ module Crystal else link_flags = @link_flags || "" link_flags += " -rdynamic" + + if program.has_flag?("openbsd") + # OpenBSD requires Indirect Branch Tracking by default, but we're not + # compatible (yet), so we disable it for now: + link_flags += " -Wl,-znobtcfi" + end + {DEFAULT_LINKER, %(#{DEFAULT_LINKER} "${@}" -o #{Process.quote_posix(output_filename)} #{link_flags} #{program.lib_flags(@cross_compile)}), object_names} end end