[2/3] x86/build: use -std=gnu89 for proper extern inline semantics

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[ CC me I'am not subscribed to LKML and linux-kbuild ]
[ Unsure if this the complete CC list of the original posting [0] ]

Hi,

I am discovering clang's compiler flags as HPA writes in [0]...

"-fgnu-inlines would be a better option.

We could also simply #define inline inline __attribute__((gnu_inline))"

[1] says on clang-7 compiler-flags...

Generate output compatible with the standard GNU Objective-C runtime

-fgnu89-inline, -fno-gnu89-inline

...and...

Place each function in its own section (ELF Only)

-fgnu-inline-asm, -fno-gnu-inline-asm

Should that be '-fgnu89-inline'?
You happen to know what '-fgnu-inline-asm' does and it is an option?

This what Linux v4.17 says about inline defines...

[ include/linux/compiler-gcc.h ]
...
/*
 * Force always-inline if the user requests it so via the .config,
 * or if gcc is too old.
 * GCC does not warn about unused static inline functions for
 * -Wunused-function.  This turns out to avoid the need for complex #ifdef
 * directives.  Suppress the warning in clang as well by using "unused"
 * function attribute, which is redundant but not harmful for gcc.
 */
#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) ||                \
    !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
#define inline inline           __attribute__((always_inline,unused)) notrace
#define __inline__ __inline__   __attribute__((always_inline,unused)) notrace
#define __inline __inline       __attribute__((always_inline,unused)) notrace
#else
/* A lot of inline functions can cause havoc with function tracing */
#define inline inline           __attribute__((unused)) notrace
#define __inline__ __inline__   __attribute__((unused)) notrace
#define __inline __inline       __attribute__((unused)) notrace
#endif
...

[ include/linux/compiler_types.h ]
...
/*
 * Allow us to avoid 'defined but not used' warnings on functions and data,
 * as well as force them to be emitted to the assembly file.
 *
 * As of gcc 3.4, static functions that are not marked with attribute((used))
 * may be elided from the assembly file.  As of gcc 3.4, static data not so
 * marked will not be elided, but this may change in a future gcc version.
 *
 * NOTE: Because distributions shipped with a backported unit-at-a-time
 * compiler in gcc 3.3, we must define __used to be __attribute__((used))
 * for gcc >=3.3 instead of 3.4.
 *
 * In prior versions of gcc, such functions and data would be emitted, but
 * would be warned about except with attribute((unused)).
 *
 * Mark functions that are referenced only in inline assembly as __used so
 * the code is emitted even though it appears to be unreferenced.
 */
#ifndef __used
# define __used                 /* unimplemented */
#endif

#ifndef __maybe_unused
# define __maybe_unused         /* unimplemented */
#endif

#ifndef __always_unused
# define __always_unused        /* unimplemented */
#endif

#ifndef noinline
#define noinline
#endif

/*
 * Rather then using noinline to prevent stack consumption, use
 * noinline_for_stack instead.  For documentation reasons.
 */
#define noinline_for_stack noinline

#ifndef __always_inline
#define __always_inline inline
#endif
...

Regards,
- Sedat -


[0] https://patchwork.kernel.org/patch/10444075/
[1] https://clang.llvm.org/docs/ClangCommandLineReference.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux