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.42k stars 286 forks source link

help required - crosscompiling to armhf from arm64 #983

Closed neofeo closed 1 year ago

neofeo commented 1 year ago

HI, I am trying to crosscompile this project like this

ARCH=armhf CC=/usr/bin/arm-linux-gnueabihf-gcc CXX=/usr/bin/arm-linux-gnueabihf-g++ PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig  meson build32  --libdir armhf  -Dwith_wayland=enabled -Dwith_xnvctrl=disabled

it does compile, but its linking everything to arm64 and bc of that fails at the end. How the hell I need to do to force it to look to armhf libraries instead?

flightlessmango commented 1 year ago

Does it help to use meson cross file? https://mesonbuild.com/Cross-compilation.html

neofeo commented 1 year ago

trying mybest @flightlessmango

rock-5b:MangoHud:% meson armhf --cross-file=/home/salva/cross_file_armhf.txt  --libdir armhf  -Dwith_wayland=enabled -Dwith_xnvctrl=disabled                                                              <master>
The Meson build system
Version: 0.61.2
Source dir: /home/salva/DEV/MangoHud
Build dir: /home/salva/DEV/MangoHud/armhf
Build type: cross build
Project name: MangoHud
Project version: v0.6.8
C compiler for the host machine: arm-linux-gnueabihf-gcc (gcc 11.3.0 "arm-linux-gnueabihf-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0")
C linker for the host machine: arm-linux-gnueabihf-gcc ld.bfd 2.38
C++ compiler for the host machine: arm-linux-gnueabihf-g++ (gcc 11.3.0 "arm-linux-gnueabihf-g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0")
C++ linker for the host machine: arm-linux-gnueabihf-g++ ld.bfd 2.38
C compiler for the build machine: cc (gcc 11.3.0 "cc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0")
C linker for the build machine: cc ld.bfd 2.38
C++ compiler for the build machine: c++ (gcc 11.3.0 "c++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0")
C++ linker for the build machine: c++ ld.bfd 2.38
Build machine cpu family: aarch64
Build machine cpu: aarch64
Host machine cpu family: arm
Host machine cpu: armv7
Target machine cpu family: arm
Target machine cpu: armv7
Program python3 (mako) found: YES (/usr/bin/python3) modules: mako
WARNING: Python files installed by Meson might not be found by python interpreter.
 This warning can be avoided by setting "python.platlibdir" option.
WARNING: Python files installed by Meson might not be found by python interpreter.
 This warning can be avoided by setting "python.purelibdir" option.
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.5
Run-time dependency wayland-client found: YES 1.20.0
Run-time dependency dbus-1 found: YES 1.12.20
Run-time dependency threads found: YES
Compiler for C supports arguments -Werror=implicit-function-declaration: YES 
Compiler for C supports arguments -Werror=missing-declarations: 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 -Wno-unused-parameter: YES 
Compiler for C supports arguments -Qunused-arguments: NO 
Compiler for C supports arguments -fno-math-errno: YES 
Compiler for C supports arguments -fno-trapping-math: YES 
Compiler for C supports arguments -Wno-missing-field-initializers: YES 
Compiler for C++ supports arguments -Werror=missing-declarations: YES 
Compiler for C++ supports arguments -Werror=return-type: YES 
Compiler for C++ supports arguments -Wno-unused-parameter: YES 
Compiler for C++ supports arguments -Qunused-arguments: NO 
Compiler for C++ supports arguments -fno-math-errno: YES 
Compiler for C++ supports arguments -fno-trapping-math: YES 
Compiler for C++ supports arguments -Wno-non-virtual-dtor: YES 
Compiler for C++ supports arguments -Wno-missing-field-initializers: YES 
Checking for function "dlopen" : YES 
Checking for function "clock_gettime" : YES 

Executing subproject vulkan-headers 

vulkan-headers| Project name: vulkan-headers
vulkan-headers| Project version: 1.2.158
vulkan-headers| C compiler for the host machine: arm-linux-gnueabihf-gcc (gcc 11.3.0 "arm-linux-gnueabihf-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0")
vulkan-headers| C linker for the host machine: arm-linux-gnueabihf-gcc ld.bfd 2.38
vulkan-headers| C compiler for the build machine: cc (gcc 11.3.0 "cc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0")
vulkan-headers| C linker for the build machine: cc ld.bfd 2.38
vulkan-headers| Build targets in project: 1
vulkan-headers| Subproject vulkan-headers finished.

Checking for size of "void*" : 4

Executing subproject imgui 

