flightlessmango / MangoHud

A Vulkan and OpenGL overlay for monitoring FPS, temperatures, CPU/GPU load and more. Discord: https://discordapp.com/invite/Gj5YmBb
MIT License
6.26k stars 269 forks source link

Unable to run on riscv64 #599

Open archanox opened 2 years ago

archanox commented 2 years ago

When executing the following command mangohud --dlsym ./re3 I get the following error can't get libdl.so.

Mangohud was installed from the Ubuntu apt repo with no issues. I suspect it's something to do with not having installed libc6-i686 which is unavailable.

How does this work on aarch64?

TheComputerGuy96 commented 2 years ago

@archanox Try recompilling MangoHUD from source

archanox commented 2 years ago

When building from source, unfortunately I have unmet dependencies, and an odd error at the end.

ubuntu@ubuntu:~/MangoHud$ ./build.sh build
Command: build
# Checking Dependencies
# Missing dependencies:gcc-multilib g++-multilib mesa-common-dev libxnvctrl-dev
Do you wish the script to install these packages? [y/N]y
Attempting to install missing packages
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package gcc-multilib is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'gcc-multilib' has no installation candidate
E: Unable to locate package g++-multilib
The Meson build system
Version: 0.56.2
Source dir: /home/ubuntu/MangoHud
Build dir: /home/ubuntu/MangoHud/build/meson64
Build type: native build
Project name: MangoHud
Project version: v0.6.5
C compiler for the host machine: ccache cc (gcc 10.3.0 "cc (Ubuntu 10.3.0-1ubuntu1) 10.3.0")
C linker for the host machine: cc ld.bfd 2.36.1
C++ compiler for the host machine: ccache c++ (gcc 10.3.0 "c++ (Ubuntu 10.3.0-1ubuntu1) 10.3.0")
C++ linker for the host machine: c++ ld.bfd 2.36.1
Host machine cpu family: riscv64
Host machine cpu: riscv64
Program python3 (mako) found: YES (/usr/bin/python3) modules: mako
Checking if "GCC atomic builtins" compiles: YES
Checking if "Supports timespec_get" compiles: YES
Checking for function "bswap32" : YES
Checking for function "bswap64" : YES
Checking for function "clz" : YES
Checking for function "clzll" : YES
Checking for function "ctz" : YES
Checking for function "expect" : YES
Checking for function "ffs" : YES
Checking for function "ffsll" : YES
Checking for function "popcount" : YES
Checking for function "popcountll" : YES
Checking for function "unreachable" : YES
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Run-time dependency x11 found: YES 1.7.0
Dependency wayland-client skipped: feature with_wayland disabled
Run-time dependency dbus-1 found: YES 1.12.20
Dependency vulkan skipped: feature use_system_vulkan disabled
Run-time dependency threads found: YES
Compiler for C supports arguments -Werror=implicit-function-declaration: YES
Compiler for C supports arguments -Werror=missing-prototypes: YES
Compiler for C supports arguments -Werror=return-type: YES
Compiler for C supports arguments -Werror=incompatible-pointer-types: YES
Compiler for C supports arguments -fno-math-errno: YES
Compiler for C supports arguments -fno-trapping-math: YES
Compiler for C supports arguments -Qunused-arguments: NO
Compiler for C supports arguments -Wmissing-field-initializers: YES
Compiler for C supports arguments -Wformat-truncation: YES
Compiler for C++ supports arguments -Werror=return-type: YES
Compiler for C++ supports arguments -fno-math-errno: YES
Compiler for C++ supports arguments -fno-trapping-math: YES
Compiler for C++ supports arguments -Qunused-arguments: NO
Compiler for C++ supports arguments -Wnon-virtual-dtor: YES
Compiler for C++ supports arguments -Wmissing-field-initializers: YES
Compiler for C++ supports arguments -Wformat-truncation: YES
Compiler for C supports arguments -Woverride-init: YES
Compiler for C supports arguments -Winitializer-overrides: NO
Checking for function "dlopen" : NO
Library dl found: YES
Checking for function "clock_gettime" : YES
Downloading vulkan-headers source from https://github.com/KhronosGroup/Vulkan-Headers/archive/v1.2.158.tar.gz
Downloading file of unknown size.
Downloading vulkan-headers patch from https://wrapdb.mesonbuild.com/v1/projects/vulkan-headers/1.2.158/1/get_zip
Download size: 1107
Downloading: ..........

