Issue 140996
Summary RISC-V Architecture Mismatch Error During BOLT Instrumentation: "linking object with arch x86_64 into context with arch riscv64"
Labels BOLT
Assignees
Reporter JunGaos
    When attempting to instrument a RISC-V binary using LLVM-BOLT, the process fails with an architecture mismatch error during the linking phase. BOLT correctly identifies the target as RISC-V but fails when trying to link what appears to be an x86_64 object file.

Environment:
LLVM-BOLT Version: 569b6f6dade6a1a1b758d982bcd9d91abafb787f
Target Architecture: riscv64
Host Architecture: x86_64
Toolchain: riscv-gnu-toolchain with clang
OS: Ubuntu (ThinkCentre)

File: loop_test.c
```c
#include <stdio.h>
int main() {
 int sum = 0;
    
    for (int i = 0; i < 100; i++) {
        sum += i;
    }
    
    printf("Sum: %d\n", sum);
    return 0;
}
```


Steps to Reproduce:
Compile a simple C program for RISC-V:
`/home/simon/diskWD/riscv-gnu-toolchain/install/bin/clang loop_test.c -Wl,--emit-relocs -o loop_test_rv_llvm`
Attempt to instrument the binary with BOLT:
`/home/simon/diskWD/riscv-gnu-toolchain/install/bin/llvm-bolt loop_test_rv_llvm -instrument -o instrumented_loop_test_rv_llvm -instrumentation-file=without_pgo_loop_test_rv_llvm.fdata`
BOLT fails with the following error:
```
BOLT-INFO: shared object or position-independent executable detected
BOLT-INFO: Target architecture: riscv64
BOLT-INFO: BOLT version: 569b6f6dade6a1a1b758d982bcd9d91abafb787f
BOLT-INFO: first alloc address is 0x0
BOLT-INFO: creating new program header table at address 0x200000, offset 0x200000
BOLT-INFO: enabling relocation mode
BOLT-INFO: forcing -jump-tables=move for instrumentation
BOLT-INFO: 0 out of 8 functions in the binary (0.0%) have non-empty execution profile
BOLT-INSTRUMENTER: Number of indirect call site descriptors: 1
BOLT-INSTRUMENTER: Number of indirect call target descriptors: 5
BOLT-INSTRUMENTER: Number of function descriptors: 5
BOLT-INSTRUMENTER: Number of branch counters: 2
BOLT-INSTRUMENTER: Number of ST leaf node counters: 8
BOLT-INSTRUMENTER: Number of direct call counters: 0
BOLT-INSTRUMENTER: Total number of counters: 10
BOLT-INSTRUMENTER: Total size of counters: 80 bytes (static alloc memory)
BOLT-INSTRUMENTER: Total size of string table emitted: 60 bytes in file
BOLT-INSTRUMENTER: Total size of descriptors: 592 bytes in file
BOLT-INSTRUMENTER: Profile will be saved to file without_pgo_loop_test_rv_llvm.fdata
BOLT-INFO: UCE removed 1 blocks and 40 bytes of code
BOLT-INFO: padding code to 0x600000 to accommodate hot text
BOLT-ERROR: linking object with arch x86_64 into context with arch riscv64
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to