Skip to contentSkip to conversation

KernelShark build fixes for v1.0

PATCH Superseded Yordan Karadzhov 2 participants 4 messages Jun 11, 2019 – Jun 12, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover KernelShark build fixes for v1.0

Two patches addressing the problem of having the paths to the build directory embedded in the final binaries. The problem was reported by Troy Engel.

Yordan Karadzhov (2):
kernel-shark: Avoid TRACECMD_BIN_DIR being set to the build path
kernel-shark: Avoid debug build when CMAKE_BUILD_TYPE=Release

 kernel-shark/CMakeLists.txt           | 25 ++++++++++++++++---------
 kernel-shark/README                   |  4 ++--
 kernel-shark/build/FindTraceCmd.cmake | 14 +++++++++-----
 kernel-shark/build/deff.h.cmake       |  2 +-
 kernel-shark/src/KsCaptureDialog.cpp  | 13 ++++++++-----
 5 files changed, 36 insertions(+), 22 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/2 kernel-shark: Avoid TRACECMD_BIN_DIR being set to the build path

The full path to the build directory (which is random for every user) is embedded in the final binary. This is a no-no for some Linux distros which are requiring that the finished binaries should not have such paths embedded in them.

---
 kernel-shark/build/FindTraceCmd.cmake | 14 +++++++++-----
 kernel-shark/build/deff.h.cmake       |  2 +-
 kernel-shark/src/KsCaptureDialog.cpp  | 13 ++++++++-----
 3 files changed, 18 insertions(+), 11 deletions(-)
kernel-shark/build/FindTraceCmd.cmake +9 -5
index 8c51f11..3d11347 100644
@@ -12,10 +12,14 @@
 # MESSAGE(" Looking for trace-cmd ...")
 
 # First search in the user provided paths.
-find_path(TRACECMD_BIN_DIR      NAMES  trace-cmd
-                                PATHS  $ENV{TRACE_CMD}/tracecmd/
-                                       ${CMAKE_SOURCE_DIR}/../tracecmd/
-                                NO_DEFAULT_PATH)
+if (NOT CMAKE_BUILD_TYPE MATCHES Release)
+
+  find_program(TRACECMD_EXECUTABLE   NAMES  trace-cmd
+                                     PATHS  $ENV{TRACE_CMD}/tracecmd/
+                                            ${CMAKE_SOURCE_DIR}/../tracecmd/
+                                     NO_DEFAULT_PATH)
+
+endif (NOT CMAKE_BUILD_TYPE MATCHES Release)
 
 find_path(TRACECMD_INCLUDE_DIR  NAMES  trace-cmd/trace-cmd.h
                                 PATHS  $ENV{TRACE_CMD}/include/
@@ -34,7 +38,7 @@ find_library(TRACEEVENT_LIBRARY NAMES  traceevent/libtraceevent.a
 
 # If not found, search in the default system paths. Note that if the previous
 # search was successful "find_path" will do nothing this time.
-find_path(TRACECMD_BIN_DIR      NAMES  trace-cmd)
+find_program(TRACECMD_EXECUTABLE   NAMES  trace-cmd)
 find_path(TRACECMD_INCLUDE_DIR  NAMES  trace-cmd/trace-cmd.h)
 find_library(TRACECMD_LIBRARY   NAMES  trace-cmd/libtracecmd.so)
 find_library(TRACEEVENT_LIBRARY NAMES  traceevent/libtraceevent.so)
kernel-shark/build/deff.h.cmake +1 -1
index efee2a1..79726ff 100644
@@ -18,7 +18,7 @@
 #cmakedefine KS_PLUGIN_INSTALL_PREFIX "@KS_PLUGIN_INSTALL_PREFIX@"
 
 /** Location of the trace-cmd executable. */
-#cmakedefine TRACECMD_BIN_DIR "@TRACECMD_BIN_DIR@"
+#cmakedefine TRACECMD_EXECUTABLE "@TRACECMD_EXECUTABLE@"
 
 /** "pkexec" executable. */
 #cmakedefine DO_AS_ROOT "@DO_AS_ROOT@"
kernel-shark/src/KsCaptureDialog.cpp +8 -5
index b107595..96ab3e2 100644
@@ -489,12 +489,15 @@ KsCaptureDialog::KsCaptureDialog(QWidget *parent)
 	connect(&_captureCtrl._closeButton,	&QPushButton::pressed,
 		this,				&KsCaptureDialog::close);
 
-	if (KsUtils::isInstalled())
-		captureExe = QString(_INSTALL_PREFIX) + QString("/bin");
-	else
-		captureExe = TRACECMD_BIN_DIR;
+	captureExe = QString(_INSTALL_PREFIX) + QString("/bin/trace-cmd");
+
+#ifdef TRACECMD_EXECUTABLE
+
+	if (!KsUtils::isInstalled())
+		captureExe = TRACECMD_EXECUTABLE;
+
+#endif
 
-	captureExe += "/trace-cmd";
 	_captureProc.setProgram(captureExe);
 
 	_captureMon.connectMe(&_captureProc, &_captureCtrl);
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/2 kernel-shark: Avoid debug build when CMAKE_BUILD_TYPE=Release

In reply to Yordan Karadzhov

The debug flags by design embed the build paths, but the distro package binaries should not have such paths embedded in them.

---
 kernel-shark/CMakeLists.txt | 25 ++++++++++++++++---------
 kernel-shark/README         |  4 ++--
 2 files changed, 18 insertions(+), 11 deletions(-)
kernel-shark/CMakeLists.txt +16 -9
index d45be20..fe398bb 100644
@@ -33,8 +33,22 @@ endif (Qt5Widgets_FOUND)
 set(LIBRARY_OUTPUT_PATH    "${KS_DIR}/lib")
 set(EXECUTABLE_OUTPUT_PATH "${KS_DIR}/bin")
 
-set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -Wall -g -pthread -fPIC")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g -std=c++11 -pthread -fPIC")
+set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -Wall -pthread -fPIC")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -pthread -fPIC")
+
+if (NOT CMAKE_BUILD_TYPE MATCHES Release)
+
+    set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -g")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
+
+endif (NOT CMAKE_BUILD_TYPE MATCHES Release)
+
+if (NOT CMAKE_BUILD_TYPE MATCHES Debug)
+
+    set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -O2")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
+
+endif (NOT CMAKE_BUILD_TYPE MATCHES Debug)
 
 if(NOT _INSTALL_PREFIX)
 	set(_INSTALL_PREFIX "/usr/local")
