medusa icon indicating copy to clipboard operation
medusa copied to clipboard

Please sanitize the build system

Open hasselmm opened this issue 7 years ago • 7 comments

Even if all dependencies listed in README.rst and the build instructions are followed the build system tries download and build giga bytes of common libraries which all are provided by typical Linux distributions. This simply doesn't make any sense as it wastes the time of potential users and contributors without giving them any benefit.

hasselmm avatar Feb 04 '17 23:02 hasselmm

Hi hasselmm, AFAIK only boost and qt are packaged on most linux distribution (LLVM is a bit different on this case), the actual CMake script should give the choice to either: compile the dependency with hunter or using the classic CMake way(, but you still have to provide a correct path). That's why I'm not really sure to understand your request. I'm aware this project lacks of a correct and up to date documentation about how to compile and use it. However, if you have a specific request, feel free to give details about that.

Thanks for reporting an issue.

wisk avatar Feb 13 '17 01:02 wisk

Hi wisk,

sorry for late reply - lost focus on this, sorry. Good to hear that building without Hunter shall be possible, it's just that your instructions in README.rst seem to trigger a Hunter build, even if all dependencies are available. Well, have a closer look why this is happening.

hasselmm avatar Mar 05 '17 14:03 hasselmm

I'll leave this here for now, feel free to delete this post.

