Open yamt opened 2 months ago
Hi @yamt
How do you compile clang? I do not see this problem with our latest release made for this tag.
lp_uart_print (feat/ulp_debug*) » clang -c -Os -g /tmp/a.c
lp_uart_print (feat/ulp_debug*) » llvm-dwarfdump a.o
a.o: file format elf32-littleriscv
.debug_info contents:
0x00000000: Compile Unit: length = 0x0000004d, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x04 (next unit at 0x00000051)
0x0000000b: DW_TAG_compile_unit
DW_AT_producer ("Espressif clang version 17.0.1 (https://github.com/espressif/llvm-project.git esp-17.0.1_20240419)")
DW_AT_language (DW_LANG_C11)
DW_AT_name ("/tmp/a.c")
DW_AT_stmt_list (0x00000000)
DW_AT_comp_dir ("/home/alexey/projects/esp/esp-idf/examples/system/ulp/lp_core/lp_uart/lp_uart_print")
DW_AT_low_pc (0x00000000)
DW_AT_high_pc (0x00000002)
0x00000026: DW_TAG_subprogram
DW_AT_low_pc (0x00000000)
DW_AT_high_pc (0x00000002)
DW_AT_frame_base (DW_OP_reg2 X2)
DW_AT_GNU_all_call_sites (true)
DW_AT_name ("f")
DW_AT_decl_file ("/tmp/a.c")
DW_AT_decl_line (1)
DW_AT_prototyped (true)
DW_AT_type (0x00000049 "int")
DW_AT_external (true)
0x0000003b: DW_TAG_formal_parameter
DW_AT_location (DW_OP_reg10 X10)
DW_AT_name ("x")
DW_AT_decl_file ("/tmp/a.c")
DW_AT_decl_line (1)
DW_AT_type (0x00000049 "int")
0x00000048: NULL
0x00000049: DW_TAG_base_type
DW_AT_name ("int")
DW_AT_encoding (DW_ATE_signed)
DW_AT_byte_size (0x04)
0x00000050: NULL
Hi @yamt
How do you compile clang? I do not see this problem with our latest release made for this tag.
my configuration is:
cmake \
-G Ninja \
-S llvm -B ${BUILD_DIR} \
-DCMAKE_BUILD_TYPE=Debug \
-DLLVM_ENABLE_PROJECTS="lld;clang;lldb" \
-DLLVM_TARGETS_TO_BUILD="WebAssembly;X86" \
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=Xtensa \
-DLLVM_DEFAULT_TARGET_TRIPLE="xtensa-esp32-elf" \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_TESTS=ON \
-DLLVM_INCLUDE_TOOLS=ON \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_ZLIB=OFF \
-DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_ENABLE_LIBXML2=OFF \
-DLLVM_ENABLE_LIBEDIT=OFF \
-DLLVM_HAVE_LIBXAR=OFF \
-DLLVM_INSTALL_BINUTILS_SYMLINKS=ON \
-DLLDB_INCLUDE_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=${HOME}/llvm
my colleague independently had a similar symptom (broken dwarf) with https://github.com/bytecodealliance/wasm-micro-runtime/tree/main/wamr-compiler. i don't know how she built it.
i was able to reproduce the symptom with the release assets. https://github.com/espressif/llvm-project/releases/download/esp-17.0.1_20240419/clang-esp-17.0.1_20240419-x86_64-apple-darwin.tar.xz
clang --target=xtensa-esp-unknown-elf -c -Os -g a.c
well, actully it turned out to be a problem in llvm-dwarfdump. my fix: https://github.com/llvm/llvm-project/pull/96311
@yamt Thank you very much for the findings. We will pick it up. So let's keep this ticket open until that moment .
the following is with
esp-17.0.1_20240419
built locally. at least, DW_AT_producer, DW_AT_name, DW_AT_decl_file, DW_AT_comp_dir seem broken.