Hi Yash,

 

First, if we're going to take this approach, you should revert my work-around as part of this commit:

commit ca10312c4c7e88d67f4b487ae9afcbfdf92898d6
Author:     Randy MacLeod <Randy.MacLeod@...>
Date: Wed Mar 1 19:24:27 2023

    librelp: make inline errors be warnings in debug build
        ...

Will send a v2 if needed.

BUT...

The problem isn't so much that the code doesn't get in-lined when doing a debug build but
that it fails to compile.  I think this is a compiler regressions since
I was not able to reproduce the error when compiling natively using Ubuntu-22.04 (gcc-11.3) but
was able to reproduce it using Fedora-37, gcc --version : gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4)

 

Does the change you made actually build with the two compiler versions above?

I tested the changes in LINCD sources which have GCC 12.2. I didn’t check the above mentioned version.


Is there documentation that states that

static inline void

is not as portable as:

__attribute__((always_inline)) static inline void

 

I suspect there is not but I'm not a compiler geek!

As you mentioned in https://github.com/rsyslog/librelp/issues/256#issue-1605905115, it happens only when complied without any optimization and as per https://gcc.gnu.org/onlinedocs/gcc/Inline.html it’s mentioned that:
 
GCC does not inline any functions when not optimizing unless you specify the ‘always_inline’ attribute for the function, like this: 
/* Prototype.  */ inline void foo (const char) __attribute__((always_inline)); 
Please let me know if we are on the same page.

../Randy

Regards,

Yash