-- [download 100% complete] -- verifying file... file='/home/hnlfu4/.hunter/_Base/Download/OGDF/snapshot-2015-12-04/fb9b5d9/snapshot-2015-12-04.tar.gz' -- SHA1 hash of /home/hnlfu4/.hunter/_Base/Download/OGDF/snapshot-2015-12-04/fb9b5d9/snapshot-2015-12-04.tar.gz does not match expected value expected: 'fb9b5d93fd27feae91799c5a52805e10c139b22e' actual: '0a55144b31d165f4b3009693cb9089c6b8930c88' -- Hash mismatch, removing... -- Retry after 15 seconds (attempt #4) ...

xgRTHKk4 avatar Dec 30 '17 20:12 xgRTHKk4

-- Using src='https://github.com/wisk/ogdf/archive/snapshot-2015-12-04.tar.gz'

xgRTHKk4 avatar Dec 30 '17 20:12 xgRTHKk4

I'm running into this issue when attempting to compile Medusa.

Show libraries installed, clone and prepare build:

$ dpkg -l 'libboost*-dev' '*qt*-dev' 'libsoci-dev' 'libsqlite3-dev' | sed -rn '/^i/s/^ *([^ ]+( +[^ ]+){2}).*$/\1/p'
ii  libboost-atomic1.62-dev:amd64          1.62.0+dfsg-4
ii  libboost-chrono1.62-dev:amd64          1.62.0+dfsg-4
ii  libboost-context1.62-dev:amd64         1.62.0+dfsg-4
ii  libboost-coroutine-dev:amd64           1.62.0.1
ii  libboost-coroutine1.62-dev:amd64       1.62.0+dfsg-4
ii  libboost-date-time1.62-dev:amd64       1.62.0+dfsg-4
ii  libboost-dev:amd64                     1.62.0.1
ii  libboost-filesystem-dev:amd64          1.62.0.1
ii  libboost-filesystem1.62-dev:amd64      1.62.0+dfsg-4
ii  libboost-graph-dev:amd64               1.62.0.1
ii  libboost-graph1.62-dev:amd64           1.62.0+dfsg-4
ii  libboost-program-options-dev:amd64     1.62.0.1
ii  libboost-program-options1.62-dev:amd64 1.62.0+dfsg-4
ii  libboost-regex-dev:amd64               1.62.0.1
ii  libboost-regex1.62-dev:amd64           1.62.0+dfsg-4
ii  libboost-serialization1.62-dev:amd64   1.62.0+dfsg-4
ii  libboost-system1.62-dev:amd64          1.62.0+dfsg-4
ii  libboost-test1.62-dev:amd64            1.62.0+dfsg-4
ii  libboost-thread-dev:amd64              1.62.0.1
ii  libboost-thread1.62-dev:amd64          1.62.0+dfsg-4
ii  libboost-wave-dev:amd64                1.62.0.1
ii  libboost-wave1.62-dev:amd64            1.62.0+dfsg-4
ii  libboost1.62-dev:amd64                 1.62.0+dfsg-4
ii  libqt4-dev                             4:4.8.7+dfsg-11
ii  libqt4-opengl-dev                      4:4.8.7+dfsg-11
ii  libqt5opengl5-dev:amd64                5.7.1+dfsg-3+b1
ii  libsoci-dev                            3.2.3-2
ii  libsqlite3-dev:amd64                   3.16.2-5+deb9u1
ii  qtbase5-dev:amd64                      5.7.1+dfsg-3+b1
ii  qtmultimedia5-dev:amd64                5.7.1~20161021-2
ii  qtscript5-dev:amd64                    5.7.1~20161021+dfsg-2
$ git clone https://github.com/wisk/medusa
$ cd medusa
$ mkdir build
$ cd build

I try to build without Hunter. First hurdle: OGDF_ROOT is not defined.

$ cmake .. -DHUNTER_ENABLED=OFF
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Compile all modules
-- Boost version: 1.62.0
-- Found the following Boost libraries:
--   system
--   atomic
--   filesystem
--   program_options
--   graph
--   regex
CMake Error at cmake/FindOGDF.cmake:2 (message):
  You must defined OGDF_ROOT
Call Stack (most recent call first):
  CMakeLists.txt:92 (find_package)


-- Configuring incomplete, errors occurred!
See also "/<redacted>/medusa/build/CMakeFiles/CMakeOutput.log".

Graphic output is not so important to me, so I define MEDUSA_BUILD_WITH_OGDF=OFF. No change. I try defining OGDF_ROOT= and it somehow makes it past that point. Next hurdle, SQLite3:

$ cmake .. -DHUNTER_ENABLED=OFF -DMEDUSA_BUILD_WITH_OGDF=OFF -DOGDF_ROOT=
Compile all modules
-- Boost version: 1.62.0
-- Found the following Boost libraries:
--   system
--   atomic
--   filesystem
--   program_options
--   graph
--   regex
OGDF found
-- Performing Test HAVE_ABI_VERSION
-- Performing Test HAVE_ABI_VERSION - Success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Build arch_arm (Architectures)
-- Build arch_st62 (Architectures)
-- Build arch_x86 (Architectures)
-- Build arch_z80 (Architectures)
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so (found version "2.7.13") 
CMake Warning at src/compil/llvm/CMakeLists.txt:14 (message):
  Please, define LLVM_ROOT to compile compil_llvm


CMake Error at src/db/soci/CMakeLists.txt:12 (find_package):
  By not providing "FindSQLite3.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "SQLite3", but
  CMake did not find one.

  Could not find a package configuration file provided by "SQLite3" with any
  of the following names:

    SQLite3Config.cmake
    sqlite3-config.cmake

  Add the installation prefix of "SQLite3" to CMAKE_PREFIX_PATH or set
  "SQLite3_DIR" to a directory containing one of the above files.  If
  "SQLite3" provides a separate development package or SDK, be sure it has
  been installed.


-- Configuring incomplete, errors occurred!
See also "/<redacted>/medusa/build/CMakeFiles/CMakeOutput.log".
See also "/<redacted>/medusa/build/CMakeFiles/CMakeError.log".

I have a FindSQLIte3.cmake in my disk from another project (Minetest), so I copy it to <medusa>/cmake and SQLite3 is detected. Next hurdle: SOCI.

$ cp /<redacted>/cmake/Modules/FindSQLite3.cmake ../cmake/
$ cmake .. -DHUNTER_ENABLED=OFF -DMEDUSA_BUILD_WITH_OGDF=OFF -DOGDF_ROOT=
Compile all modules
-- Boost version: 1.62.0
-- Found the following Boost libraries:
--   system
--   atomic
--   filesystem
--   program_options
--   graph
--   regex
OGDF found
-- Build arch_arm (Architectures)
-- Build arch_st62 (Architectures)
-- Build arch_x86 (Architectures)
-- Build arch_z80 (Architectures)
CMake Warning at src/compil/llvm/CMakeLists.txt:14 (message):
  Please, define LLVM_ROOT to compile compil_llvm


-- Found SQLite3: /usr/lib/x86_64-linux-gnu/libsqlite3.so  
CMake Error at src/db/soci/CMakeLists.txt:13 (include):
  include could not find load file:

    /cmake/SOCI.cmake


-- Build emul_interpreter (Emulators)
CMake Warning at src/emul/llvm/CMakeLists.txt:14 (message):
  Please, define LLVM_ROOT to compile emul_llvm


-- Build ldr_bs (Loaders)
-- Build ldr_elf (Loaders)
-- Build ldr_gb (Loaders)
-- Build ldr_mach-o (Loaders)
-- Build ldr_pe (Loaders)
-- Build ldr_raw (Loaders)
-- Build ldr_st62 (Loaders)
-- Build os_unix (OperatingSystems)
-- Build os_windows (OperatingSystems)
-- Qt found, qMedusa will be compiled
-- pydusa found, generate python package
-- Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE) 
-- Configuring incomplete, errors occurred!
See also "/<redacted>/medusa/build/CMakeFiles/CMakeOutput.log".
See also "/<redacted>/medusa/build/CMakeFiles/CMakeError.log".