|Executing subproject vulkan-headers method meson
|
|Project name: vulkan-headers
|Project version: 1.2.158
|C compiler for the host machine: ccache cc (gcc 10.3.0 "cc (Ubuntu 10.3.0-1ubuntu1) 10.3.0")
|C linker for the host machine: cc ld.bfd 2.36.1
|Build targets in project: 1
|Subproject vulkan-headers finished.

Checking for size of "void*" : 8
Downloading imgui source from https://github.com/ocornut/imgui/archive/v1.81.tar.gz
Downloading file of unknown size.
Downloading imgui patch from https://wrapdb.mesonbuild.com/v1/projects/imgui/1.81/1/get_zip
Download size: 1850
Downloading: ..........

|Executing subproject imgui method meson
|
|Project name: imgui
|Project version: 1.81
|C++ compiler for the host machine: ccache c++ (gcc 10.3.0 "c++ (Ubuntu 10.3.0-1ubuntu1) 10.3.0")
|C++ linker for the host machine: c++ ld.bfd 2.36.1
|Library d3d9 skipped: feature dx9 disabled
|Library d3d10 skipped: feature dx10 disabled
|Library d3d11 skipped: feature dx11 disabled
|Library d3d12 skipped: feature dx12 disabled
|Library metal skipped: feature metal disabled
|Dependency glew skipped: feature opengl disabled
|Dependency vulkan skipped: feature vulkan disabled
|Dependency glfw3 skipped: feature glfw disabled
|Dependency sdl2 skipped: feature sdl2 disabled
|Dependency allegro5 skipped: feature allegro5 disabled
|Library marmalade skipped: feature marmalade disabled
|Build targets in project: 3
|Subproject imgui finished.

Program glslangValidator found: YES (/usr/local/bin/glslangValidator)
Has header "NVCtrl/NVCtrl.h" : NO

src/meson.build:121:6: ERROR: Problem encountered: NVCtrl.h was not found. Disable with '-Dwith_xnvctrl=disabled' if gpu stats by XNVCtrl is not needed.

A full log can be found at /home/ubuntu/MangoHud/build/meson64/meson-logs/meson-log.txt
ubuntu@ubuntu:~/MangoHud$

meson-log.txt

EDIT: Wait, I'm an idiot, trying again after installing sudo apt install mesa-common-dev libxnvctrl-dev

TheComputerGuy96 commented 2 years ago

@archanox You have to disable XNVCtrl as seen in the log

archanox commented 2 years ago

So I got further, but not by much.

ubuntu@ubuntu:~/MangoHud$ ./build.sh build
Command: build
# Checking Dependencies
# Missing dependencies:gcc-multilib g++-multilib
Do you wish the script to install these packages? [y/N]y
Attempting to install missing packages
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package gcc-multilib is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'gcc-multilib' has no installation candidate
E: Unable to locate package g++-multilib
The Meson build system
Version: 0.56.2
Source dir: /home/ubuntu/MangoHud
Build dir: /home/ubuntu/MangoHud/build/meson64
Build type: native build
Project name: MangoHud
Project version: v0.6.5
C compiler for the host machine: ccache cc (gcc 10.3.0 "cc (Ubuntu 10.3.0-1ubuntu1) 10.3.0")
C linker for the host machine: cc ld.bfd 2.36.1
C++ compiler for the host machine: ccache c++ (gcc 10.3.0 "c++ (Ubuntu 10.3.0-1ubuntu1) 10.3.0")
C++ linker for the host machine: c++ ld.bfd 2.36.1
Host machine cpu family: riscv64
Host machine cpu: riscv64
Program python3 (mako) found: YES (/usr/bin/python3) modules: mako
Checking if "GCC atomic builtins" compiles: YES
Checking if "Supports timespec_get" compiles: YES
Checking for function "bswap32" : YES
Checking for function "bswap64" : YES
Checking for function "clz" : YES
Checking for function "clzll" : YES
Checking for function "ctz" : YES
Checking for function "expect" : YES
Checking for function "ffs" : YES
Checking for function "ffsll" : YES
Checking for function "popcount" : YES
Checking for function "popcountll" : YES
Checking for function "unreachable" : YES
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Run-time dependency x11 found: YES 1.7.0
Dependency wayland-client skipped: feature with_wayland disabled
Run-time dependency dbus-1 found: YES 1.12.20
Dependency vulkan skipped: feature use_system_vulkan disabled
Run-time dependency threads found: YES
Compiler for C supports arguments -Werror=implicit-function-declaration: YES
Compiler for C supports arguments -Werror=missing-prototypes: YES
Compiler for C supports arguments -Werror=return-type: YES
Compiler for C supports arguments -Werror=incompatible-pointer-types: YES
Compiler for C supports arguments -fno-math-errno: YES
Compiler for C supports arguments -fno-trapping-math: YES
Compiler for C supports arguments -Qunused-arguments: NO
Compiler for C supports arguments -Wmissing-field-initializers: YES
Compiler for C supports arguments -Wformat-truncation: YES
Compiler for C++ supports arguments -Werror=return-type: YES
Compiler for C++ supports arguments -fno-math-errno: YES
Compiler for C++ supports arguments -fno-trapping-math: YES
Compiler for C++ supports arguments -Qunused-arguments: NO
Compiler for C++ supports arguments -Wnon-virtual-dtor: YES
Compiler for C++ supports arguments -Wmissing-field-initializers: YES
Compiler for C++ supports arguments -Wformat-truncation: YES
Compiler for C supports arguments -Woverride-init: YES
Compiler for C supports arguments -Winitializer-overrides: NO
Checking for function "dlopen" : NO
Library dl found: YES
Checking for function "clock_gettime" : YES

