emsec / hal

HAL – The Hardware Analyzer
MIT License
624 stars 76 forks source link

`make install` is broken on Ubuntu 22.04 #592

Open RenWal opened 4 days ago

RenWal commented 4 days ago

Multiple issues with installing HAL on Ubuntu 22.04:

ldconfig isn't run at the appropriate time

When running make install, ldconfig is invoked via the post_install.cmake.in config, but that happens too early, namely before instead of after installing the shared objects (and plugins). See make install output snippet below:

[…]
-- Installing: /usr/local/share/cmake/hal/halTargets.cmake
-- Installing: /usr/local/share/cmake/hal/halTargets-release.cmake
-- Installing: /usr/local/share/hal/ld_conf/hal.conf
-- Copy file /usr/local/share/hal/ld_conf/hal.conf to /etc/ld.so.conf.d/
-- Running: ldconfig
-- Installing: /usr/local/lib/libhal_core.so
-- Set runtime path of "/usr/local/lib/libhal_core.so" to ""
-- Installing: /usr/local/lib/libhal_utilities.so
-- Installing: /usr/local/lib/libhal_netlist.so
-- Set runtime path of "/usr/local/lib/libhal_netlist.so" to ""
-- Installing: /usr/local/lib/libhal_plugin_system.so
-- Set runtime path of "/usr/local/lib/libhal_plugin_system.so" to ""
-- Installing: /usr/local/lib/hal_py.so
-- Set runtime path of "/usr/local/lib/hal_py.so" to ""
-- Installing: /usr/local/bin/hal
-- Set runtime path of "/usr/local/bin/hal" to ""
[…]

Manually invoking ldconfig once is enough to fix the issue, but this should be handled properly by the build toolchain.

Plugins with dependencies won't load

After installing HAL as above, any plugin that depends on another plugin won't load:

[14.10.2024 13:39:48] [core] [info] loading plugin '/usr/local/lib/hal_plugins/logic_evaluator.so'...
[14.10.2024 13:39:48] [core] [error] [/home/hrecourse/hal/src/plugin_system/runtime_library.cpp:47] cannot load library '/usr/local/lib/hal_plugins/logic_evaluator.so' (error: netlist_simulator_controller.so: cannot open shared object file: No such file or directory) -- did you properly link the plugin?
[14.10.2024 13:39:48] [gui] [warning] [/home/hrecourse/hal/plugins/gui/src/plugin_relay/gui_plugin_manager.cpp:551] Error loading plugin 'logic_evaluator' from location '/usr/local/lib/hal_plugins/logic_evaluator.so'
[14.10.2024 13:39:48] [gui] [warning] [/home/hrecourse/hal/plugins/gui/src/plugin_relay/gui_plugin_manager.cpp:389] GuiPluginManager: loading of 'logic_evaluator' failed, is it really a HAL plugin?

HAL appears to be looking for the shared object in the wrong location:

$ strace -f -e trace=file hal -g
[…]
[14.10.2024 13:48:39] [core] [info] loading plugin '/usr/local/lib/hal_plugins/logic_evaluator.so'...
[pid 35139] openat(AT_FDCWD, "/usr/local/lib/hal_plugins/logic_evaluator.so", O_RDONLY|O_CLOEXEC) = 24
[pid 35139] newfstatat(24, "", {st_mode=S_IFREG|0755, st_size=783584, ...}, AT_EMPTY_PATH) = 0
[pid 35139] openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 24
[pid 35139] newfstatat(24, "", {st_mode=S_IFREG|0644, st_size=78063, ...}, AT_EMPTY_PATH) = 0
[pid 35139] openat(AT_FDCWD, "/lib/x86_64-linux-gnu/netlist_simulator_controller.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 35139] openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/netlist_simulator_controller.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 35139] openat(AT_FDCWD, "/lib/netlist_simulator_controller.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 35139] openat(AT_FDCWD, "/usr/lib/netlist_simulator_controller.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[14.10.2024 13:48:39] [core] [error] [/home/hrecourse/hal/src/plugin_system/runtime_library.cpp:47] cannot load library '/usr/local/lib/hal_plugins/logic_evaluator.so' (error: netlist_simulator_controller.so: cannot open shared object file: No such file or directory) -- did you properly link the plugin?
RenWal commented 4 days ago

@joern274 About that dependency issue: Any insights on what may be going on in the plugin manager here? Is this a configuration problem at install time (e.g. some library path not correctly configured) or caused by the way the plugin manager looks for dependencies?