diff --git a/qemu.spec b/qemu.spec
index 3ec62ba..feac33c 100644
--- a/qemu.spec
+++ b/qemu.spec
@@ -1125,7 +1125,7 @@ make V=1 %{?_smp_mflags} $buildldflags
 popd
 %endif
 
-gcc %{_sourcedir}/ksmctl.c -O2 -g -o ksmctl
+gcc %{_sourcedir}/ksmctl.c $RPM_OPT_FLAGS $RPM_LD_FLAGS -o ksmctl
 
 
 %install