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

5.264.0: linking fails on missing GetDefaultResources symbol #165

Open
kloczek opened this issue Mar 22, 2023 · 12 comments
Open

5.264.0: linking fails on missing GetDefaultResources symbol #165

kloczek opened this issue Mar 22, 2023 · 12 comments

Comments

@kloczek
Copy link

kloczek commented Mar 22, 2023

Something is wromg and I cannot figure out what exactly

[1/5] Generating src/version.h with a custom command
fatal: not a git repository (or any parent up to mount point /home/tkloczko)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
[2/4] Linking target src/libplacebo.so.264
FAILED: src/libplacebo.so.264
/usr/bin/g++  -o src/libplacebo.so.264 src/libplacebo.so.264.p/meson-generated_.._vulkan_utils_gen.c.o src/libplacebo.so.264.p/colorspace.c.o src/libplacebo.so.264.p/common.c.o src/libplacebo.so.264.p/dither.c.o src/libplacebo.so.264.p/dispatch.c.o src/libplacebo.so.264.p/dummy.c.o src/libplacebo.so.264.p/filters.c.o src/libplacebo.so.264.p/format.c.o src/libplacebo.so.264.p/glsl_spirv.c.o src/libplacebo.so.264.p/gpu.c.o src/libplacebo.so.264.p/gpu_utils.c.o src/libplacebo.so.264.p/log.c.o src/libplacebo.so.264.p/pl_alloc.c.o src/libplacebo.so.264.p/pl_string.c.o src/libplacebo.so.264.p/renderer.c.o src/libplacebo.so.264.p/siphash.c.o src/libplacebo.so.264.p/shaders.c.o src/libplacebo.so.264.p/shaders_colorspace.c.o src/libplacebo.so.264.p/shaders_custom.c.o src/libplacebo.so.264.p/shaders_custom_mpv.c.o src/libplacebo.so.264.p/shaders_deinterlacing.c.o src/libplacebo.so.264.p/shaders_dithering.c.o src/libplacebo.so.264.p/shaders_film_grain.c.o src/libplacebo.so.264.p/shaders_film_grain_av1.c.o src/libplacebo.so.264.p/shaders_film_grain_h274.c.o src/libplacebo.so.264.p/shaders_icc.c.o src/libplacebo.so.264.p/shaders_lut.c.o src/libplacebo.so.264.p/shaders_sampling.c.o src/libplacebo.so.264.p/swapchain.c.o src/libplacebo.so.264.p/tone_mapping.c.o src/libplacebo.so.264.p/utils_dolbyvision.c.o src/libplacebo.so.264.p/utils_frame_queue.c.o src/libplacebo.so.264.p/utils_upload.c.o src/libplacebo.so.264.p/glsl_spirv_shaderc.c.o src/libplacebo.so.264.p/glsl_glslang.cc.o src/libplacebo.so.264.p/glsl_glslang_resources.c.o src/libplacebo.so.264.p/glsl_spirv_glslang.c.o src/libplacebo.so.264.p/opengl_context.c.o src/libplacebo.so.264.p/opengl_formats.c.o src/libplacebo.so.264.p/opengl_loader_gl.c.o src/libplacebo.so.264.p/opengl_loader_egl.c.o src/libplacebo.so.264.p/opengl_gpu.c.o src/libplacebo.so.264.p/opengl_gpu_tex.c.o src/libplacebo.so.264.p/opengl_gpu_pass.c.o src/libplacebo.so.264.p/opengl_swapchain.c.o src/libplacebo.so.264.p/opengl_utils.c.o src/libplacebo.so.264.p/vulkan_command.c.o src/libplacebo.so.264.p/vulkan_context.c.o src/libplacebo.so.264.p/vulkan_formats.c.o src/libplacebo.so.264.p/vulkan_gpu.c.o src/libplacebo.so.264.p/vulkan_gpu_buf.c.o src/libplacebo.so.264.p/vulkan_gpu_tex.c.o src/libplacebo.so.264.p/vulkan_gpu_pass.c.o src/libplacebo.so.264.p/vulkan_malloc.c.o src/libplacebo.so.264.p/vulkan_swapchain.c.o src/libplacebo.so.264.p/vulkan_utils.c.o -Wl,--as-needed -Wl,--no-undefined -shared -fPIC -Wl,--start-group -Wl,-soname,libplacebo.so.264 -Wl,--as-needed -Wl,--gc-sections -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -flto=auto -flto-partition=none -fuse-linker-plugin -Wl,--build-id=sha1 -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -Wl,--exclude-libs=ALL -lm -pthread /usr/lib64/libshaderc_shared.so -lglslang-default-resource-limits /usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/libSPIRV.a /usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/libMachineIndependent.a /usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/libOSDependent.a /usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/libOGLCompiler.a /usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/libGenericCodeGen.a -ldl /usr/lib64/libvulkan.so /usr/lib64/liblcms2.so -Wl,--end-group
/usr/bin/ld: /tmp/ccOEIkUM.lto.o: in function `pl_glslang_compile':
/home/tkloczko/rpmbuild/BUILD/libplacebo-5.264.0/x86_64-redhat-linux-gnu/../src/glsl/glslang.cc:85: undefined reference to `GetDefaultResources()'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