|Executing subproject vulkan-headers method meson
|
|Project name: vulkan-headers
|Project version: 1.2.158
|C compiler for the host machine: ccache cc (gcc 10.3.0 "cc (Ubuntu 10.3.0-1ubuntu1) 10.3.0")
|C linker for the host machine: cc ld.bfd 2.36.1
|Build targets in project: 1
|Subproject vulkan-headers finished.

Checking for size of "void*" : 8

|Executing subproject imgui method meson
|
|Project name: imgui
|Project version: 1.81
|C++ compiler for the host machine: ccache c++ (gcc 10.3.0 "c++ (Ubuntu 10.3.0-1ubuntu1) 10.3.0")
|C++ linker for the host machine: c++ ld.bfd 2.36.1
|Library d3d9 skipped: feature dx9 disabled
|Library d3d10 skipped: feature dx10 disabled
|Library d3d11 skipped: feature dx11 disabled
|Library d3d12 skipped: feature dx12 disabled
|Library metal skipped: feature metal disabled
|Dependency glew skipped: feature opengl disabled
|Dependency vulkan skipped: feature vulkan disabled
|Dependency glfw3 skipped: feature glfw disabled
|Dependency sdl2 skipped: feature sdl2 disabled
|Dependency allegro5 skipped: feature allegro5 disabled
|Library marmalade skipped: feature marmalade disabled
|Build targets in project: 3
|Subproject imgui finished.

Program glslangValidator found: YES (/usr/local/bin/glslangValidator)
Has header "NVCtrl/NVCtrl.h" : YES
Compiler for C supports link arguments -Wl,-Bsymbolic-functions: YES
Compiler for C supports link arguments -Wl,-z,relro: YES
Compiler for C supports link arguments -Wl,--exclude-libs,ALL: YES
Configuring MangoHud.json using configuration
Configuring mangohud using configuration
Build targets in project: 7

MangoHud v0.6.5

  Subprojects
             imgui: YES
    vulkan-headers: YES

Found ninja-1.10.1 at /usr/bin/ninja
Using 'PKG_CONFIG_PATH' from environment with value: '/usr/lib32/pkgconfig:/usr/lib/i386-linux-gnu/pkgconfig:/usr/lib/pkgconfig:'
Using 'PKG_CONFIG_PATH' from environment with value: '/usr/lib32/pkgconfig:/usr/lib/i386-linux-gnu/pkgconfig:/usr/lib/pkgconfig:'
The Meson build system
Version: 0.56.2
Source dir: /home/ubuntu/MangoHud
Build dir: /home/ubuntu/MangoHud/build/meson32
Build type: native build
Project name: MangoHud
Project version: v0.6.5
Using 'CC' from environment with value: 'gcc -m32'

meson.build:1:0: ERROR: Unable to detect GNU compiler type:
gcc: error: unrecognized command-line option ‘-m32’

A full log can be found at /home/ubuntu/MangoHud/build/meson32/meson-logs/meson-log.txt
ubuntu@ubuntu:~/MangoHud$

It appears that it's very x86 based? -m32 is the x86 arch, no?

TheComputerGuy96 commented 2 years ago

@archanox Unset the CC variable or set it to gcc

jackun commented 2 years ago

gcc: error: unrecognized command-line option ‘-m32’

