Building With -03 Flags. - BSD

This is a discussion on Building With -03 Flags. - BSD ; Hi. When I was using an i386 box I edited make.conf - did a buildworld to build and optimize programs with 02-flags and everything worked just fine. I'm now using FBSD-amd64. By default, its building programs and buildworld with -02 ...

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 20 of 46

Thread: Building With -03 Flags.

  1. Building With -03 Flags.

    Hi.

    When I was using an i386 box I edited make.conf - did a buildworld to build
    and optimize programs with 02-flags and everything worked just fine.

    I'm now using FBSD-amd64. By default, its building programs and buildworld
    with -02 (The only thing I added to /etc/make.conf was to knock out
    profile, games etc.

    Since everything is building with -02 by default, can I kick the optimize
    flags to -03 without makeing the system unstable? Will it work if I
    use -03?

    Thanks in advance..







  2. Re: Building With -03 Flags.

    In article <_3Aqh.53$Pa1.16@newsfe03.lga>,
    Timmy writes:
    >
    > I'm now using FBSD-amd64. By default, its building programs and buildworld
    > with -02 (The only thing I added to /etc/make.conf was to knock out
    > profile, games etc.
    >
    > Since everything is building with -02 by default, can I kick the optimize
    > flags to -03 without makeing the system unstable? Will it work if I
    > use -03?


    What is the difference between -O2 and -O3? If you can't
    answer that question, then it is probably:
    (a) safe to use -O3
    (b) unsafe to use -O3
    (c) someone is too lazy to RTFM

    --
    Steve
    http://troutmask.apl.washington.edu/~kargl/

  3. Re: Building With -03 Flags.

    Steven G. Kargl wrote:

    > In article <_3Aqh.53$Pa1.16@newsfe03.lga>,
    > Timmy writes:
    >>
    >> I'm now using FBSD-amd64. By default, its building programs and
    >> buildworld
    >> with -02 (The only thing I added to /etc/make.conf was to knock out
    >> profile, games etc.
    >>
    >> Since everything is building with -02 by default, can I kick the optimize
    >> flags to -03 without makeing the system unstable? Will it work if I
    >> use -03?

    >
    > What is the difference between -O2 and -O3?


    Better optimization and faster program response.

    > If you can't
    > answer that question, then it is probably:
    > (a) safe to use -O3
    > (b) unsafe to use -O3
    > (c) someone is too lazy to RTFM


    Why don't you RTFM?!! You don't seem to know the answer. Why you wanna tell
    me to RTFM when you didn't have the answer? Why you wanna flame people for
    asking questions? Where in the fbsd handbook does it talk about programing
    flags and build optimizing?

    I think you're the one who needs to RTFM. If you can't answer the question
    don't respond.


  4. Re: Building With -03 Flags.

    Steven G. Kargl wrote:
    > In article <_3Aqh.53$Pa1.16@newsfe03.lga>,
    > Timmy writes:
    >>
    >> I'm now using FBSD-amd64. By default, its building programs and buildworld
    >> with -02 (The only thing I added to /etc/make.conf was to knock out
    >> profile, games etc.
    >>
    >> Since everything is building with -02 by default, can I kick the optimize
    >> flags to -03 without makeing the system unstable? Will it work if I
    >> use -03?

    >
    > What is the difference between -O2 and -O3?


    One?

    --
    Warren Block * Rapid City, South Dakota * USA

  5. Re: Building With -03 Flags.

    Timmy wrote:
    > By default, its building programs and "buildworld" with -02
    > ...
    > can I kick the optimize flags to -03
    > without makeing the system unstable?


    No, you cannot.

    The other poster was right to ask to you RTFM,
    since make.conf(5) states that you should only
    buildworld with -O or -O2. Currently FreeBSD developers
    will only answer bug reports for -O and -O2.

    There were many, many bugs that surface
    when building with O3 or above.
    And today, we still don't know if there are more.

    - JT


  6. Re: Building With -03 Flags.

    JT wrote:

    > Timmy wrote:
    >> By default, its building programs and "buildworld" with -02
    >> ...
    >> can I kick the optimize flags to -03
    >> without makeing the system unstable?

    >
    > No, you cannot.
    >
    > The other poster was right to ask to you RTFM,
    > since make.conf(5) states that you should only
    > buildworld with -O or -O2. Currently FreeBSD developers
    > will only answer bug reports for -O and -O2.
    >
    > There were many, many bugs that surface
    > when building with O3 or above.
    > And today, we still don't know if there are more.
    >
    > - JT


    Okay, I won't do it then..
    Basicley I was thinking that since I could kick the pipes on i386 a few
    levels without troubles (From the default) I could do the same on a system
    that uses -02 by default.

    My mistake, It seemed logical, as Spock would say. ;-) Well, it seemed
    logical to me, but I'm a newbie, so what do I know, I'm trying to learn :-)



  7. Re: Building With -03 Flags.

    On Sun, 14 Jan 2007 20:18:33 -0500, Timmy wrote:
    >Steven G. Kargl wrote:
    >>In article <_3Aqh.53$Pa1.16@newsfe03.lga>,
    >>Timmy writes:
    >>>
    >>> I'm now using FBSD-amd64. By default, its building programs and
    >>> buildworld
    >>> with -02 (The only thing I added to /etc/make.conf was to knock out
    >>> profile, games etc.
    >>>
    >>> Since everything is building with -02 by default, can I kick the optimize
    >>> flags to -03 without makeing the system unstable? Will it work if I
    >>> use -03?

    >>
    >> What is the difference between -O2 and -O3?

    >
    > Better optimization and faster program response.
    >
    >> If you can't
    >> answer that question, then it is probably:
    >> (a) safe to use -O3
    >> (b) unsafe to use -O3
    >> (c) someone is too lazy to RTFM

    >
    > Why don't you RTFM?!! You don't seem to know the answer. Why you wanna tell
    > me to RTFM when you didn't have the answer? Why you wanna flame people for
    > asking questions? Where in the fbsd handbook does it talk about programing
    > flags and build optimizing?


    Hey, hold your horses there, for a moment! :-)

    I'm positively sure Steven G. Kargl *knows* the answer. I bet he also
    knows the *exact* difference between -O2 and -O3 optimization levels. He
    is one of the people who are actively making a large number of
    contributions to GCC, so I'm pretty certain he knows what he is talking
    about.

    His reply may have come out a bit harsh, but he is trying to make a point.

    His point is: ``If you don't know what the difference between these two
    optimization levels is, don't tinker with the default build options.
    Before tinkering, you should dig a bit more in the manuals of GCC, and try
    to learn more about what these options do.''

    To answer your original question:

    No, it's not safe to light-heartedly enable -O3 optimizations. There is a
    big, fat warning about this inear the description of CFLAGS in the file
    `/usr/share/examples/etc/make.conf'. You should read at least this file,
    understand what the consequences of enabling -O3 can be, and then make an
    informed decision for yourself.

    - Giorgos


  8. Re: Building With -03 Flags.

    On Mon, 15 Jan 2007 01:29:13 -0000, Warren Block wrote:
    >Steven G. Kargl wrote:
    >> What is the difference between -O2 and -O3?

    >
    > One?


    ROFLMAO


  9. Re: Building With -03 Flags.

    On Sun, 14 Jan 2007 22:07:51 -0500, Timmy wrote:
    > Basicley I was thinking that since I could kick the pipes on i386 a
    > few levels without troubles (From the default) I could do the same on
    > a system that uses -02 by default.


    FWIW, there is no -02 option.

    You are using a zero (`0') character, but the option is called -O2, with
    a "capital `o'" instead. If this is a font-related problem, caused by
    the fact that the font family you are using has very similar glyphs for
    'O' (capital 'o') and '0' (zero), it's probably a good idea to switch
    fonts

    Please make sure you are as precise as possible when discussing compiler
    options. There are so many of them that getting a single letter wrong
    may convey a _very_ different meaning to your readers.

    - Giorgos


  10. Re: Building With -03 Flags.

    Giorgos Keramidas wrote:

    > On Sun, 14 Jan 2007 20:18:33 -0500, Timmy wrote:
    >>Steven G. Kargl wrote:
    >>>In article <_3Aqh.53$Pa1.16@newsfe03.lga>,
    >>>Timmy writes:
    >>>>
    >>>> I'm now using FBSD-amd64. By default, its building programs and
    >>>> buildworld
    >>>> with -02 (The only thing I added to /etc/make.conf was to knock out
    >>>> profile, games etc.
    >>>>
    >>>> Since everything is building with -02 by default, can I kick the
    >>>> optimize flags to -03 without makeing the system unstable? Will it work
    >>>> if I use -03?
    >>>
    >>> What is the difference between -O2 and -O3?

    >>
    >> Better optimization and faster program response.
    >>
    >>> If you can't
    >>> answer that question, then it is probably:
    >>> (a) safe to use -O3
    >>> (b) unsafe to use -O3
    >>> (c) someone is too lazy to RTFM

    >>
    >> Why don't you RTFM?!! You don't seem to know the answer. Why you wanna
    >> tell me to RTFM when you didn't have the answer? Why you wanna flame
    >> people for asking questions? Where in the fbsd handbook does it talk
    >> about programing flags and build optimizing?

    >
    > Hey, hold your horses there, for a moment! :-)


    Ok, I didn't mean the get hateful. Mr. Kargl I apologize to you.

    > I'm positively sure Steven G. Kargl *knows* the answer. I bet he also
    > knows the *exact* difference between -O2 and -O3 optimization levels. He
    > is one of the people who are actively making a large number of
    > contributions to GCC, so I'm pretty certain he knows what he is talking
    > about.


    I'm sure he does.

    > His reply may have come out a bit harsh, but he is trying to make a point.



    I understand, I would much rather he said, hey dumb ass, you can't do that.
    I looked at man make.conf I figured well, you shouldn't build no higher
    than O2. (To be on the safe side) I use FBSD as a desktop O/S I'm not
    running clusters of servers, nor am I in an enterprise environment. If my
    desktop gets fubar, I can reinstall, it ain't a big deal, all data is on a.
    DVD. It would be an inconvenance, but thats about all.

    > His point is: ``If you don't know what the difference between these two
    > optimization levels is, don't tinker with the default build options.


    How are you going to learn anything without tinkering with your system? What
    little bit I know has come from much trial and error.

    > Before tinkering, you should dig a bit more in the manuals of GCC, and try
    > to learn more about what these options do.''


    I think you guys are missing my point, or where I was coming from. Like I
    said, I was using an i386 box, I went from the default to -O2. Since amd64
    builds with -O2 BY DEFAULT, I figured I could kick it up a notch without
    any problems.

    > To answer your original question:
    >
    > No, it's not safe to light-heartedly enable -O3 optimizations. There is a
    > big, fat warning about this inear the description of CFLAGS in the file
    > `/usr/share/examples/etc/make.conf'. You should read at least this file,
    > understand what the consequences of enabling -O3 can be, and then make an
    > informed decision for yourself.
    >
    > - Giorgos


    I understand. I assumed the -O3 warning was a safeguard 'type' benchmark.
    It's like - all cpu's can be overclocked, the makers of the cpu set levels
    much lower than what the cpu can handle. I guess I was thinking the same
    thing with regards to FBSD. .i.e these are the recommended settings for a
    safe computing environment, go above them at your own risk.

    P.S.

    Sorry for coming off as an ass.

  11. Re: Building With -03 Flags.

    Steven G. Kargl wrote:

    > In article <_3Aqh.53$Pa1.16@newsfe03.lga>,
    > Timmy writes:
    >>
    >> I'm now using FBSD-amd64. By default, its building programs and
    >> buildworld
    >> with -02 (The only thing I added to /etc/make.conf was to knock out
    >> profile, games etc.
    >>
    >> Since everything is building with -02 by default, can I kick the optimize
    >> flags to -03 without makeing the system unstable? Will it work if I
    >> use -03?

    >
    > What is the difference between -O2 and -O3? If you can't
    > answer that question, then it is probably:
    > (a) safe to use -O3
    > (b) unsafe to use -O3
    > (c) someone is too lazy to RTFM
    >


    Sorry to come off as such an ass. Me telling you to RTFM? Yeah, I kicked
    myself. ;-)

    Anyway, I'm trying to learn this stuff.

  12. Re: Building With -03 Flags.

    On Sun, 14 Jan 2007 22:47:07 -0500, Timmy wrote:
    >Giorgos Keramidas wrote:
    >> Before tinkering, you should dig a bit more in the manuals of
    >> GCC, and try to learn more about what these options do.''

    >
    > I think you guys are missing my point, or where I was coming
    > from. Like I said, I was using an i386 box, I went from the
    > default to -O2. Since amd64 builds with -O2 BY DEFAULT, I
    > figured I could kick it up a notch without any problems.


    Well, you are certainly free to experiment

    I just wanted to make sure you understand that this may cause problems.
    If you *know* what you are doing and still want to experiment, that's a
    very different thing altogether. Once you head down the experimentation
    path, we may even get something good out of it. As your experience with
    GCC grows, it may even turn out that you have enough knowledge to help
    us bump the default FreeBSD optimization level to something higher, by
    using your experience to fix any problems FreeBSD currently may have
    with -O3 or higher

    >> To answer your original question:
    >>
    >> No, it's not safe to light-heartedly enable -O3 optimizations. There is a
    >> big, fat warning about this inear the description of CFLAGS in the file
    >> `/usr/share/examples/etc/make.conf'. You should read at least this file,
    >> understand what the consequences of enabling -O3 can be, and then make an
    >> informed decision for yourself.
    >>
    >> - Giorgos

    >
    > I understand. I assumed the -O3 warning was a safeguard 'type' benchmark.

    [...]
    > i.e these are the recommended settings for a safe computing
    > environment, go above them at your own risk.


    Exactly

    > Sorry for coming off as an ass.


    No hard feelings here, at least; I can assure you


  13. Re: Building With -03 Flags.

    Timmy wrote:
    > Hi.
    >
    > When I was using an i386 box I edited make.conf - did a buildworld to build
    > and optimize programs with 02-flags and everything worked just fine.
    >
    > I'm now using FBSD-amd64. By default, its building programs and buildworld
    > with -02 (The only thing I added to /etc/make.conf was to knock out
    > profile, games etc.
    >
    > Since everything is building with -02 by default, can I kick the optimize
    > flags to -03 without makeing the system unstable? Will it work if I
    > use -03?


    This is certainly *not* recommended. Optimizing with -O3 is far more
    susceptible to producing bugs, and on a variety of programs i have,
    produces slower code in a fair number of cases. It is not even clear
    that -O2 is better than -O, except that perhaps some constructions
    depend on being transformed by -O2, i hope not for FreeBSD, but this is
    the case for Linux.



    --

    Michel TALON


  14. Re: Building With -03 Flags.

    Timmy wrote:
    > > What is the difference between -O2 and -O3?

    >
    > Better optimization and faster program response.


    No.

    >
    > > If you can't
    > > answer that question, then it is probably:
    > > (a) safe to use -O3
    > > (b) unsafe to use -O3
    > > (c) someone is too lazy to RTFM

    >
    > Why don't you RTFM?!! You don't seem to know the answer. Why you wanna tell
    > me to RTFM when you didn't have the answer? Why you wanna flame people for
    > asking questions? Where in the fbsd handbook does it talk about programing
    > flags and build optimizing?
    >
    > I think you're the one who needs to RTFM. If you can't answer the question
    > don't respond.
    >


    You happen to speak to someone (Karl) who is particularly knowledgeable
    in compiler stuff, and does a lot of numerical computations. He rightly
    pointed out that someone who doesn't know the fine points of the
    difference between -O2 and -O3 shouldn't touch -O3 "with a bargepole".
    The -O3 flag is only of interest for numerical computations, and *after*
    having checked on each specific program that it enhances performance,
    which is not necessary the case. On OS type program, which most of the
    time is waiting lock acquisition or IO completion, using -O3 is like
    pissing in a violin to hear its sound. The parts of the kernel who need
    to be very fast (like bzeroing) are already programmed in assembly.
    Furthermore, -O3 is *known* to produce buggy code in a number of cases,
    and kernel developers don't check that their code is resistant to these
    situations, since -O2 is the officially supported compilation flag.

    Anyways, the optimization flag has exactly *zero* effect on the kernel
    performance, the best proof being that FreeBSD-4 compiled with -O
    is far more performant than either FreeBSD-6 compiled with -O2 or
    Linux kernel 2.6 with -O2 in performance intensive applications on
    monoprocessors. Far more important is the quality of locking
    implementation, quality of IO processing, etc.



    --

    Michel TALON


  15. Re: Building With -03 Flags.

    In article _3Aqh.53$Pa1.16@newsfe03.lga, dated Sun, 14 Jan 2007 19:40:22
    -0500, Timmy wrote:
    >
    > I'm now using FBSD-amd64. By default, its building programs and buildworld
    > with -02 (The only thing I added to /etc/make.conf was to knock out
    > profile, games etc.
    >
    > Since everything is building with -02 by default, can I kick the optimize
    > flags to -03 without makeing the system unstable? Will it work if I
    > use -03?
    >
    > Thanks in advance..


    I've been using the following for both CFLAGS and COPTFLAGS for quite some
    time now under 7.0-CURRENT/amd64, with no ill effects:

    -O3 -pipe -Wno-error -fomit-frame-pointer -DNO_MALLOC_EXTRAS

    HTH

    --
    Conrad J. Sabatier
    "In Unix veritas"

  16. Re: Building With -03 Flags.

    In article 4PCqh.74$uS3.44@newsfe06.lga, dated Sun, 14 Jan 2007 22:47:07
    -0500, Timmy wrote:
    >
    > How are you going to learn anything without tinkering with your system?
    > What little bit I know has come from much trial and error.


    Have you tried looking at the info pages for gcc (i.e., doing an "info
    gcc" at the command line)? There's a whole section there devoted to the
    various optimization options, and it also plainly describes which
    optimizations are enabled at each -O level.

    If you find working with the info program a tad clumsy, you may want to
    try installing the tkinfo port, similar to tkman. Both of these, in fact,
    are quite handy, and make using info and man pages much, much more
    convenient.

    --
    Conrad J. Sabatier
    "In Unix veritas"

  17. Re: Building With -03 Flags.

    Begin
    On 2007-01-15, Timmy wrote:
    > Basicley I was thinking that since I could kick the pipes on i386 a few
    > levels without troubles (From the default) I could do the same on a system
    > that uses -02 by default.


    Well, the thing is that --as already pointed out-- upping the optimisation
    level tends to open up all sorts of problems in nasty nooks and crannies.
    Fixing them requires fixing the code, or the compiler, or both.

    You're proposing setting a higher-than-tested-for optimization level
    by default. Inevitably, you'll forget that you did that. Then sometime
    later you'll do a buildworld or update all your ports. Can you imagine
    what happens next? How'd you feel about that? After finding out it was
    the optimisation levels?

    If you want to experiment with different optimization levels, nobody is
    stopping you. Just don't complain if things stop working or start to
    behave erratically. It's a lot of work to fix all the bugs and the gains
    will be small. Setting unsupported optimization levels as the default is
    going to hurt, so don't to that.


    > My mistake, It seemed logical, as Spock would say. ;-) Well, it seemed
    > logical to me, but I'm a newbie, so what do I know, I'm trying to learn :-)


    Look at it this way: Compiler optimization *might* get you an extra few
    percent of performance in the code, and it takes a lot of effort to
    do it. Then it turns out most of that optimized code only runs a few
    percent of the time anyway.

    The most effective optimization is to use the right algorithms. Where
    compiler flags might shave off percents, a change of algorithms might
    cut the time in half or even much better for large enough inputs.

    People who know what the gains are don't waste their time. They use
    optimization flags where their small gains are still substantial, for
    example in numerical applications that run for a long time, and only
    after doing all the algorithm optimization they can.


    --
    j p d (at) d s b (dot) t u d e l f t (dot) n l .
    This message was originally posted on Usenet in plain text.
    Any other representation, additions, or changes do not have my
    consent and may be a violation of international copyright law.

  18. Re: Building With -03 Flags.

    On Mon, 15 Jan 2007 09:15:18 +0000 (UTC) in Michel Talon wrote:
    >
    > Anyways, the optimization flag has exactly *zero* effect on the kernel
    > performance, the best proof being that FreeBSD-4 compiled with -O
    > is far more performant than either FreeBSD-6 compiled with -O2 or
    > Linux kernel 2.6 with -O2 in performance intensive applications on
    > monoprocessors. Far more important is the quality of locking
    > implementation, quality of IO processing, etc.


    Compiling the kernel with '-Os' occasionally obtains marginally
    better performance. However, when I fiddled with such things,
    I found it to be more interesting at flushing out gcc problems.


    --
    Chris Dukes
    < elfick> willg: you can't use dell to beat people, it wouldn't stand up
    to the strain... much like attacking a tank with a wiffle bat

  19. Re: Building With -03 Flags.

    On Sun, 14 Jan 2007 19:40:22 -0500, Timmy wrote:
    : Since everything is building with -02 by default, can I kick the optimize
    : flags to -03 without makeing the system unstable? Will it work if I
    : use -03?

    Dude...just try it. It's not sacreligious and no one's going to
    arrest you if you attempt it at -O3 *even* if it doesn't work out. If
    it's broken as many believe and if you can fix it then please submit
    the patches.

    No matter what happens it'll help out the project and you'll learn
    more in the process.

  20. Re: Building With -03 Flags.

    On Jan 16, 7:30 pm, hgold...@mpcs.com (Howard Goldstein) wrote:
    > Dude...just try it. It's not sacreligious and no one's going to
    > arrest you if you attempt it at -O3 *even* if it doesn't work out. If
    > it's broken as many believe and if you can fix it then please submit
    > the patches.


    Unfortunately the symptom is very hard to diagnose.

    The difference between -O2 and -O3 causes some part
    of the code to be replaced (based on faulty assumptions),
    but until you exercise that part of the kernel or userland program,
    you won't see the effect. And most likely it'll silently
    corrupt some kernel data structure in subtle ways...

    Generally speaking, the *only way* to know if it's
    a -O3 vs -O2 bug, is if you keep 2 copies of kernel
    (or even 2 copies of world, if you use -O3 to buildworld)
    on the same machine. And you get bizarre error/crashes
    with O3 but okay with O2.

    That is very space/time consuming and a lot of effort indeed.

    - JT


+ Reply to Thread
Page 1 of 3 1 2 3 LastLast