In meson output are contradicting lines

+ /usr/bin/meson setup --buildtype=plain --prefix=/usr --libdir=/usr/lib64 --libexecdir=/usr/libexec --bindir=/usr/bin --sbindir=/usr/sbin --includedir=/usr/include --datadir=/usr/share --mandir=/usr/share/man --infodir=/usr/share/info --localedir=/usr/share/locale --sysconfdir=/etc --localstatedir=/var --sharedstatedir=/var/lib --wrap-mode=nodownload --auto-features=enabled . x86_64-redhat-linux-gnu -D d3d11=disabled -D dovi=disabled -D glslang=enabled -D lcms=enabled -D libdovi=disabled -D opengl=enabled -D shaderc=enabled -D unwind=disabled -D vulkan=enabled
The Meson build system
Version: 1.0.1
Source dir: /home/tkloczko/rpmbuild/BUILD/libplacebo-5.264.0
Build dir: /home/tkloczko/rpmbuild/BUILD/libplacebo-5.264.0/x86_64-redhat-linux-gnu
Build type: native build
Project name: libplacebo
Project version: 5.264.0
C compiler for the host machine: /usr/bin/gcc (gcc 13.0.1 "gcc (GCC) 13.0.1 20230318 (Red Hat 13.0.1-0)")
C linker for the host machine: /usr/bin/gcc ld.bfd 2.40-2
C++ compiler for the host machine: /usr/bin/g++ (gcc 13.0.1 "g++ (GCC) 13.0.1 20230318 (Red Hat 13.0.1-0)")
C++ linker for the host machine: /usr/bin/g++ ld.bfd 2.40-2
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C supports arguments -Wincompatible-pointer-types: YES
Compiler for C supports link arguments -Wl,--exclude-libs=ALL: YES
Library m found: YES
Program python3 found: YES (/usr/bin/python3)
Run-time dependency threads found: YES
Header "pthread.h" has symbol "pthread_condattr_setclock" with dependency threads: YES
Dependency libunwind skipped: feature unwind disabled
Library execinfo found: NO
Checking for function "backtrace_symbols" with dependency -lexecinfo: YES
Found pkg-config: /usr/bin/pkg-config (1.9.4)
Run-time dependency shaderc found: YES 2022.2.1
Library glslang-default-resource-limits found: YES
Library SPIRV found: NO                                                          <== HERE
Library SPIRV found: YES                                                          <== HERE
Library MachineIndependent found: YES
Library OSDependent found: YES
Library OGLCompiler found: YES
Library GenericCodeGen found: YES
Library SPIRV-Tools found: NO
Library SPIRV-Tools-opt found: NO
Has header "glslang/build_info.h" : YES
Check usable header "d3d11.h" : NO
Check usable header "d3d11_4.h" skipped: feature d3d11 disabled
Check usable header "dxgi1_6.h" skipped: feature d3d11 disabled
Dependency spirv-cross-c-shared skipped: feature d3d11 disabled
Library version skipped: feature d3d11 disabled
Library dl found: YES
Run-time dependency vulkan found: YES 1.3.239
Run-time dependency lcms2 found: YES 2.14
Dependency dovi skipped: feature libdovi disabled
Configuring config.h using configuration
Configuring config_internal.h using configuration
Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency glfw3 found: NO (tried pkgconfig and cmake)
sdl2-config found: NO
Run-time dependency sdl2 found: NO (tried pkgconfig and config-tool)
Run-time dependency sdl2_image found: NO (tried pkgconfig and cmake)
Dependency threads found: YES unknown (cached)
Run-time dependency libavcodec found: YES 60.3.100
Run-time dependency libavformat found: YES 60.3.100
Run-time dependency libavutil found: YES 58.2.100
Has header "nuklear.h" : NO
demos/meson.build:32: WARNING: Nuklear was not found in `demos/3rdparty`. Please run `git submodule update --init` followed by `meson --wipe`.
Check usable header "EGL/egl.h" : YES
Configuring config_demos.h using configuration
demos/meson.build:98: WARNING: Demos enabled but no supported combination of windowing system and graphical APIs was found. Demo programs require either GLFW or SDL and either Vulkan or OpenGL to function.
Build targets in project: 5

