On 6 August 2018 at 17:37, Laszlo Ersek <ler...@redhat.com> wrote:
> On 08/06/18 16:54, Gao, Liming wrote:
>> Laszlo: We manually search the unused functions in the module source
>> files, and also verify the build to make sure the unused functions are
>> real dead code.
>
> Works for me, but then the commit message should state exactly this.
> Such as:
>
>     """
>     Remove functions that have external linkage but are never called.
>     (We have manually verified that no function removed in this patch is
>     ever called.)
>     """
>
> Because:
>
> * "Dead code" also means such code that is conditionally reachable (for
>   example, there is a conditional call to the function); however deeper
>   analysis reveals that the condition can never evaluate to TRUE.
>
>   A patch that eliminates code for this case must stand on its own,
>   because it needs non-mechanic review. From the commit message it
>   wasn't clear whether such changes were in scope, and it was difficult
>   to tell from the code (due to the size of the patch).
>
> * "External linkage" is relevant because it highlights that the current
>   situation is at least in part the result of tooling limitations.
>
>   A large number of functions in MdeModulePkg should be STATIC (= be
>   given internal linkage), but they are kept with external linkage
>   because some VS debugging tools cannot cope with STATIC functions (to
>   my understanding).
>

Could we *please* double check if this is still the case? Is this like
the ELILO thing, where nobody remembers what version exactly needed it
and we keep cargo culting (and duplicating) the fix ad inifitum?

IMO, STATIC is a fundamental part of careful structuring of your code,
and if the tooling cannot cope, it should be fixed.

>   In turn, because utility functions are never made STATIC, gcc cannot
>   emit warnings when some of those functions are never actually called
>   (if they were STATIC, gcc would abort the build with to warnings).
>   Obviously this doesn't apply to all utility functions (some may have
>   originally been called from multiple source files).
>
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to