imgui| Project name: imgui
imgui| Project version: 1.81
imgui| C++ compiler for the host machine: arm-linux-gnueabihf-g++ (gcc 11.3.0 "arm-linux-gnueabihf-g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0")
imgui| C++ linker for the host machine: arm-linux-gnueabihf-g++ ld.bfd 2.38
imgui| C++ compiler for the build machine: c++ (gcc 11.3.0 "c++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0")
imgui| C++ linker for the build machine: c++ ld.bfd 2.38
imgui| Library d3d9 skipped: feature dx9 disabled
imgui| Library d3d10 skipped: feature dx10 disabled
imgui| Library d3d11 skipped: feature dx11 disabled
imgui| Library d3d12 skipped: feature dx12 disabled
imgui| Library metal skipped: feature metal disabled
imgui| Dependency glew skipped: feature opengl disabled
imgui| Dependency vulkan skipped: feature vulkan disabled
imgui| Dependency glfw3 skipped: feature glfw disabled
imgui| Dependency sdl2 skipped: feature sdl2 disabled
imgui| Dependency allegro5 skipped: feature allegro5 disabled
imgui| Library marmalade skipped: feature marmalade disabled
imgui| Build targets in project: 3
imgui| Subproject imgui finished.

Library spdlog skipped: feature use_system_spdlog disabled

Executing subproject spdlog 

spdlog| Project name: spdlog
spdlog| Project version: 1.8.5
spdlog| C++ compiler for the host machine: arm-linux-gnueabihf-g++ (gcc 11.3.0 "arm-linux-gnueabihf-g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0")
spdlog| C++ linker for the host machine: arm-linux-gnueabihf-g++ ld.bfd 2.38
spdlog| C++ compiler for the build machine: c++ (gcc 11.3.0 "c++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0")
spdlog| C++ linker for the build machine: c++ ld.bfd 2.38
spdlog| Dependency threads found: YES unknown (cached)
spdlog| Build targets in project: 4
spdlog| Subproject spdlog finished.

Found CMake: NO
Run-time dependency nlohmann_json found: NO (tried pkgconfig and cmake)
Looking for a fallback subproject for the dependency nlohmann_json

Executing subproject nlohmann_json 

nlohmann_json| Project name: nlohmann_json
nlohmann_json| Project version: 3.10.5
nlohmann_json| C++ compiler for the host machine: arm-linux-gnueabihf-g++ (gcc 11.3.0 "arm-linux-gnueabihf-g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0")
nlohmann_json| C++ linker for the host machine: arm-linux-gnueabihf-g++ ld.bfd 2.38
nlohmann_json| C++ compiler for the build machine: c++ (gcc 11.3.0 "c++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0")
nlohmann_json| C++ linker for the build machine: c++ ld.bfd 2.38
nlohmann_json| Build targets in project: 4
nlohmann_json| Subproject nlohmann_json finished.

Dependency nlohmann_json from subproject subprojects/nlohmann_json-3.10.5 found: YES 3.10.5
Program glslangValidator found: YES (/usr/local/bin/glslangValidator)
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 
Compiler for C supports link arguments -lGL: YES 
WARNING: extract_all_objects called without setting recursive
keyword argument. Meson currently defaults to
non-recursive to maintain backward compatibility but
the default will be changed in the future.

Configuring MangoHud.arm.json using configuration
Configuring mangohud using configuration
Program appstreamcli found: NO
Build targets in project: 9

MangoHud v0.6.8

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

  User defined options
    Cross files   : /home/salva/cross_file_armhf.txt
    libdir        : armhf
    with_wayland  : enabled
    with_xnvctrl  : disabled

my config file

[binaries]
c = 'arm-linux-gnueabihf-gcc'
cpp = 'arm-linux-gnueabihf-g++'
ar = 'arm-linux-gnueabihf-ar'
strip = 'arm-linux-gnueabihf-strip'
objcopy = 'arm-linux-gnueabihf-objcopy'
pkgconfig = 'pkg-config'

[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'armv7'
endian = 'little'

[properties]
sys_lib_paths = ['/usr/lib/arm-linux-gnueabihf/']
link_args = ['-L/usr/lib/arm-linux-gnueabihf/', '-llibwayland-client']

is stills tries to link with arm64 libs...

neofeo commented 1 year ago

Ahh, maybe pkg config has to be addresed differently. Hopefully you can give me a hint.

flightlessmango commented 1 year ago

I don't think you can use the normal pkg-config, it would need to be the one for the architecture you want to compile

neofeo commented 1 year ago

even with armhf pkgconfig it doesnt work. super difficult to setup it seems. sadly, there is no deb i can found with wayland enabled. debian repo and ubuntu repo do not work

neofeo commented 1 year ago

/usr/bin/arm-linux-gnueabihf-pkg-config --variable pc_path pkg-config outputs /usr/local/lib/aarch64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig super wrong then, it doesnt find any armhf package required for mangohud, I am unable to export the right path, but even then , armhf pkgconfig at /usr/lib/arm.../pkgconfig/ doesnt have the client wayland .pc

super confusing. there is any repo with armhf builds with wayland enable you can recommend?

neofeo commented 1 year ago

Ok,I made some horriblr hacks that eventually make it to work. Not proud, but enough:)