[PATCH] configure: add optional --enable-native option to compilation flags

11 views
Skip to first unread message

david.m...@gmail.com

unread,
Jan 23, 2026, 11:50:21 PM (10 days ago) Jan 23
to Window Maker Development
This patch adds an option to enable native CPU optimizations
by adding -march=native to the compiler flags, tuning the
generated code for the build machine at the expense of portability.

In some tests, especially on wrlib I saw 8% perf improvement.
Should be used by developers or those who recompile wmaker for their own usage.
---
 configure.ac               | 17 +++++++++++++++++
 doc/build/Compilation.texi |  4 ++++
 2 files changed, 21 insertions(+)

diff --git a/configure.ac b/configure.ac
index 86ac2a00..1d2bbe6e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -130,6 +130,20 @@ AS_IF([test "x$debug" = "xyes"],
 ])
 
 
+dnl Native CPU Optimizations Option
+dnl =================
+m4_divert_push([INIT_PREPARE])dnl
+AC_ARG_ENABLE([native],
+    [AS_HELP_STRING([--enable-native], [enable native option, @<:@default=no@:>@])],
+    [AS_CASE(["$enableval"],
+        [yes], [native=yes],
+        [no],  [native=no],
+        [AC_MSG_ERROR([bad value $enableval for --enable-native])] )],
+    [native=no])
+m4_divert_pop([INIT_PREPARE])dnl
+AS_IF([test "x$native" = "xyes"],
+    [AX_CFLAGS_GCC_OPTION([-march=native])])
+
 AX_CFLAGS_GCC_OPTION([-Wall])
 AX_CFLAGS_GCC_OPTION([-Wextra -Wno-sign-compare])
 dnl
@@ -1037,6 +1051,9 @@ echo "Supported graphic format libraries  :$supported_gfx"
 echo "Unsupported features                :$unsupported"
 echo "Pango text layout support in WINGs  : $pango"
 echo "Translated languages to support     :$supported_locales"
+AS_IF([test "x$native" = "xyes"],
+    [AS_ECHO(["Target architecture                 : native"]) ],
+    [AS_ECHO(["Target architecture                 : generic"]) ])
 AS_IF([test "x$WEB_REPO_ROOT" != "x"],
     [AS_ECHO(["Git repository for WMaker's Website : $WEB_REPO_ROOT"]) ])
 AS_IF([test "x$debug" = "xyes"],
diff --git a/doc/build/Compilation.texi b/doc/build/Compilation.texi
index 0046384a..bd4fc66d 100644
--- a/doc/build/Compilation.texi
+++ b/doc/build/Compilation.texi
@@ -651,6 +651,10 @@ appropriate requirements and works with this.
 Despite all this, if you think there's a use for it and feel in the mood to help, do not hesitate to
 discuss on the mailing list @value{emailsupport} to get it working.
 
+@item --enable-native
+Enable native CPU optimizations by adding @option{-march=native} to the compiler flags, tuning the
+generated code for the build machine at the expense of portability.
+
 @item --with-web-repo=@i{PATH}
 Enable generation of HTML documentation to be uploaded to @sc{Window Maker}'s website.
 The @file{@i{PATH}} is the directory where you have cloned the homepage's repository.
--
2.43.0

0001-configure-add-optional-enable-native-option-to-compi.patch

Andreas Metzler

unread,
Jan 24, 2026, 1:39:16 AM (10 days ago) Jan 24
to david.m...@gmail.com, Window Maker Development
On 2026-01-24 "david.m...@gmail.com" <david.m...@gmail.com> wrote:
> This patch adds an option to enable native CPU optimizations
> by adding -march=native to the compiler flags, tuning the
> generated code for the build machine at the expense of portability.

> In some tests, especially on wrlib I saw 8% perf improvement.
> Should be used by developers or those who recompile wmaker for their own
> usage.
[...]

Good morning,

Wouldn't these people simply set -march=native in their CFLAGS instead
of checking whether there is a special ./configure option available?

cu Andreas

david.m...@gmail.com

unread,
Jan 24, 2026, 8:55:57 AM (10 days ago) Jan 24
to Window Maker Development
Hi Andreas,

The patch is adding a reminder to be displayed at the end of the configure
for which architecture you are building wmaker.
I found that quite convenient, I am almost always forgetting to change it.
And I feel it's easier to have a "enable-native" than to remember to add 
./configure CFLAGS="-O2 -march=native" to achieve the same result.

But I am not a gcc expert, just that it makes it easier for me and I thought for others too.
 

Andreas Metzler

unread,
Jan 24, 2026, 9:57:34 AM (10 days ago) Jan 24
to wmake...@googlegroups.com
On 2026-01-24 "david.m...@gmail.com" <david.m...@gmail.com> wrote:
> On Saturday, 24 January 2026 at 01:39:16 UTC-5 Andreas Metzler wrote:
>>> On 2026-01-24 "david.m...@gmail.com" <david.m...@gmail.com> wrote:
>>> This patch adds an option to enable native CPU optimizations
>>> by adding -march=native to the compiler flags, tuning the
>>> generated code for the build machine at the expense of portability.

>>> In some tests, especially on wrlib I saw 8% perf improvement.
>>> Should be used by developers or those who recompile wmaker for their own
>>> usage.

>> Wouldn't these people simply set -march=native in their CFLAGS instead
>> of checking whether there is a special ./configure option available?

> Hi Andreas,

> The patch is adding a reminder to be displayed at the end of the configure
> for which architecture you are building wmaker.
> I found that quite convenient, I am almost always forgetting to change it.
> And I feel it's easier to have a "enable-native" than to remember to add
> ./configure CFLAGS="-O2 -march=native" to achieve the same result.

Hello David,

My point was that »./configure CFLAGS="-O2 -march=native"« works for
every piece of software that uses autoconf while "--enable-native" would
only work for wmaker. So isn't it simpler/easier to use the former than
special-case wmaker?

cu Andreas

Carlos R. Mafra

unread,
Jan 24, 2026, 10:18:37 AM (9 days ago) Jan 24
to wmake...@googlegroups.com
I think it is simpler to use a configuration option like the patch.
This way I don't need to type

./configure CFLAGS="-O2 -march=native"

every time. I know I could, but it is simpler if I don't need to.

I applied the patch, btw. It is simple and does not affect the code.


Reply all
Reply to author
Forward
0 new messages