libplacebo 5.264.0

  Optional features
    d3d11         : NO
    dovi          : NO
    gl-proc-addr  : YES
    glslang       : YES
    lcms          : YES
    libdovi       : NO
    opengl        : YES
    shaderc       : YES
    vk-proc-addr  : YES
    vulkan        : YES

  User defined options
    auto_features : enabled
    bindir        : /usr/bin
    buildtype     : plain
    datadir       : /usr/share
    includedir    : /usr/include
    infodir       : /usr/share/info
    libdir        : /usr/lib64
    libexecdir    : /usr/libexec
    localedir     : /usr/share/locale
    localstatedir : /var
    mandir        : /usr/share/man
    prefix        : /usr
    sbindir       : /usr/sbin
    sharedstatedir: /var/lib
    sysconfdir    : /etc
    wrap_mode     : nodownload
    d3d11         : disabled
    dovi          : disabled
    glslang       : enabled
    lcms          : enabled
    libdovi       : disabled
    opengl        : enabled
    shaderc       : enabled
    unwind        : disabled
    vulkan        : enabled

Found ninja-1.11.1 at /usr/bin/ninja
+ /usr/bin/meson compile -C x86_64-redhat-linux-gnu -j 48 --verbose
@haasn
Copy link
Owner

haasn commented Mar 23, 2023

Library glslang-default-resource-limits found: YES

This is the library that this symbol should be defined in..

@kloczek
Copy link
Author

kloczek commented Mar 23, 2023

Hmm ..

[tkloczko@pers-jacek glsl]$ objdump -x /usr/lib64/libglslang-default-resource-limits.a | grep GetDefaultResources
 25 .gnu.lto__Z19GetDefaultResourcesv.513.ebda98ceefa8c670 00000122  0000000000000000  0000000000000000  00006c54  2**0

@kloczek
Copy link
Author

kloczek commented Mar 23, 2023

Just in case I'm using glslang 1.3.239.0.

@haasn
Copy link
Owner

haasn commented Mar 23, 2023

.gnu.lto

Try setting -Db_lto=true in your libplacebo build, does that make it work?

@haasn
Copy link
Owner

haasn commented Mar 23, 2023

https://stackoverflow.com/questions/27372667/undefined-reference-cross-compiling-static-libraries-with-lto-under-gcc

Seems to be the same issue, possibly - I think your build of glslang is broken, whence did you obtain it?

@kloczek
Copy link
Author

kloczek commented Mar 23, 2023

