The compiler produces debug information that is incompatible with Keil-MDK
Closed, ResolvedPublic

Description

In TF-M, we using -g option, and the default level is DWARF 4 in latest Arm compiler. And the Keil-MDK don't support DWARF 4 debug information. It makes the Keil can't debug the tfm binary which compiled with cmake.

Could you please change the -g option to -gdwarf-2 in cmake/Compiler/ARMClang.cmake? or we need to add some special documents for build and debug tf-m on Keil/DS-5.

qixiang created this task.Jul 1 2019, 3:38 AM

Hi Qixiang,
Can you help to :

  1. provide the version customer are using
  2. provide the solution you have created?

We can add a feature to enable dwarf-2; if you can contribute then that would be great, or we can create a patch based on your solution.

Thanks.

KenLSoft claimed this task.Jul 3 2019, 5:45 AM
KenLSoft added a subscriber: gyuri-szing.
qixiang added a comment.EditedJul 3 2019, 6:47 AM

Product: DS-5 Ultimate Edition 5.29.1
Component: ARM Compiler 6.10.1
Tool: armclang [5d143200]

Solution:

~/workspace/arm/tf-m/tfm-github$ git diff
diff --git a/cmake/Compiler/ARMClang.cmake b/cmake/Compiler/ARMClang.cmake
index a5ed2f3..57b704d 100644
--- a/cmake/Compiler/ARMClang.cmake
+++ b/cmake/Compiler/ARMClang.cmake
@@ -28,10 +28,10 @@ macro(__compiler_armclang lang)
   if(NOT CMAKE_${lang}_FLAGS_SET)
     set(CMAKE_${lang}_FLAGS_SET TRUE)
     string(APPEND CMAKE_${lang}_FLAGS_INIT " ")
-    string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -O0")
+    string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -gdwarf-2 -O0")
     string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Oz -DNDEBUG")
     string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG")
-    string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O3 -g -DNDEBUG")
+    string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O3 -gdwarf-2 -DNDEBUG")

     set(CMAKE_${lang}_OUTPUT_EXTENSION ".o")
     set(CMAKE_${lang}_OUTPUT_EXTENSION_REPLACE 1)

Thanks, that is helpful. Will let you know after the feature is created.

Hi Qixiang, could you check the patch on your side?

The Patch link is: https://review.trustedfirmware.org/#/c/trusted-firmware-m/+/1532/

You can decide which dwarf version to use when building by "-DBUILD_DWARF_VERSION=<version number>"

@qixiang this patch had been merged into the master branch. Can you help to update the task status?

KenLSoft closed this task as Resolved.Jul 29 2019, 2:52 AM

Resolve the changes since no response. We can re-open it if there are still concerns.