$OpenBSD: patch-Makefile,v 1.1 2017/07/16 14:11:21 robert Exp $

Index: Makefile
--- Makefile.orig
+++ Makefile
@@ -55,10 +55,18 @@ EXTRAVERSION=
 
 CPPFLAGS = -P -MD -MT $@
 
+# For gcc stack alignment is specified with -mpreferred-stack-boundary,
+# clang has the option -mstack-alignment for that purpose.
+ifneq ($(call cc-option,$(CC),-mpreferred-stack-boundary=4,),)
+	cc_stack_align_opt := -mpreferred-stack-boundary
+else ifneq ($(call cc-option,$(CC),-mstack-alignment=4,),)
+	cc_stack_align_opt := -mstack-alignment
+endif
+
 COMMONCFLAGS := -I$(OUT) -Isrc -Os -MD -g \
     -Wall -Wno-strict-aliasing -Wold-style-definition \
     $(call cc-option,$(CC),-Wtype-limits,) \
-    -m32 -march=i386 -mregparm=3 -mpreferred-stack-boundary=2 \
+    -m32 -march=i386 -mregparm=3 $(cc_stack_align_opt)=2 \
     -minline-all-stringops -fomit-frame-pointer \
     -freg-struct-return -ffreestanding -fno-delete-null-pointer-checks \
     -ffunction-sections -fdata-sections -fno-common -fno-merge-constants