Indeed. SOCI.cmake is not there. Setting MEDUSA_BUILD_WITH_SOCI=OFF has no effect. Neither does setting MEDUSA_BUILD_WITH_SQLITE3=OFF (I tried that just in case SQLite3 was pulling SOCI).

At this point, I give up, search the issue tracker, find this issue, and post this report.

Is it possible to fix the build system so that a fresh clone compiles without Hunter? A comment above mentions that LLVM is a bit different. If LLVM is a requisite to compile Medusa, could the specific LLVM used be included as a submodule? I see that the only submodule is https://github.com/wisk/samples currently, so I didn't bother to fetch it.

My aim is to reverse-engineer Z80 code. I'm currently using dz80 with .ctl files, but that's not very practical, and I wanted to give Medusa a go.

ghost avatar Nov 21 '18 11:11 ghost

Also ran into this problem, made progress thanks to the previous comment. On an Arch linux system, installed llvm, ogdf-snapshot and soci from the AUR. Added FindSQLite3.cmake (as linked previously), and FindSoci.cmake to the cmake directory, then applied the following hacky changes:

diff --git a/src/compil/llvm/CMakeLists.txt b/src/compil/llvm/CMakeLists.txt
index 7582f1a..369254f 100644
--- a/src/compil/llvm/CMakeLists.txt
+++ b/src/compil/llvm/CMakeLists.txt
@@ -10,20 +10,11 @@ set(SRC
 # TODO(KS): Probably not the optimal solution, but it works, so who cares?
 set(MEDUSA_LLVM_LIBS all)
 
-if (UNIX AND NOT LLVM_ROOT)
-  message(WARNING "Please, define LLVM_ROOT to compile compil_llvm")
-endif()
-
-if (MSVC AND (NOT LLVM_ROOT_DEBUG OR NOT LLVM_ROOT_RELEASE))
-  message(WARNING "Please, define both LLVM_ROOT_DBUG AND LLVM_ROOT_RELEASE to compile compil_llvm")
-endif()
 
-
-if (UNIX AND LLVM_ROOT)
+if (UNIX)
 
   add_library(compil_llvm SHARED ${SRC})
-  set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${LLVM_ROOT}/share/llvm/cmake")
-  include(LLVMConfig)
+  find_package(LLVM)
   include_directories(${LLVM_INCLUDE_DIRS})
   link_directories(${LLVM_LIBRARY_DIRS})
   add_definitions(${LLVM_DEFINITIONS})
diff --git a/src/db/soci/CMakeLists.txt b/src/db/soci/CMakeLists.txt
index 696d331..6311e29 100644
--- a/src/db/soci/CMakeLists.txt
+++ b/src/db/soci/CMakeLists.txt
@@ -10,13 +10,13 @@ set(SRC
   )
 
 find_package(SQLite3 REQUIRED)
-include("${SOCI_ROOT}/cmake/SOCI.cmake")
+find_package(Soci REQUIRED)
 
 # define db soci target
 include_directories(${SQLITE3_INCLUDE_DIRS})
 include_directories(${SOCI_INCLUDE_DIRS})
 add_library(db_soci SHARED ${SRC})
-target_link_libraries(db_soci medusa ${SQLITE3_LIBRARY} SOCI::soci_core_static SOCI::soci_sqlite3_static)
+target_link_libraries(db_soci medusa ${SQLITE3_LIBRARY} ${SOCI_LIBRARY} ${SOCI_sqlite3_PLUGIN})
 set_target_properties(db_soci PROPERTIES
   FOLDER "Databases"
   PREFIX ""
diff --git a/src/emul/llvm/CMakeLists.txt b/src/emul/llvm/CMakeLists.txt
index 06e7b13..39e0818 100644
--- a/src/emul/llvm/CMakeLists.txt
+++ b/src/emul/llvm/CMakeLists.txt
@@ -10,20 +10,10 @@ set(SRC
 # TODO(KS): Probably not the optimal solution, but it works, so who cares?
 set(MEDUSA_LLVM_LIBS all)
 
-if (UNIX AND NOT LLVM_ROOT)
-  message(WARNING "Please, define LLVM_ROOT to compile emul_llvm")
-endif()
-
-if (MSVC AND (NOT LLVM_ROOT_DEBUG OR NOT LLVM_ROOT_RELEASE))
-  message(WARNING "Please, define both LLVM_ROOT_DBUG AND LLVM_ROOT_RELEASE to compile emul_llvm")
-endif()
-
-
-if (UNIX AND LLVM_ROOT)
+if (UNIX)
 
   add_library(emul_llvm SHARED ${SRC})
-  set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${LLVM_ROOT}/share/llvm/cmake")
-  include(LLVMConfig)
+  find_package(LLVM)
   include_directories(${LLVM_INCLUDE_DIRS})
   link_directories(${LLVM_LIBRARY_DIRS})
   add_definitions(${LLVM_DEFINITIONS})

IgnoredAmbience avatar Nov 22 '18 01:11 IgnoredAmbience

Thanks for the patch. Thanks to it, I made it past the configure phase, but there were more surprises: two more projects were being dowloaded during the build process, namely pybind11 and PEGTL (also in Debian):

$ dpkg -l '*pegtl*' '*pybind11*-dev' | sed -rn '/^i/s/^ *([^ ]+( +[^ ]+){2}).*$/\1/p'
ii  pegtl-dev      1.3.1-1
ii  pybind11-dev   2.0.1-3

One is invoked from the main CMakeLists.txt and the other from src/tools/pydusa/CMakeLists.txt.

I've started to use unshare to disable networking during the configure and build process. There are quite some use cases for which it's not acceptable to have a build process use a network connection, and I'm in that situation.

Apart from that, the build failed in a way that I was afraid would happen: the OGDF dependency is not optional, despite having the MEDUSA_BUILD_WITH_OGDF flag. Since that one is not included in my Debian, next I'll try to incorporate it as a git submodule.

ghost avatar Nov 22 '18 16:11 ghost