Use develop branch, probably. It should run 32bit build just for X86 (unless I haven't pushed that yet).

jrtc27 commented 2 years ago

gcc: error: unrecognized command-line option ‘-m32’

Use develop branch, probably. It should run 32bit build just for X86 (unless I haven't pushed that yet).

It only runs the 32-bit build on x86_64, but unconditionally tries to install the multilib packages.

Not sure what the point of the build script is, anyway, seems like a waste of time that reinvents the wheel whilst also breaking things. There's a meson.build you can just use manually like any other normal project. The Debian packaging just uses that, for example, and then runs ninja in the build directory.

archanox commented 2 years ago

gcc: error: unrecognized command-line option ‘-m32’

Use develop branch, probably. It should run 32bit build just for X86 (unless I haven't pushed that yet).

So I switched to develop and got a bit further.

ubuntu@ubuntu:~/MangoHud$ ./build.sh clean
Command: clean 
ubuntu@ubuntu:~/MangoHud$ ./build.sh reinstall
Command: reinstall 
# Checking dependencies for "ubuntu"
# Missing dependencies:gcc-multilib g++-multilib 
Do you wish the script to install these packages? [y/N]
Continuing with missing dependencies
The Meson build system
Version: 0.56.2
Source dir: /home/ubuntu/MangoHud
Build dir: /home/ubuntu/MangoHud/build/meson64
Build type: native build
Project name: MangoHud
Project version: v0.6.5
C compiler for the host machine: ccache cc (gcc 10.3.0 "cc (Ubuntu 10.3.0-1ubuntu1) 10.3.0")
C linker for the host machine: cc ld.bfd 2.36.1
C++ compiler for the host machine: ccache c++ (gcc 10.3.0 "c++ (Ubuntu 10.3.0-1ubuntu1) 10.3.0")
C++ linker for the host machine: c++ ld.bfd 2.36.1
Host machine cpu family: riscv64
Host machine cpu: riscv64
Program python3 (mako) found: YES (/usr/bin/python3) modules: mako
Checking if "GCC atomic builtins" compiles: YES 
Checking if "Supports timespec_get" compiles: YES 
Checking for function "bswap32" : YES 
Checking for function "bswap64" : YES 
Checking for function "clz" : YES 
Checking for function "clzll" : YES 
Checking for function "ctz" : YES 
Checking for function "expect" : YES 
Checking for function "ffs" : YES 
Checking for function "ffsll" : YES 
Checking for function "popcount" : YES 
Checking for function "popcountll" : YES 
Checking for function "unreachable" : YES 
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Run-time dependency x11 found: YES 1.7.0
Dependency wayland-client skipped: feature with_wayland disabled
Run-time dependency dbus-1 found: YES 1.12.20
Run-time dependency libdrm found: YES 2.4.105
Dependency vulkan skipped: feature use_system_vulkan disabled
Run-time dependency threads found: YES
Compiler for C supports arguments -Werror=implicit-function-declaration: YES 
Compiler for C supports arguments -Werror=missing-prototypes: YES 
Compiler for C supports arguments -Werror=return-type: YES 
Compiler for C supports arguments -Werror=incompatible-pointer-types: YES 
Compiler for C supports arguments -fno-math-errno: YES 
Compiler for C supports arguments -fno-trapping-math: YES 
Compiler for C supports arguments -Qunused-arguments: NO 
Compiler for C supports arguments -Wmissing-field-initializers: YES 
Compiler for C supports arguments -Wformat-truncation: YES 
Compiler for C++ supports arguments -Werror=return-type: YES 
Compiler for C++ supports arguments -fno-math-errno: YES 
Compiler for C++ supports arguments -fno-trapping-math: YES 
Compiler for C++ supports arguments -Qunused-arguments: NO 
Compiler for C++ supports arguments -Wnon-virtual-dtor: YES 
Compiler for C++ supports arguments -Wmissing-field-initializers: YES 
Compiler for C++ supports arguments -Wformat-truncation: YES 
Compiler for C supports arguments -Woverride-init: YES 
Compiler for C supports arguments -Winitializer-overrides: NO 
Checking for function "dlopen" : NO 
Library dl found: YES
Checking for function "clock_gettime" : YES 
Downloading vulkan-headers source from https://github.com/KhronosGroup/Vulkan-Headers/archive/v1.2.158.tar.gz
Downloading file of unknown size.
Downloading vulkan-headers patch from https://wrapdb.mesonbuild.com/v2/vulkan-headers_1.2.158-2/get_patch
Download size: 1107
Downloading: ..........

|Executing subproject vulkan-headers method meson 
|
|Project name: vulkan-headers
|Project version: 1.2.158
|C compiler for the host machine: ccache cc (gcc 10.3.0 "cc (Ubuntu 10.3.0-1ubuntu1) 10.3.0")
|C linker for the host machine: cc ld.bfd 2.36.1
|Build targets in project: 1
|Subproject vulkan-headers finished.

Checking for size of "void*" : 8
Downloading imgui source from https://github.com/ocornut/imgui/archive/v1.81.tar.gz
Downloading file of unknown size.
Downloading imgui patch from https://wrapdb.mesonbuild.com/v2/imgui_1.81-1/get_patch
Download size: 1850
Downloading: ..........

|Executing subproject imgui method meson 
|
|Project name: imgui
|Project version: 1.81
|C++ compiler for the host machine: ccache c++ (gcc 10.3.0 "c++ (Ubuntu 10.3.0-1ubuntu1) 10.3.0")
|C++ linker for the host machine: c++ ld.bfd 2.36.1
|Library d3d9 skipped: feature dx9 disabled
|Library d3d10 skipped: feature dx10 disabled
|Library d3d11 skipped: feature dx11 disabled
|Library d3d12 skipped: feature dx12 disabled
|Library metal skipped: feature metal disabled
|Dependency glew skipped: feature opengl disabled
|Dependency vulkan skipped: feature vulkan disabled
|Dependency glfw3 skipped: feature glfw disabled
|Dependency sdl2 skipped: feature sdl2 disabled
|Dependency allegro5 skipped: feature allegro5 disabled
|Library marmalade skipped: feature marmalade disabled
|Build targets in project: 3
|Subproject imgui finished.

Library spdlog skipped: feature use_system_spdlog disabled
Downloading spdlog source from https://github.com/gabime/spdlog/archive/v1.8.5.tar.gz
Downloading file of unknown size.
Downloading spdlog patch from https://wrapdb.mesonbuild.com/v2/spdlog_1.8.5-1/get_patch
Download size: 2211
Downloading: ..........

|Executing subproject spdlog method meson 
|
|Project name: spdlog
|Project version: 1.8.5
|C++ compiler for the host machine: ccache c++ (gcc 10.3.0 "c++ (Ubuntu 10.3.0-1ubuntu1) 10.3.0")
|C++ linker for the host machine: c++ ld.bfd 2.36.1
|Dependency threads found: YES unknown (cached)
|Build targets in project: 4
|Subproject spdlog finished.

Program glslangValidator found: YES (/usr/local/bin/glslangValidator)
Has header "NVCtrl/NVCtrl.h" : YES 
Compiler for C supports link arguments -Wl,-Bsymbolic-functions: YES 
Compiler for C supports link arguments -Wl,-z,relro: YES 
Compiler for C supports link arguments -Wl,--exclude-libs,ALL: YES 
Configuring MangoHud.json using configuration
Configuring mangohud using configuration
Build targets in project: 8

MangoHud v0.6.5

  Subprojects
             imgui: YES
            spdlog: YES
    vulkan-headers: YES

Found ninja-1.10.1 at /usr/bin/ninja
ninja: Entering directory `build/meson64'
[11/62] Generating overlay.frag.spv.h with a custom command
FAILED: src/overlay.frag.spv.h 
/usr/local/bin/glslangValidator -V -x -o src/overlay.frag.spv.h ../../src/overlay.frag
/bin/sh: 1: /usr/local/bin/glslangValidator: Exec format error
[16/62] Compiling C++ object subprojec...dlog-1.8.5/src/libspdlog.a.p/fmt.cpp.o
ninja: build stopped: subcommand failed.
ubuntu@ubuntu:~/MangoHud$ 

Does MangoHud currently support platform other than x86/x64? Is there arm/aarch64 support? If so, I am curious how it's not working here for riscv64, but is there.

jackun commented 2 years ago

build.sh for compatibility with older steam run-times assumes it's being built on old Ubuntu image so it downloads x86 only upstream binary.

You need to compile https://github.com/KhronosGroup/glslang for riscv64 if it's not included in repo and if it actually does.

archanox commented 2 years ago

So, I would have replied sooner to say "but it's already installed". Which is true, but...

ubuntu@ubuntu:~/MangoHud$ file /usr/local/bin/glslangValidator
/usr/local/bin/glslangValidator: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=49ae2305d36a618210dff8ae45c3b1b083f68b47, not stripped

Embarrassingly, I'm not sure where that version came from. If it was from an apt package, this source, another source... Built from source, copied over the new elfs

ubuntu@ubuntu:~/vicecity$ file /usr/local/bin/glslangValidator
/usr/local/bin/glslangValidator: ELF 64-bit LSB pie executable, UCB RISC-V, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-riscv64-lp64d.so.1, BuildID[sha1]=f6ca8b7079b3236d4d26eb664052d4d3f08577ae, for GNU/Linux 4.15.0, not stripped

Anyway, back to the MangoHud build.

ubuntu@ubuntu:~/MangoHud$ ./build.sh build
Command: build 
ninja: Entering directory `build/meson64'
[1/45] Generating overlay.frag.spv.h with a custom command
../../src/overlay.frag
[2/45] Generating overlay.vert.spv.h with a custom command
../../src/overlay.vert
[44/45] Installing files.
Installing src/libMangoHud.so to /home/ubuntu/MangoHud/build/release/usr/lib/mangohud/lib64
Installing src/libMangoHud_dlsym.so to /home/ubuntu/MangoHud/build/release/usr/lib/mangohud/lib64
Installing /home/ubuntu/MangoHud/data/mangohud.1 to /home/ubuntu/MangoHud/build/release/usr/share/man/man1
Installing /home/ubuntu/MangoHud/build/meson64/src/MangoHud.json to /home/ubuntu/MangoHud/build/release/usr/share/vulkan/implicit_layer.d
Installing /home/ubuntu/MangoHud/build/meson64/src/mangohud to /home/ubuntu/MangoHud/build/release/usr/bin
Installing /home/ubuntu/MangoHud/src/../bin/MangoHud.conf to /home/ubuntu/MangoHud/build/release/usr/share/doc/mangohud

It finished, it worked. Let's try again.

ubuntu@ubuntu:~/vicecity$ mangohud --dlsym ./reVC
can't get libdl.so

Same thing. Double checked that I do indeed have libdl.so lurking somewhere...

ubuntu@ubuntu:~/vicecity$ file /usr/lib/riscv64-linux-gnu/libdl.so
/usr/lib/riscv64-linux-gnu/libdl.so: symbolic link to /lib/riscv64-linux-gnu/libdl.so.2
ubuntu@ubuntu:~/vicecity$ file /lib/riscv64-linux-gnu/libdl.so.2
/lib/riscv64-linux-gnu/libdl.so.2: symbolic link to libdl-2.33.so
ubuntu@ubuntu:~/vicecity$ file /lib/riscv64-linux-gnu/libdl-2.33.so 
/lib/riscv64-linux-gnu/libdl-2.33.so: ELF 64-bit LSB shared object, UCB RISC-V, version 1 (SYSV), dynamically linked, BuildID[sha1]=33f8bdbf7e4a1e62022939689a2c8b51d4216ab5, for GNU/Linux 4.15.0, stripped

So I suspect that somewhere, someone has done a hard reference to an x86 library, I'll see if I can dig up anything further.

jackun commented 2 years ago

Strange. That somewhere is https://github.com/flightlessmango/MangoHud/blob/d27f13fa888ca9eca392ea79d690df240d4985bb/src/real_dlsym.cpp#L23

and https://github.com/flightlessmango/MangoHud/blob/d27f13fa888ca9eca392ea79d690df240d4985bb/src/elfhacks.cpp#L118

archanox commented 2 years ago

I just took another look at the output of ./build.sh install and I'm seeing this

ubuntu@ubuntu:~/MangoHud$ ./build.sh install
Command: install 
ninja: Entering directory `build/meson64'
[1/2] Installing files.
Installing src/libMangoHud.so to /home/ubuntu/MangoHud/build/release/usr/lib/mangohud/lib64
Installing src/libMangoHud_dlsym.so to /home/ubuntu/MangoHud/build/release/usr/lib/mangohud/lib64
Installing /home/ubuntu/MangoHud/data/mangohud.1 to /home/ubuntu/MangoHud/build/release/usr/share/man/man1
Installing /home/ubuntu/MangoHud/build/meson64/src/MangoHud.json to /home/ubuntu/MangoHud/build/release/usr/share/vulkan/implicit_layer.d
Installing /home/ubuntu/MangoHud/build/meson64/src/mangohud to /home/ubuntu/MangoHud/build/release/usr/bin
Installing /home/ubuntu/MangoHud/src/../bin/MangoHud.conf to /home/ubuntu/MangoHud/build/release/usr/share/doc/mangohud
Command: install 
removed '/usr/lib/mangohud/lib'
removed '/usr/lib/mangohud/tls/x86_64'
removed '/usr/lib/mangohud/tls/i686'
removed directory '/usr/lib/mangohud/tls'
removed '/usr/lib/mangohud/lib64/libMangoHud.so'
removed '/usr/lib/mangohud/lib64/libMangoHud_dlsym.so'
removed '/usr/lib/mangohud/lib64/tls'
removed directory '/usr/lib/mangohud/lib64'
removed directory '/usr/lib/mangohud'
removed '/usr/share/doc/mangohud/MangoHud.conf.example'
removed directory '/usr/share/doc/mangohud'
removed '/usr/share/man/man1/mangohud.1'
DEFAULTLIB: lib64
/usr/bin/install: creating directory '/usr/lib/mangohud'
/usr/bin/install: creating directory '/usr/lib/mangohud/lib64'
'./build/release/usr/lib/mangohud/lib64/libMangoHud.so' -> '/usr/lib/mangohud/lib64/libMangoHud.so'
'./build/release/usr/lib/mangohud/lib64/libMangoHud_dlsym.so' -> '/usr/lib/mangohud/lib64/libMangoHud_dlsym.so'
/usr/bin/install: creating directory '/usr/share/vulkan/implicit_layer.d'
'./build/release/usr/share/vulkan/implicit_layer.d/MangoHud.json' -> '/usr/share/vulkan/implicit_layer.d/MangoHud.json'
removed '/usr/share/vulkan/implicit_layer.d/MangoHud.json'
'./build/release/usr/share/vulkan/implicit_layer.d/MangoHud.json' -> '/usr/share/vulkan/implicit_layer.d/MangoHud.json'
'./build/release/usr/share/man/man1/mangohud.1' -> '/usr/share/man/man1/mangohud.1'
/usr/bin/install: creating directory '/usr/share/doc/mangohud'
'./build/release/usr/share/doc/mangohud/MangoHud.conf.example' -> '/usr/share/doc/mangohud/MangoHud.conf.example'
'./build/release/usr/bin/mangohud' -> '/usr/bin/mangohud'
'/usr/lib/mangohud/lib' -> 'lib64'
'/usr/lib/mangohud/x86_64' -> 'lib64'
'/usr/lib/mangohud/x86_64-linux-gnu' -> 'lib64'
'/usr/lib/mangohud/lib64/x86_64' -> '.'
'/usr/lib/mangohud/lib64/x86_64-linux-gnu' -> '.'
'/usr/lib/mangohud/i686' -> 'lib32'
'/usr/lib/mangohud/i386-linux-gnu' -> 'lib32'
'/usr/lib/mangohud/i686-linux-gnu' -> 'lib32'
'/usr/lib/mangohud/tls/x86_64' -> '../lib64'
'/usr/lib/mangohud/tls/i686' -> '../lib32'
'/usr/lib/mangohud/lib/i386-linux-gnu' -> '../lib32'
'/usr/lib/mangohud/lib/i686-linux-gnu' -> '../lib32'
'/usr/lib/mangohud/lib/tls' -> '../tls'
MangoHud Installed

There's a lot of mention of i686/i386/x86_64 is this bueno?

I've been fiddling with the LD_PRELOAD env variable too, with no success.

ubuntu@ubuntu:~/vicecity$ export LD_PRELOAD=/home/ubuntu/MangoHud/build/release/usr/lib/
ubuntu@ubuntu:~/vicecity$ mangohud ./reVC
ERROR: ld.so: object '/home/ubuntu/MangoHud/build/release/usr/lib/' from LD_PRELOAD cannot be preloaded (cannot read file data): ignored.
ERROR: ld.so: object '/home/ubuntu/MangoHud/build/release/usr/lib/' from LD_PRELOAD cannot be preloaded (cannot read file data): ignored.
ERROR: ld.so: object '/usr/lib/mangohud/$LIB/libMangoHud_dlsym.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/mangohud/$LIB/libMangoHud.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/home/ubuntu/MangoHud/build/release/usr/lib/' from LD_PRELOAD cannot be preloaded (cannot read file data): ignored.
ERROR: ld.so: object '/usr/lib/mangohud/$LIB/libMangoHud_dlsym.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/mangohud/$LIB/libMangoHud.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

My gut feeling is that $LIB should not be there for starters, but I don't know why it says it cannot read the build location either.

EDIT: Have also tried the following to no avail

export LD_PRELOAD=/home/ubuntu/MangoHud/build/release/usr/lib/mangohud/lib64/
export LD_PRELOAD=/home/ubuntu/MangoHud/build/release/usr/lib/mangohud/lib64/libMangoHud.so
export LD_PRELOAD=/home/ubuntu/MangoHud/build/release/usr/lib/mangohud/

But honestly I have no idea what it's actually looking for here the README.md just says LD_PRELOAD=/path/to/mangohud/lib/. But in the error output it mentions individual libraries.

jackun commented 2 years ago

It's fine, just assumes x86 but shows you should probably use meson directly so it picks up correct libdir (/usr/lib/riscv64-linux-gnu). Basic meson build --prefix /usr -Dappend_libdir_mangohud=false && ninja -C build install is probably enough.

$LIB gets automagically changed to lib/riscv64-linux-gnu (maybe without lib/?) by dynamic linker.

archanox commented 2 years ago

It looks like I'm straying further from the light...

ubuntu@ubuntu:~/MangoHud$ ./build.sh uninstall
Command: uninstall 
Command: uninstall 
removed directory '/usr/lib/mangohud'
removed '/usr/share/doc/mangohud/MangoHud.conf.example'
removed directory '/usr/share/doc/mangohud'
removed '/usr/share/man/man1/mangohud.1'
removed '/usr/share/vulkan/implicit_layer.d/MangoHud.json'
removed '/usr/bin/mangohud'
ubuntu@ubuntu:~/MangoHud$ mangohud 
bash: /usr/bin/mangohud: No such file or directory
ubuntu@ubuntu:~/MangoHud$ meson build --prefix /usr -Dappend_libdir_mangohud=false && ninja -C build install
Directory already configured.

Just run your build command (e.g. ninja) and Meson will regenerate as necessary.
If ninja fails, run "ninja reconfigure" or "meson --reconfigure"
to force Meson to regenerate.

If build failures persist, run "meson setup --wipe" to rebuild from scratch
using the same options as passed when configuring the build.
To change option values, run "meson configure" instead.
ninja: Entering directory `build'
[1/2] Installing files.
Installation failed due to insufficient permissions.
Attempting to use polkit to gain elevated privileges...
Installing src/libMangoHud.so to /usr/lib/riscv64-linux-gnu
Installing src/libMangoHud_dlsym.so to /usr/lib/riscv64-linux-gnu
Installing /home/ubuntu/MangoHud/data/mangohud.1 to /usr/share/man/man1
Installing /home/ubuntu/MangoHud/build/src/MangoHud.json to /usr/share/vulkan/implicit_layer.d
Installing /home/ubuntu/MangoHud/build/src/mangohud to /usr/bin
Installing /home/ubuntu/MangoHud/src/../bin/MangoHud.conf to /usr/share/doc/mangohud
ubuntu@ubuntu:~/MangoHud$ mangohud 
ERROR: No program supplied

Usage: mangohud <program>
ubuntu@ubuntu:~/MangoHud$ cd ~/vicecity/
ubuntu@ubuntu:~/vicecity$ mangohud --dlsym ./reVC
can't get libdl.so
ubuntu@ubuntu:~/vicecity$ 

1 step forward, 2 steps back?

$LIB gets automagically changed to lib/riscv64-linux-gnu (maybe without lib/?) by dynamic linker.

I'd expect that too, but I don't know if it's actually being populated correctly?

jackun commented 2 years ago

eh_init_obj might be failing https://github.com/flightlessmango/MangoHud/blob/d27f13fa888ca9eca392ea79d690df240d4985bb/src/elfhacks.cpp#L152

But there's a workaround to use dlvsym instead of elfhacks to get "untainted" dlsym https://github.com/anholt/libepoxy/blob/71dcab0cc9accb322771fa8587241ee63fb76dd0/test/dlwrap.c#L214

archanox commented 2 years ago

eh_init_obj might be failing https://github.com/flightlessmango/MangoHud/blob/d27f13fa888ca9eca392ea79d690df240d4985bb/src/elfhacks.cpp#L152

But there's a workaround to use dlvsym instead of elfhacks to get "untainted" dlsym https://github.com/anholt/libepoxy/blob/71dcab0cc9accb322771fa8587241ee63fb76dd0/test/dlwrap.c#L214

Unfortunately I don't know how to approach resolving this issue I'm afraid. Does this issue now get closed with WONTFIX?