Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build issues for LLVM based toolchains. #1513

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/mangohud.version
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,5 @@
global:
overlay_GetInstanceProcAddr;
overlay_GetDeviceProcAddr;
glX*;
egl*;
dlsym;
mangohud_find_glx_ptr;
mangohud_find_egl_ptr;
local: *;
};
6 changes: 6 additions & 0 deletions src/mangohud_opengl.version.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
global:
@x11_symbols@
@wayland_symbols@
local: *;
};
104 changes: 67 additions & 37 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,23 @@ if is_unixy
endif
endif

link_args = cc.get_supported_link_arguments(['-Wl,-Bsymbolic-functions', '-Wl,-z,relro', '-Wl,--exclude-libs,ALL', '-lGL', '-static-libstdc++'])
# meson fails to check version-script so just force add
link_args += '-Wl,--version-script,@0@'.format(join_paths(meson.current_source_dir(), 'mangohud.version'))
link_args = cpp.get_supported_link_arguments(['-Wl,-Bsymbolic-functions', '-Wl,-z,relro', '-Wl,--exclude-libs,ALL', '-lGL'])

# Approach for libc++ detection taken from https://github.com/mesonbuild/meson/commit/675b47b0692131fae974298829ba807d730ab098
# Rationale for the approach is explained in this SO answer https://stackoverflow.com/a/31658120
if cpp.has_header('<version>')
header = 'version'
else
header = 'ciso646'
endif
is_libcxx = cpp.has_header_symbol(header, '_LIBCPP_VERSION')

# https://github.com/llvm/llvm-project/issues/38622
if is_libcxx
message('Detected libcxx, not appending -static-libstc++ to linker arguments')
else
link_args+=['-static-libstdc++']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flightlessmango can't this be left for packagers / users to add with meson with -D cpp_link_args when/if needed ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a case where its enabled by default and you have to disable it yourself for the cases where its not desirable (libcxx / no static libstdc++ available).

endif

mangohud_static_lib = static_library(
'MangoHud',
Expand Down Expand Up @@ -211,44 +225,60 @@ mangohud_shared_lib = shared_library(
'MangoHud',
objects: mangohud_static_lib.extract_all_objects(),
link_with: mangohud_static_lib,
link_args : link_args,
link_args : [link_args, '-Wl,--version-script,@0@'.format(join_paths(meson.current_source_dir(), 'mangohud.version'))],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot of duplication, should probably be a variable

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about how to do that nicer, I have unique files for all libs and mangohub_opengl uses a different directory as its generated at build time.

Could also break it into several lines like in the example given in this meson issue about improving mesons handling for these.

mesonbuild/meson#3047

install_dir : libdir_mangohud,
install: true
)

mangohud_opengl_shared_lib = shared_library(
'MangoHud_opengl',
mangohud_version,
opengl_files,
vklayer_files,
util_files,
c_args : [
pre_args,
vulkan_wsi_args
],
cpp_args : [
pre_args,
vulkan_wsi_args
],
dependencies : [
mangohud_version_dep,
vulkan_wsi_deps,
dearimgui_dep,
spdlog_dep,
dbus_dep,
dep_dl,
dep_rt,
dep_pthread,
dep_vulkan,
windows_deps,
json_dep,
implot_dep],
include_directories : [inc_common],
link_args : link_args,
link_with: mangohud_static_lib,
install_dir : libdir_mangohud,
install: true
)
if is_unixy
mangohud_opengl_syms = configuration_data()
if get_option('with_x11').enabled()
mangohud_opengl_syms.set('x11_symbols', 'glX*; mangohud_find_glx_ptr;')
endif
if get_option('with_wayland').enabled()
mangohud_opengl_syms.set('wayland_symbols', 'egl*; mangohud_find_egl_ptr;')
endif

mangohud_opengl_version_file = configure_file(
input: 'mangohud_opengl.version.in',
output: 'mangohud_opengl.version',
configuration: mangohud_opengl_syms,
)

mangohud_opengl_shared_lib = shared_library(
'MangoHud_opengl',
mangohud_version,
opengl_files,
vklayer_files,
util_files,
c_args : [
pre_args,
vulkan_wsi_args
],
cpp_args : [
pre_args,
vulkan_wsi_args
],
dependencies : [
mangohud_version_dep,
vulkan_wsi_deps,
dearimgui_dep,
spdlog_dep,
dbus_dep,
dep_dl,
dep_rt,
dep_pthread,
dep_vulkan,
json_dep,
implot_dep],
include_directories : [inc_common],
link_args : [link_args, '-Wl,--version-script,@0@'.format(join_paths(meson.current_build_dir(), 'mangohud_opengl.version'))],
link_with: mangohud_static_lib,
link_depends: mangohud_opengl_version_file,
install_dir : libdir_mangohud,
install: true
)
endif

if get_option('mangoapp')
if not get_option('with_x11').enabled()
Expand Down
6 changes: 4 additions & 2 deletions tests/test_amdgpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
#include <stddef.h>
#include <setjmp.h>
#include <stdint.h>
#include "stdio.h"
#include "../src/amdgpu.h"
// cmocka and libc++ have clashing symbols which causes issues if the symbols
// are defined before libc++ can hide its own with _LIBCPP_HIDE_FROM_ABI.
extern "C" {
#include <cmocka.h>
}
#include "stdio.h"
#include "../src/amdgpu.h"

#define UNUSED(x) (void)(x)

Expand Down