@@ -47,13 +61,6 @@ set(KS_ICON_FIN    KS_icon_fin.svg)
 set(KS_LOGO        KS_logo_symbol.svg)
 set(KS_LOGO_LABEL  KS_logo_horizontal.svg)
 
-if (NOT _DEBUG)
-
-	set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -O2")
-	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
-
-endif (NOT _DEBUG)
-
 SET(CMAKE_INSTALL_RPATH "${_INSTALL_PREFIX}/lib/${KS_APP_NAME}/")
 SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
 
kernel-shark/README +2 -2
index 379c390..2027044 100644
@@ -39,13 +39,13 @@ the original trace-cmd end traceevent libraries.
 as a CMake Command-Line option.
 
 2.1.2 In order to generates complete debug information to be used by GDB add
--D_DEBUG=1 as a CMake Command-Line option.
+-DCMAKE_BUILD_TYPE=Debug as a CMake Command-Line option.
 
 2.1.3 By default, installation prefix is "/usr/local". It can be changed using
 -D_INSTALL_PREFIX= as a CMake Command-Line option.
 
 Example:
-    cmake -D_DOXYGEN_DOC=1 -D_DEBUG=1 -D_INSTALL_PREFIX=/usr ../
+    cmake -D_DOXYGEN_DOC=1 -DCMAKE_BUILD_TYPE=Debug -D_INSTALL_PREFIX=/usr ../
 
 2.2.1 Use "make clean" if you want to delete all already compiled objects.
 
Signature · 1 line
2.20.1
#3 lore raw
In reply to Yordan Karadzhov
Quoted 3 lines · On Tue, 11 Jun 2019 18:20:41 +0300 Yordan Karadzhov <[email protected]>…

Two patches addressing the problem of having the paths to the build directory embedded in the final binaries. The problem was reported by Troy Engel.

Hi Troy,

Do these patches work for you?

https://patchwork.kernel.org/patch/10987563/
https://patchwork.kernel.org/patch/10987565/

If so, can I add our "Tested-by"?

Thanks!

-- Steve

Quoted 12 lines

Yordan Karadzhov (2):
kernel-shark: Avoid TRACECMD_BIN_DIR being set to the build path
kernel-shark: Avoid debug build when CMAKE_BUILD_TYPE=Release

 kernel-shark/CMakeLists.txt           | 25 ++++++++++++++++---------
 kernel-shark/README                   |  4 ++--
 kernel-shark/build/FindTraceCmd.cmake | 14 +++++++++-----
 kernel-shark/build/deff.h.cmake       |  2 +-
 kernel-shark/src/KsCaptureDialog.cpp  | 13 ++++++++-----
 5 files changed, 36 insertions(+), 22 deletions(-)