I\'m trying to compile a specific function with no optimization using clang
, in order to prevent certain security-related calls to memset()
from be
As advocated by @dulacc in his comment, __attribute__ ((optnone))
works on clang 9.0.0 on Mac's High Sierra.
As clang documentation says,
Clang supports GCC’s gnu attribute namespace. All GCC attributes which are accepted with the
__attribute__((foo))
syntax are also accepted as[[gnu::foo]]
. This only extends to attributes which are specified by GCC (see the list of GCC function attributes, GCC variable attributes, and GCC type attributes). As with the GCC implementation, these attributes must appertain to the declarator-id in a declaration, which means they must go either at the start of the declaration or immediately after the name being declared.
Try
void* always_memset(void *b, int c, size_t len) [[gnu::optimize(0)]]
or
void* always_memset(void *b, int c, size_t len) __attribute__ ((optimize("0")));