This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: PATCH: flag_external and DECL_EXTERNAL documentation



  Hi Lars,

[put the main list back in the cc because someone there might have an idea]

>> there's nothing to prevent a function in the current unit from
>> having an extern declaration, in fact that's a very common situation
>> when your code is structured so that every .c file has a
>> corresponding .h that declares all its extern functions, and the .c
>> file includes its own .h.  So you can't assume that a function
>> actually is external to the current compilation unit just because
>> it's declared that way; nor can you assume it isn't.
>
>Argh, that's right of course.  But since GCC operates in function-at-a-
>time mode, there's no way to know wheter a function will be defined later
>in the current unit?  Unless there's a way to switch to unit-at-a-time
>mode?

  No, you cannot know that for global functions.  You can *assume* it for
static functions, because if they don't get defined later in the module,
the whole module won't compile.

  There is no unit-at-a-time mode in Gcc.  I could imagine building one
on top of the tree-based inliner, by deferring *all* the functions for 
possible inlining/output suppression.  But that would be a nasty hack. And
we still don't have a way to spot virtual functions that get compiled but
won't be emitted until the same module as the vtable.

  Otherwise, I can't see any solution to the general problem of knowing 
whether a forward reference to a global function will match a function
later in the same compilation unit.  For your case, where the assembler
absolutely *needs* to know, you might have to use some kind of thunk style
trick.

      DaveK

-- 
we are not seats or eyeballs or end users or consumers.
we are human beings - and our reach exceeds your grasp.
                    deal with it.                      - cluetrain.org 


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]