avast / retdec

RetDec is a retargetable machine-code decompiler based on LLVM.
https://retdec.com/
MIT License
7.96k stars 940 forks source link

Static libraries #755

Open blue-devil opened 4 years ago

blue-devil commented 4 years ago

Hello. I am making packages for linux distrubition PisiLinux

  1. At the end of the compilation there are "static libraries" under /usr/lib64. How can i prevent compiling static libraries? The parameter DBUILD_STATIC_LIBS=OFF doesnt work. Any ideas?

  2. under support directory and in the CMakeLists.txt file. Absolute paths arenot working all right.

    set(SUPPORT_TARGET_DIR "${RETDEC_INSTALL_SUPPORT_DIR_ABS}")
    set(YARAC_PATH         "${RETDEC_INSTALL_BIN_DIR_ABS}/retdec-yarac${CMAKE_EXECUTABLE_SUFFIX}")
    set(YARAC_VERSION_PATH "${SUPPORT_TARGET_DIR}/version-yarac.txt")

    SUPPORT_TARGET_DIR doesnt work RETDEC_INSTALL_BIN_DIR_ABS doesnt work either. They dont return the absolute paths.

PeterMatula commented 4 years ago

Hi, right now, we are building only the static libs. Would you like the dynamic ones? Or what is the problem with static libraries?

As for the SUPPORT_TARGET_DIR and RETDEC_INSTALL_BIN_DIR_ABS - I will look into it, but can you post the configuration, build, and installation commands you used?

blue-devil commented 4 years ago
  1. Sorry for the late post :/

  2. I have no problems wiıth the static libs. I am just making packages for PisiLinux
    distro and admins 'generally' dont include static libs or seperate them. Not a big deal.

  3. Real problem is SUPPORT_TARGET_DIR and RETDEC_INSTALL_BIN_DIR_ABS these cannot find their paths while compliling. So i have written a patch for these: https://github.com/pisilinux/KaraPisi/blob/master/security/reversing/decompiler/retdec/files/SCTZineCMakeListsPisiFix.patch

Patch changes absolute paths to direct paths:

--- support.orig/CMakeLists.txt 2020-04-07 23:09:28.000000000 +0200
+++ support/CMakeLists.txt  2020-04-28 13:03:34.387943557 +0200
@@ -6,8 +6,8 @@

 set(CMAKE_INSTALL_MESSAGE LAZY)
 set(SUPPORT_TARGET_DIR "${RETDEC_INSTALL_SUPPORT_DIR_ABS}")
-set(YARAC_PATH         "${RETDEC_INSTALL_BIN_DIR_ABS}/retdec-yarac${CMAKE_EXECUTABLE_SUFFIX}")
-set(YARAC_VERSION_PATH "${SUPPORT_TARGET_DIR}/version-yarac.txt")
+set(YARAC_PATH         "/var/pisi/retdec-4.0-2/install/usr/bin/retdec-yarac${CMAKE_EXECUTABLE_SUFFIX}")
+set(YARAC_VERSION_PATH "/var/pisi/retdec-4.0-2/install/usr/share/retdec/support/version-yarac.txt")

 # Clean the support target directory if YARA compilation flag changed.
 #
@@ -46,20 +46,22 @@
    endif()
 ")

+# 2020-02-29 - BlueDeviL note: We manually download the binary
+
 # Get and install external support package from the retdec-support repository.
 # This step may erase the entire target support directory, so it needs to go
 # first.
 #
-install(CODE "
-   execute_process(
-       # -u = unbuffered -> print debug messages right away.
-       COMMAND \"${PYTHON_EXECUTABLE}\" -u \"${CMAKE_SOURCE_DIR}/support/install-share.py\" \"${CMAKE_INSTALL_PREFIX}\" \"${SUPPORT_PKG_URL}\" \"${SUPPORT_PKG_SHA256}\" \"${SUPPORT_PKG_VERSION}\"
-       RESULT_VARIABLE INSTALL_SHARE_RES
-   )
-   if(INSTALL_SHARE_RES)
-       message(FATAL_ERROR \"RetDec share directory installation FAILED\")
-   endif()
-")
+#install(CODE "
+#  execute_process(
+#      # -u = unbuffered -> print debug messages right away.
+#      COMMAND \"${PYTHON_EXECUTABLE}\" -u \"${CMAKE_SOURCE_DIR}/support/install-share.py\" \"${CMAKE_INSTALL_PREFIX}\" \"${SUPPORT_PKG_URL}\" \"${SUPPORT_PKG_SHA256}\" \"${SUPPORT_PKG_VERSION}\"
+#      RESULT_VARIABLE INSTALL_SHARE_RES
+#  )
+#  if(INSTALL_SHARE_RES)
+#      message(FATAL_ERROR \"RetDec share directory installation FAILED\")
+#  endif()
+#")

 # Write currently used yarac version to the support directory.
 #
@@ -97,7 +99,7 @@
    execute_process(
        COMMAND \"${PYTHON_EXECUTABLE}\" -u \"${YARA_INSTALL_PY}\"
            \"${YARAC_PATH}\"
-           \"${SUPPORT_TARGET_DIR}\"
+           \"/var/pisi/retdec-4.0-2/install/usr/share/retdec/support\"
            \"${CMAKE_SOURCE_DIR}/support/yara_patterns\"
            ${RETDEC_COMPILE_YARA}
        RESULT_VARIABLE INSTALL_YARA_RES

I am using PisiLinux and Pisi Package Manager.