Subject: Fix issue https://codeberg.org/guix/guix/issues/1446
Author: Nigko Yerden <nigko.yerden@gmail.com>
Date: 2025-07-25
License: gpl3+

diff --git a/opa/Makefile b/opa/Makefile
index 2692886..11a92cb 100644
--- a/opa/Makefile
+++ b/opa/Makefile
@@ -74,6 +74,7 @@ ${TARGLIB}-objs := opa_debug.o opa_time.o \
 
 ${TARGLIB}-objs := $(patsubst %.o, $(OUTDIR)/%.o, ${${TARGLIB}-objs})
 DEPS := $(${TARGLIB}-objs:.o=.d)
+BASECFLAGS_NO_AVX := $(filter-out -mavx -mavx2 -mavx512f, $(BASECFLAGS))
 
 .PHONY: all clean
 IGNORE_DEP_TARGETS = clean
@@ -84,12 +85,20 @@ install: all
 	@echo "Nothing to do for install."
 
 $(OUTDIR)/%.d:  $(this_srcdir)/%.c
-	$(CC) $(CFLAGS) $(BASECFLAGS) $(INCLUDES) $< -MM -MF $@ -MQ $(@:.d=.o)
+	if [ "$<" = "$(this_srcdir)/opa_time.c" ]; then \
+            $(CC) $(CFLAGS) $(BASECFLAGS_NO_AVX) $(INCLUDES) $< -MM -MF $@ -MQ $(@:.d=.o); \
+        else \
+            $(CC) $(CFLAGS) $(BASECFLAGS) $(INCLUDES) $< -MM -MF $@ -MQ $(@:.d=.o); \
+        fi
 
 $(OUTDIR)/%.d:  $(this_srcdir)/%.S
 	$(CC) $(CFLAGS) $(BASECFLAGS) $(INCLUDES) $< -MM -MF $@ -MQ $(@:.d=.o)
 
 $(OUTDIR)/%.o: $(this_srcdir)/%.c | ${DEPS}
-	$(CC) $(CFLAGS) $(BASECFLAGS) $(INCLUDES) -c $< -o $@
+	if [ "$<" = "$(this_srcdir)/opa_time.c" ]; then \
+	    $(CC) $(CFLAGS) $(BASECFLAGS_NO_AVX) $(INCLUDES) -c $< -o $@; \
+        else \
+	    $(CC) $(CFLAGS) $(BASECFLAGS) $(INCLUDES) -c $< -o $@; \
+        fi
 
 $(OUTDIR)/%.o: $(this_srcdir)/%.S | ${DEPS}
 	$(CC) $(ASFLAGS) -c $< -o $@