clang does not like nested funcs. use a define instead. https://bugs.gentoo.org/451986 --- a/libelf/elf_begin.c +++ b/libelf/elf_begin.c @@ -1011,18 +1011,17 @@ elf_begin (fildes, cmd, ref) return NULL; } - Elf *lock_dup_elf () - { - /* We need wrlock to dup an archive. */ - if (ref->kind == ELF_K_AR) - { - rwlock_unlock (ref->lock); - rwlock_wrlock (ref->lock); - } - - /* Duplicate the descriptor. */ - return dup_elf (fildes, cmd, ref); - } +#define lock_dup_elf() \ + ({ \ + /* We need wrlock to dup an archive. */ \ + if (ref->kind == ELF_K_AR) \ + { \ + rwlock_unlock (ref->lock); \ + rwlock_wrlock (ref->lock); \ + } \ + /* Duplicate the descriptor. */ \ + dup_elf (fildes, cmd, ref); \ + }) switch (cmd) {