radeonsi has an unchecked hard dependency on libelf
src/amd/common/meson.build
includes ac_rtld
in the build only if libelf
is available, and silently continues the setup if it's missing:
if dep_elf.found()
amd_common_files += files(
'ac_rtld.c',
'ac_rtld.h',
'ac_rgp_elf_object_pack.c',
)
endif
However, several files in radeonsi make unconditional use of it:
$ git grep -l ac_rtld src/gallium/drivers/radeonsi/si_*
src/gallium/drivers/radeonsi/si_compute.c
src/gallium/drivers/radeonsi/si_debug.c
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_shader_llvm.c
src/gallium/drivers/radeonsi/si_state_draw.cpp
This results in a bunch of link errors like these:
mold: error: undefined symbol: ac_rtld_open
>>> referenced by si_compute.c
>>> src/gallium/drivers/radeonsi/libradeonsi.a(src/gallium/drivers/radeonsi/libradeonsi.a.p/si_compute.c.o):(si_compute_get_code_object)>>> referenced by si_debug.c
>>> src/gallium/drivers/radeonsi/libradeonsi.a(src/gallium/drivers/radeonsi/libradeonsi.a.p/si_debug.c.o):(si_add_split_disasm)>>> referenced by si_shader.c
>>> src/gallium/drivers/radeonsi/libradeonsi.a(src/gallium/drivers/radeonsi/libradeonsi.a.p/si_shader.c.o):(si_shader_dump_disassembly)>>> referenced 2 more times
mold: error: undefined symbol: ac_rtld_close
>>> referenced by si_state_draw.cpp
>>> src/gallium/drivers/radeonsi/libradeonsi_gfx9.a(src/gallium/drivers/radeonsi/libradeonsi_gfx9.a.p/si_state_draw.cpp.o):(bool si_update_shaders<(amd_gfx_level)11, (si_has_tess)0, (si_has_gs)0, (si_has_ngg)0>(si_context*))>>> referenced by si_state_draw.cpp
>>> src/gallium/drivers/radeonsi/libradeonsi_gfx9.a(src/gallium/drivers/radeonsi/libradeonsi_gfx9.a.p/si_state_draw.cpp.o):(bool si_update_shaders<(amd_gfx_level)11, (si_has_tess)0, (si_has_gs)1, (si_has_ngg)0>(si_context*))>>> referenced by si_state_draw.cpp
>>> src/gallium/drivers/radeonsi/libradeonsi_gfx9.a(src/gallium/drivers/radeonsi/libradeonsi_gfx9.a.p/si_state_draw.cpp.o):(bool si_update_shaders<(amd_gfx_level)11, (si_has_tess)1, (si_has_gs)0, (si_has_ngg)0>(si_context*))>>> referenced 32 more times
mold: error: undefined symbol: ac_rtld_read_config
>>> referenced by si_shader_llvm.c
>>> src/gallium/drivers/radeonsi/libradeonsi.a(src/gallium/drivers/radeonsi/libradeonsi.a.p/si_shader_llvm.c.o):(si_compile_llvm)
mold: error: undefined symbol: ac_rtld_get_section_by_name
>>> referenced by si_compute.c
>>> src/gallium/drivers/radeonsi/libradeonsi.a(src/gallium/drivers/radeonsi/libradeonsi.a.p/si_compute.c.o):(si_compute_get_code_object)>>> referenced by si_debug.c
>>> src/gallium/drivers/radeonsi/libradeonsi.a(src/gallium/drivers/radeonsi/libradeonsi.a.p/si_debug.c.o):(si_add_split_disasm)>>> referenced by si_shader.c
>>> src/gallium/drivers/radeonsi/libradeonsi.a(src/gallium/drivers/radeonsi/libradeonsi.a.p/si_shader.c.o):(si_shader_dump_disassembly)
mold: error: undefined symbol: ac_rtld_upload
>>> referenced by si_state_draw.cpp
>>> src/gallium/drivers/radeonsi/libradeonsi_gfx9.a(src/gallium/drivers/radeonsi/libradeonsi_gfx9.a.p/si_state_draw.cpp.o):(bool si_update_shaders<(amd_gfx_level)11, (si_has_tess)0, (si_has_gs)0, (si_has_ngg)0>(si_context*))>>> referenced by si_state_draw.cpp
>>> src/gallium/drivers/radeonsi/libradeonsi_gfx9.a(src/gallium/drivers/radeonsi/libradeonsi_gfx9.a.p/si_state_draw.cpp.o):(bool si_update_shaders<(amd_gfx_level)11, (si_has_tess)0, (si_has_gs)1, (si_has_ngg)0>(si_context*))>>> referenced by si_state_draw.cpp
>>> src/gallium/drivers/radeonsi/libradeonsi_gfx9.a(src/gallium/drivers/radeonsi/libradeonsi_gfx9.a.p/si_state_draw.cpp.o):(bool si_update_shaders<(amd_gfx_level)11, (si_has_tess)1, (si_has_gs)0, (si_has_ngg)0>(si_context*))>>> referenced 27 more times
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Either it's a radeonsi bug and it needs to be updated to support building without libelf
(using #ifdef USE_LIBELF
), or it's a meson bug and dep_elf
needs to be required when radeonsi is built (if not dep_elf.found() error('radeonsi requires libelf')
).