Open singalsu opened 5 years ago
This is tricky, need a cmake expert here.
grep -rl "-O3" . | xargs sed -i 's/-O3/-O/g'
find . -name "CMakeLists.txt" | xargs grep -rl "-O3" | xargs sed -i 's/-O3/-O/g'
Note : Editor is NOT accepting/displaying the escape character \ please add \ before-O3 and -O
@juimonen can you help here, cmake support conditional logic so you can pass in -DEBUG or similar on the cmd line to select different CFLAGS.
This happens simply because we have -O3
hardcoded in various CMakeLists.txt
files, for the testbench this was done in commit 56228b0221dc. The first step is this, try it and see what happens:
--- a/tools/testbench/CMakeLists.txt
+++ b/tools/testbench/CMakeLists.txt
@@ -30,7 +30,7 @@ target_include_directories(testbench PRIVATE
)
endif()
-target_compile_options(testbench PRIVATE -g -O3 -Wall -Werror -Wl,-EL -Wmissing-prototypes
+target_compile_options(testbench PRIVATE -g -Wall -Werror -Wl,-EL -Wmissing-prototypes
-Wimplicit-fallthrough -DCONFIG_LIBRARY -imacros${config_h})
target_link_libraries(testbench PRIVATE -ldl -lm)
@ShriramShastry : https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax
To see which flags are used without being flooded by the build logs:
$ touch tools/testbench/testbench.c
make -C tools/testbench/build_testbench/ testbench.o VERBOSE=1
PS: debugging -O code is madness. Don't do it. Ever.
Also try this:
$ grep OPT tools/testbench/build_testbench/sof_ep/build/generated/.config
CONFIG_OPTIMIZE_FOR_PERFORMANCE=y
# CONFIG_OPTIMIZE_FOR_SIZE is not set
# CONFIG_OPTIMIZE_FOR_DEBUG is not set
# CONFIG_OPTIMIZE_FOR_NONE is not set
$ make -C tools/testbench/build_testbench/sof_ep/build/ menuconfig
@marc-hb are you able to take care of a global -g
and -pg
setting for building all code. The latter is for building on host. I'm assuming this would be done in Zephyr Kconfig ?
@marc-hb are you able to take care of a global
-g
and-pg
setting for building all code. The latter is for building on host. I'm assuming this would be done in Zephyr Kconfig ?
Sorry, reason I ask as its not propagated through all tools/code and I've no idea if we inherit from Zephyr.
@lgirdwood this feels like significant CMake surgery and I have no idea how long it would take, sorry. My untested, testbench-specific advice above was just off the top of my head and after looking at it for 5 minutes.
@marc-hb ok, how about if we make it consistent when we invoke cmake or make e.g. make DEBUG=1
just something quick and easy for the tools developers.
Is your feature request related to a problem? Please describe. The cmake build of testbench does not generate an executable without optimization. When run in debugger (gdb + graphical front end) the optimized executable has variables optimized out and code stepping is not linear. The hand editing of makefiles manually to remove code optimization is cumbersome due to complexity of cmake generates makefiles.
Describe the solution you'd like When running command "cmake -DCMAKE_BUILD_TYPE=Debug .." there should be no -O3 optimizations left anywhere in makefiles (testbench, pipeline & components code). Just "-O" might be sufficient but to be safe just leave "-g".
Describe alternatives you've considered No alternates besides hand editing of makefiles.
Additional context N/A