> In addition to GCC not liking x86_emulate(), it turns out that Clang is still
> rather more a work in progress than a usable feature, causing failures in the
> FreeBSD builds:
>
>   https://cirrus-ci.com/task/5934059060199424
>
> Exclude CONFIG_CONDITION_COVERAGE from Ranconfig until it gets a bit more
> stable.

Hi Andrew,

Thanks for catching this. I can confirm it is reliably reproducible on
a FreeBSD host with LLVM toolchain, as long as CONFIG_COVERAGE is on
(regardless of CONFIG_CONDITION_COVERAGE). So this patch probably won't
avoid the failure in the future.

See also the report by Roger which predates the introduction of LLVM
condition coverage:

  https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=290381

The cause looks multifold:

1. Direct cause is null dereferences in LLVM linker

  
https://github.com/llvm/llvm-project/blob/llvmorg-23-init/lld/ELF/OutputSections.cpp#L631
  
https://github.com/llvm/llvm-project/blob/llvmorg-23-init/lld/ELF/InputSection.cpp#L419

2. The use of objcopy from elftoolchain on FreeBSD

  $ objcopy --version
  objcopy (elftoolchain r3769)

3. gnu_inline attribute of xen/include/xen/sort.h

On FreeBSD 14.2, the following sequence using small program reproduces the
crash:

```
cat > 1.c <<'EOF'
#include "h.h"
int fun1(int a, int b) { return add(a, b); }
EOF

cat > 2.c <<'EOF'
#include "h.h"
int func2(int a, int b) { return add(a+1, b+1); }
EOF

cat > h.h <<'EOF'
extern inline __attribute__((__gnu_inline__))
int add(int a, int b) { return a + b; }
EOF

# OBJCOPY=/usr/local/bin/objcopy # binutils -- fine
# OBJCOPY=/usr/bin/llvm-objcopy  # LLVM -- fine
# OBJCOPY=cp                     # skip -- fine
OBJCOPY=/usr/bin/objcopy       # elftoolchain -- X

CFLAGS='-O1 -fprofile-instr-generate -fcoverage-mapping'

clang $CFLAGS -c 1.c -o 1.o.tmp
clang $CFLAGS -c 2.c -o 2.o.tmp
$OBJCOPY 1.o.tmp 1.o
$OBJCOPY 2.o.tmp 2.o

ld.lld -o output.o -r 1.o 2.o
```

I will consider filing a report/patch to LLVM but I am frankly not sure
whether it will be accommodated given (1) this unusual combination of
toolchain to trigger the bug (2) elftoolchain is retiring in newer FreeBSD.

Thanks,
Wentao

>
> Signed-off-by: Andrew Cooper <[email protected]>

[snip]

Reply via email to