Changing the libc calling convention

I have been searching for a way to change the default calling convention
used for library calls in Clang/LLVM. Although I can see a way to change
the calling convention for compiler-rt functions, there does not appear
to be a mechanism to achieve this for libc library calls.

I have tried a couple of solution:

I tried to change the calling convention in the declarations in the
library. For some library functions, these declarations appear to
conflict with the implicit declaration known to Clang, and I couldn't
find an obvious means for a target to override this. Another problem
with this approach was that the user could provide their own
declarations without a calling convention.

I also tried changing the calling convention in LLVM, by adding a hook
to TargetLibraryInfo to let the target override it. This worked for
trivial cases, but not for function pointers and a couple of other edge
cases.

I can probably make either solution work for my use case, but I am
curious if there is an obvious solution I am missing.

Best regards,
Edward Jones

Can you clarify what you mean by ‘libc’ in this context? Do you mean solely functions that are part of the C standard (which may be in libc, libm, or some other support library), or functions that are actually in a specific library?

David

Apologies, I mean all functions which are part of the C standard, not
simply those which appear in libc.

Best regards,
Edward Jones