mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] prefer Oz optimization if the compiler supports it
@ 2017-07-19 10:44 Dmitry Golovin
  2017-07-19 12:52 ` Rich Felker
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Golovin @ 2017-07-19 10:44 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 333 bytes --]

Hi all!

This is a very small and simple patch, it adds support for Oz level of optimization (clang supports it). Since the kernel switched to Oz, I think it's a good idea to use it as long as the compiler supports it, on the other hand I didn't test if it has any advantages in case of musl.

The patch is attached.

Regards,
Dmitry

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-prefer-Oz-optimization-if-the-compiler-supports-it.patch --]
[-- Type: text/x-diff; name="0001-prefer-Oz-optimization-if-the-compiler-supports-it.patch", Size: 782 bytes --]

From 4f9a8ae81b7c3810b1ec8e31fc11cf72c0f82dee Mon Sep 17 00:00:00 2001
From: Dmitry Golovin <dima@golovin.in>
Date: Wed, 19 Jul 2017 13:35:25 +0300
Subject: [PATCH] prefer Oz optimization if the compiler supports it

---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 539c9fcb..1212af91 100755
--- a/configure
+++ b/configure
@@ -425,7 +425,7 @@ xno|x) printf "disabled\n" ; optimize=no ;;
 *) printf "custom\n" ;;
 esac
 
-test "$optimize" = no || tryflag CFLAGS_AUTO -Os || tryflag CFLAGS_AUTO -O2
+test "$optimize" = no || tryflag CFLAGS_AUTO -Oz || tryflag CFLAGS_AUTO -Os || tryflag CFLAGS_AUTO -O2
 test "$optimize" = yes && optimize="internal,malloc,string"
 
 if fnmatch 'no|size' "$optimize" ; then :
-- 
2.13.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] prefer Oz optimization if the compiler supports it
  2017-07-19 10:44 [PATCH] prefer Oz optimization if the compiler supports it Dmitry Golovin
@ 2017-07-19 12:52 ` Rich Felker
  2017-07-19 13:48   ` Dmitry Golovin
  0 siblings, 1 reply; 4+ messages in thread
From: Rich Felker @ 2017-07-19 12:52 UTC (permalink / raw)
  To: musl

On Wed, Jul 19, 2017 at 01:44:17PM +0300, Dmitry Golovin wrote:
> Hi all!
> 
> This is a very small and simple patch, it adds support for Oz level
> of optimization (clang supports it). Since the kernel switched to
> Oz, I think it's a good idea to use it as long as the compiler
> supports it, on the other hand I didn't test if it has any
> advantages in case of musl.
> 
> The patch is attached.

I'm not clear what the goal is. Why would Oz be preferred to Os? A
quick search shows that all it seems to do is disabling some
vectorization, which sounds undesirable.

Rich


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] prefer Oz optimization if the compiler supports it
  2017-07-19 12:52 ` Rich Felker
@ 2017-07-19 13:48   ` Dmitry Golovin
  2017-07-20  1:45     ` Rich Felker
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Golovin @ 2017-07-19 13:48 UTC (permalink / raw)
  To: musl

In theory Oz should produce slimmer binary than Os, but I want first to perform tests to see how optimization level really affects size and performance.

Regards,
Dmitry

19.07.2017, 15:52, "Rich Felker" <dalias@libc.org>:
> On Wed, Jul 19, 2017 at 01:44:17PM +0300, Dmitry Golovin wrote:
>>  Hi all!
>>
>>  This is a very small and simple patch, it adds support for Oz level
>>  of optimization (clang supports it). Since the kernel switched to
>>  Oz, I think it's a good idea to use it as long as the compiler
>>  supports it, on the other hand I didn't test if it has any
>>  advantages in case of musl.
>>
>>  The patch is attached.
>
> I'm not clear what the goal is. Why would Oz be preferred to Os? A
> quick search shows that all it seems to do is disabling some
> vectorization, which sounds undesirable.
>
> Rich


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] prefer Oz optimization if the compiler supports it
  2017-07-19 13:48   ` Dmitry Golovin
@ 2017-07-20  1:45     ` Rich Felker
  0 siblings, 0 replies; 4+ messages in thread
From: Rich Felker @ 2017-07-20  1:45 UTC (permalink / raw)
  To: musl

On Wed, Jul 19, 2017 at 04:48:49PM +0300, Dmitry Golovin wrote:
> In theory Oz should produce slimmer binary than Os, but I want first
> to perform tests to see how optimization level really affects size
> and performance.

My impression is that clang's -O2 and -Os are comparable in goals to
gcc's -Os, and that -Oz just makes some minor size-improvement
tradeoffs that could be bad for performance.

I've been wanting for a while to actually drop use of -Os with
selective -O3 for some dirs, and instead use -O2 for everything by
default. With recent compilers, -Os seems to do gratuitously stupid
things, and doesn't make much of a size difference vs -O2 (and even
less so if you use -fno-align-*). The main thing that's kept me from
actually pursuing such a change is not having had time to test the
effects myself or work with someone else to get it done.

Rich


> 19.07.2017, 15:52, "Rich Felker" <dalias@libc.org>:
> > On Wed, Jul 19, 2017 at 01:44:17PM +0300, Dmitry Golovin wrote:
> >>  Hi all!
> >>
> >>  This is a very small and simple patch, it adds support for Oz level
> >>  of optimization (clang supports it). Since the kernel switched to
> >>  Oz, I think it's a good idea to use it as long as the compiler
> >>  supports it, on the other hand I didn't test if it has any
> >>  advantages in case of musl.
> >>
> >>  The patch is attached.
> >
> > I'm not clear what the goal is. Why would Oz be preferred to Os? A
> > quick search shows that all it seems to do is disabling some
> > vectorization, which sounds undesirable.
> >
> > Rich


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-07-20  1:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-19 10:44 [PATCH] prefer Oz optimization if the compiler supports it Dmitry Golovin
2017-07-19 12:52 ` Rich Felker
2017-07-19 13:48   ` Dmitry Golovin
2017-07-20  1:45     ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).