Loading ...
Sorry, an error occurred while loading the content.

Re: Release 2.0: -O option

Expand Messages
  • Stephane Carrez
    Hi! ... Yes and this comes from the definition of various inline functions defined in the .h files. It is volunteered that these functions are declared both
    Message 1 of 3 , Oct 1, 2002
    • 0 Attachment
      Hi!

      ingo68hc11 wrote:

      > Hi!
      >
      > Not using the -Os option for optimization results in
      > many undefined references error messages during linking, e.g.
      >
      > ...
      > beepTask.o(.text+0x18): undefined reference to
      > `set_interrupt_handler_beeper'
      > ...
      >
      > I use the same commands for compiling and linking, except
      > that in one case I specify -Os (everything is fine), and in the other
      > case I leave out this option or do -O0 (gives error msg).
      >
      > BTW: I want to compile without optimization, because it kills special
      > code passages in a task of a multitasking OS where a countzer variable
      > is increased in a loop. Nothing is done with that variavle in the
      > task-subroutine, but I need it somewhere else.
      >
      > Any help is appreciated.
      >
      > Ingo.
      >



      Yes and this comes from the definition of various inline functions defined
      in the .h files. It is volunteered that these functions are declared
      both inline and extern.

      There should be no reason to avoid compiling with -O. If the compiler
      optimizes and removes a variable, it has reasons to do so. And there are
      ways to tell it it shouldn't.

      In general, declaring a variable as volatile will do the trick.

      If you have a busy wait loop and it is removed (which is legal if it
      does nothing), you can force the compiler to keep it by adding an
      empty __asm__ __volatile__ ("") instruction.

      Stephane

      -----------------------------------------------------------------------
      Home Office
      E-mail: stcarrez@... Stephane.Carrez@...
      WWW: http://stcarrez.nerim.net http://www.solsoft.com
      Free the Software! Visual Security Policy Management
    • ingo68hc11
      ... other ... special ... variable ... defined ... declared ... compiler ... there are ... Accepted, but: the variable (OSIdleCtr) that is removed is a global
      Message 2 of 3 , Oct 2, 2002
      • 0 Attachment
        --- In gnu-m68hc11@y..., Stephane Carrez <stcarrez@n...> wrote:
        > Hi!
        >
        > ingo68hc11 wrote:
        >
        > > Hi!
        > >
        > > Not using the -Os option for optimization results in
        > > many undefined references error messages during linking, e.g.
        > >
        > > ...
        > > beepTask.o(.text+0x18): undefined reference to
        > > `set_interrupt_handler_beeper'
        > > ...
        > >
        > > I use the same commands for compiling and linking, except
        > > that in one case I specify -Os (everything is fine), and in the
        other
        > > case I leave out this option or do -O0 (gives error msg).
        > >
        > > BTW: I want to compile without optimization, because it kills
        special
        > > code passages in a task of a multitasking OS where a countzer
        variable
        > > is increased in a loop. Nothing is done with that variavle in the
        > > task-subroutine, but I need it somewhere else.
        > >
        > > Any help is appreciated.
        > >
        > > Ingo.
        > >
        >
        >
        >
        > Yes and this comes from the definition of various inline functions
        defined
        > in the .h files. It is volunteered that these functions are
        declared
        > both inline and extern.
        >
        > There should be no reason to avoid compiling with -O. If the
        compiler
        > optimizes and removes a variable, it has reasons to do so. And
        there are
        > ways to tell it it shouldn't.

        Accepted, but:
        the variable (OSIdleCtr) that is removed is a global variable that is
        used somewhere else. In fact it is used to compute CPU usage: The
        variable is incremented in a loop in the lowest priority task. The
        1+lowest priority task computes CPU usage periodically (once a second)
        from this global value. Switches between tasks are performed by
        interrupts only, the assembler 'swi' insn, so no direct calls.
        'Volatile' helps, but for this I have to change the OS-code...

        Ingo.


        >
        > In general, declaring a variable as volatile will do the trick.
        >
        > If you have a busy wait loop and it is removed (which is legal if it
        > does nothing), you can force the compiler to keep it by adding an
        > empty __asm__ __volatile__ ("") instruction.
        >
        > Stephane
        >
        > --------------------------------------------------------------------
        ---
        > Home Office
        > E-mail: stcarrez@n... Stephane.Carrez@s...
        > WWW: http://stcarrez.nerim.net http://www.solsoft.com
        > Free the Software! Visual Security Policy
        Management
      Your message has been successfully submitted and would be delivered to recipients shortly.