Menu

#68 Clang fails to build fuser because of inline decision

Next Release
open
None
1
2015-06-25
2015-06-24
Han Shen
No

Hi, we are trying to build ChromeOs using clang while this package fails to build.

The reason, after investigation, is that Clang, under '-O2' choose not to inline "prefetch" that has below declaration -

// fuser.c
extern inline void attribute((used,__gnu_inline__,always_inline,__artificial__)) prefetch(const void *restrict x)

The declaration "extern inline and attribute __gnu_inline__" forces compiler to treat this "prefetch" implementation as inline-only definition. In other words, if the call to prefetch is not inlined (such decision is made by compiler), then there must be another prefetch implementation somewhere else in other compilation unit with no "inline" keyword.

Current situation is GCC honor "always_inline" attribute, thus no problem, whereas clang does not, instead it choose not to inline it, so an "undefined" reference to prefetch is reported.

Is there another external "prefetch" implemented in this package so the "__gnu_inline__" is meant to provide an alternative "prefetch" implementation? If that's not the case, may I suggest just remove "__gnu_inline__" attribute, so the declaration provides both inline and external definition for the function?

Discussion

  • Craig Small

    Craig Small - 2015-06-25
    • assigned_to: Dr. Werner Fink
     
  • Craig Small

    Craig Small - 2015-06-25

    This code (src/lists.h) was written by Werner so I'll see what he thinks.

     
  • Dr. Werner Fink

    Dr. Werner Fink - 2015-06-25

    Maybe a

    #ifdef GNUC_GNU_INLINE
    extern inline void attribute((used,gnu_inline,always_inline,artificial))
    #else
    extern inline void attribute((used,always_inline,artificial))
    #endif
    prefetch(const void *restrict x)

    might help here.

     
  • Dr. Werner Fink

    Dr. Werner Fink - 2015-06-25

    With the attached patch at least gcc compiles, no clang here.

     
  • Han Shen

    Han Shen - 2015-06-25

    Hi Dr. Werner Fink, I tried the patch for clang, it works for us, thanks!

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.