tools/perf: Fix compiling with libelf on rv32
Subsystems (2)
PATCH 1/1 tools/perf: Fix compiling with libelf on rv32
From: Chen Pei <[email protected]>
When cross-compiling perf with libelf, the following error occurred:
In file included from tests/genelf.c:14:
tests/../util/genelf.h:50:2: error: #error "unsupported architecture"
50 | #error "unsupported architecture"
| ^~~~~
tests/../util/genelf.h:59:5: warning: "GEN_ELF_CLASS" is not defined, evaluates to 0 [-Wundef] 59 | #if GEN_ELF_CLASS == ELFCLASS64
Fix this by adding GEN-ELF-ARCH and GEN-ELF-CLASS definitions for rv32.
--- tools/perf/util/genelf.h | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/genelf.h +3 -0
@@ -43,6 +43,9 @@ int jit_add_debug_info(Elf *e, uint64_t code_addr, void *debug, int nr_debug_ent#elif defined(__riscv) && __riscv_xlen ==64 #define GEN_ELF_ARCH EM_RISCV#define GEN_ELF_CLASS ELFCLASS64 +#elif defined(__riscv) && __riscv_xlen ==32 +#define GEN_ELF_ARCH EM_RISCV +#define GEN_ELF_CLASS ELFCLASS32#elif defined(__loongarch__)#define GEN_ELF_ARCH EM_LOONGARCH#define GEN_ELF_CLASS ELFCLASS64
Signature · 1 line
2.25.1
Quoted 12 lines · On Mon, Apr 15, 2024 at 2:57 AM <[email protected]> wrote:
From: Chen Pei <[email protected]>
When cross-compiling perf with libelf, the following error occurred:
In file included from
tests/genelf.c:14:
tests/../util/genelf.h:50:2: error: #error "unsupported architecture"
50 | #error "unsupported architecture"
| ^~~~~
tests/../util/genelf.h:59:5: warning: "GEN_ELF_CLASS" is not defined, evaluates to 0 [-Wundef] 59 | #ifGEN_ELF_CLASS== ELFCLASS64
Quoted 3 lines
Fix this by adding GEN-ELF-ARCH and GEN-ELF-CLASS definitions for rv32.
Signed-off-by Chen Pei <[email protected]>
Thanks,
Ian
Quoted 22 lines
--- tools/perf/util/genelf.h | 3 +++ 1 file changed, 3 insertions(+)tools/perf/util/genelf.h +3
-1@@ -43,6 +43,9 @@ int jit_add_debug_info(Elf *e, uint64_t code_addr, void *debug, int nr_debug_ent#elif defined(__riscv) && __riscv_xlen ==64 #define GEN_ELF_ARCH EM_RISCV#define GEN_ELF_CLASS ELFCLASS64 +#elif defined(__riscv) && __riscv_xlen ==32 +#define GEN_ELF_ARCH EM_RISCV +#define GEN_ELF_CLASS ELFCLASS32#elif defined(__loongarch__)#define GEN_ELF_ARCH EM_LOONGARCH#define GEN_ELF_CLASS ELFCLASS64 --2.25.1
Quoted 13 lines · Ian Rogers
Quoted 12 lines · On Mon, Apr 15, 2024 at 2:57 AM <[email protected]> wrote:
From: Chen Pei <[email protected]>
When cross-compiling perf with libelf, the following error occurred:
In file included from
tests/genelf.c:14:
tests/../util/genelf.h:50:2: error: #error "unsupported architecture"
50 | #error "unsupported architecture"
| ^~~~~
tests/../util/genelf.h:59:5: warning: "GEN_ELF_CLASS" is not defined, evaluates to 0 [-Wundef] 59 | #ifGEN_ELF_CLASS== ELFCLASS64
Quoted 5 lines
Quoted 3 lines
Fix this by adding GEN-ELF-ARCH and GEN-ELF-CLASS definitions for rv32.
Signed-off-by Chen Pei <[email protected]>Reviewed-by Ian Rogers <[email protected]>
Thanks, applied to perf-tools-next,
- Arnaldo