Skip to content

Replace libltdl with POSIX dlopen for module loading#4

Open
pvaldes wants to merge 1 commit intomainfrom
pvaldes/dlopen-refactor
Open

Replace libltdl with POSIX dlopen for module loading#4
pvaldes wants to merge 1 commit intomainfrom
pvaldes/dlopen-refactor

Conversation

@pvaldes
Copy link
Owner

@pvaldes pvaldes commented Jan 29, 2026

Refactor summary

  • Replace libltdl (lt_dlopen and friends) with POSIX dlopen from <dlfcn.h> for module loading
  • Remove the libltdl subproject dependency from the build system
  • Add AC_CHECK_LIB([dl], [dlopen]) to detect -ldl on platforms that need it (Linux)

Changes

  • src/modules.c: Replace lt_dlopen/lt_dlsym/lt_dlerror/lt_dlclose with dlopen/dlsym/dlerror/dlclose, remove lt_dlinit() call
  • include/modules.h: Replace <ltdl.h> with <dlfcn.h>
  • configure.ac: Remove LT_CONFIG_LTDL_DIR, LTDL_INIT, and LTDL_SUBDIR block; add AC_CHECK_LIB([dl], [dlopen])
  • Makefile.am: Remove @LTDL_SUBDIR@ from SUBDIRS, remove $(LIBLTDL) from link flags
  • src/Makefile.am: Remove $(LTDLINCL), replace $(LIBLTDL) with -ldl
  • modules/Makefile.am: Remove $(LTDLINCL)

Test plan

  • autoreconf -fi and ./configure complete without errors
  • make clean && make -j$(nproc) compiles successfully
  • make install and ircd-ratbox runs
  • No remaining ltdl/lt_dl/LIBLTDL/LTDLINCL references in source files

Note

dlopen is called with RTLD_LAZY, which defers symbol resolution until each symbol is first used. This matches the default behavior of lt_dlopen. The alternative is RTLD_NOW, which resolves all symbols at load time — this would cause module loading to fail immediately if any symbol is missing, but adds unnecessary startup cost since modules may not use all their symbols in every code path.

Next steps

  • Remove the libltdl/ directory from the repository
  • Move autotools aux files from libltdl/config/ to config/ and m4 macros from libltdl/m4/ to m4/
  • Update AC_CONFIG_AUX_DIR and AC_CONFIG_MACRO_DIR in configure.ac to point to the new locations
  • Run autoreconf -fi to regenerate configure, aclocal.m4, Makefile.in, and setup.h.in
  • Commit regenerated files in a separate "rerun autotools" commit

@pvaldes pvaldes force-pushed the pvaldes/dlopen-refactor branch from 63ebb53 to 523a89b Compare January 29, 2026 05:21
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

Successfully merging this pull request may close these issues.

1 participant