I'm building with LTO everytjong by building with set of env variables and you can see in LTO options in linkiging command

[tkloczko@pers-jacek SPECS]$ rpm -E %set_build_flags

ASMFLAGS="-O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none";
CFLAGS="-O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none";
CXXFLAGS="-O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none";
FFLAGS="-O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -I/usr/lib64/gfortran/modules";
FCFLAGS="-O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -I/usr/lib64/gfortran/modules";
LDFLAGS="-Wl,--as-needed -Wl,--gc-sections -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -flto=auto -flto-partition=none -fuse-linker-plugin -Wl,--build-id=sha1";
VALAFLAGS="${VALAFLAGS:--g}" ; export VALAFLAGS ;
CC="/usr/bin/gcc"; CXX="/usr/bin/g++"; FC="/usr/bin/gfortran";
AR="/usr/bin/gcc-ar"; NM="/usr/bin/gcc-nm"; RANLIB="/usr/bin/gcc-ranlib";
export ASMFLAGS CFLAGS CXXFLAGS FFLAGS FCFLAGS LDFLAGS VALAFLAGS CC CXX FC AR NM RANLIB;

@haasn
Copy link
Owner

haasn commented Mar 23, 2023

Ah, I see. Then it might even be a GCC bug? Maybe you can try using a dynamically linked build of glslang instead?

@kasper93
Copy link
Contributor

kasper93 commented Mar 24, 2023

In meson output are contradicting lines
Library SPIRV found: NO <== HERE
Library SPIRV found: YES <== HERE

Don't worry about it, works as expected. Due to meson limitation (mesonbuild/meson#8232) with libraries that has only cmake configuration, we manually search those libraries and to support prefer_static it is done twice, if first choice were not found. In your cases shared library were not found, but static were and this is used. All good.

GCC LTO objects have very limited compatibility so you should always use -ffat-lto-objects if you install lto build static libraries. This allows to use them with other compilers and/or without lto.

From quick look at the commands you posted I don't see anything wrong. If both are build with the same compiler version, it should be fine. I might try to repro tomorrow, but I really doubt there is an issue on libplacebo side.

Could you try this minimal case, to see if it works for you?
g++ t.cc -lglslang-default-resource-limits (add -I -L if needed)

#include <glslang/Public/ResourceLimits.h>

int main() {
    const TBuiltInResource *res = GetDefaultResources();
    return res->maxLights;
}

@kloczek
Copy link
Author

kloczek commented Apr 8, 2023

OK I made that test

[tkloczko@pers-jacek SPECS]$ g++ t.cc -lglslang-default-resource-limits
/usr/bin/ld: /tmp/ccncLepp.o: in function `main':
t.cc:(.text+0x9): undefined reference to `GetDefaultResources()'
collect2: error: ld returned 1 exit status

After rebuild glslang with -ffat-lto-objects in CXXFLAGS

[tkloczko@pers-jacek SPECS]$ g++ t.cc -lglslang-default-resource-limits
/usr/bin/ld: /tmp/ccE1rSpu.ltrans0.ltrans.o:(.debug_info+0x2f): undefined reference to `ResourceLimits.cpp.31915807'
/usr/bin/ld: /tmp/ccE1rSpu.ltrans0.ltrans.o:(.debug_info+0x46): undefined reference to `ResourceLimits.cpp.31915807'
collect2: error: ld returned 1 exit status

Hmm .. so what I ssuppose to do in that situation? 🤔

@haasn
Copy link
Owner

haasn commented Oct 3, 2023

IS this still an issue?

@Ashbd9
Copy link

Ashbd9 commented Nov 12, 2023

It works if you do CXXFLAGS=-lglslang-default-resource-limits meson setup .. &&ninja. Otherwise I get the same error.

@kloczek
Copy link
Author

kloczek commented Nov 12, 2023

Adding library to link with to C++ compile option looks like deeper problem in meson files.
If some library is missing on linking

  • it should be passed over $LIBS.
  • detection of that library should be added to the meson files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants