xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit 2570d553ef31f5a8df408f1cdc7fa32f7c5d947f

Fix C Lua modules not loading on Unix-like systems
Did attempt to escape with single quotes like this:
LDFLAGS="$LDFLAGS '-Wl,--export-dynamic-symbol=lua_*'"
but it broke compilation because the quotes were escaped. Anyway, the
probability of a file starting with `-Wl,--export-dynamic-symbol=lua_`
or `-Wl,--export-dynamic-symbol=luaL_` is rather low.

Thanks to Steven Xu (a.k.a. stevenxxiu).
Author: xaizek
Author date (UTC): 2026-05-25 16:45
Committer name: xaizek
Committer date (UTC): 2026-05-25 16:55
Parent(s): 5d3acf89e5a44af7126c885738aee1a8366e67d2
Signing key: 99DC5E4DB05F6BE2
Tree: ef1bfce221e055471dd70e904010d5d80dc7e9e3
File Lines added Lines deleted
ChangeLog 3 0
Makefile.in 1 0
aclocal.m4 1 0
build-aux/m4/ax_check_link_flag.m4 53 0
configure 145 55
configure.ac 18 4
src/Makefile.in 1 0
src/lua/lua/luaconf.h 2 1
File ChangeLog changed (mode: 100644) (index 4d4c413d3..eb6e6ed26)
241 241 Fixed a buffer overflow in trie implementation. Thanks to Michał Fixed a buffer overflow in trie implementation. Thanks to Michał
242 242 Majchrowicz and Marcin Wyczechowski. Majchrowicz and Marcin Wyczechowski.
243 243
244 Fixed Lua modules written in C not being loaded on Unix-like systems.
245 Thanks to Steven Xu (a.k.a. stevenxxiu).
246
244 247 0.14-beta to 0.14 (2025-02-08) 0.14-beta to 0.14 (2025-02-08)
245 248
246 249 Improved documentation on zh/zl menu keys a bit. Improved documentation on zh/zl menu keys a bit.
File Makefile.in changed (mode: 100644) (index 065632ebe..195270fe8)
... ... subdir = .
93 93 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
94 94 am__aclocal_m4_deps = \ am__aclocal_m4_deps = \
95 95 $(top_srcdir)/build-aux/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/build-aux/m4/ax_check_compile_flag.m4 \
96 $(top_srcdir)/build-aux/m4/ax_check_link_flag.m4 \
96 97 $(top_srcdir)/build-aux/m4/ax_pthread.m4 \ $(top_srcdir)/build-aux/m4/ax_pthread.m4 \
97 98 $(top_srcdir)/configure.ac $(top_srcdir)/configure.ac
98 99 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
File aclocal.m4 changed (mode: 100644) (index 633ead9c8..248fb5c60)
... ... AC_SUBST(am__xargs_n)
1316 1316 ]) ])
1317 1317
1318 1318 m4_include([build-aux/m4/ax_check_compile_flag.m4]) m4_include([build-aux/m4/ax_check_compile_flag.m4])
1319 m4_include([build-aux/m4/ax_check_link_flag.m4])
1319 1320 m4_include([build-aux/m4/ax_pthread.m4]) m4_include([build-aux/m4/ax_pthread.m4])
File build-aux/m4/ax_check_link_flag.m4 added (mode: 100644) (index 000000000..03a30ce4c)
1 # ===========================================================================
2 # https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 # AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
8 #
9 # DESCRIPTION
10 #
11 # Check whether the given FLAG works with the linker or gives an error.
12 # (Warnings, however, are ignored)
13 #
14 # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
15 # success/failure.
16 #
17 # If EXTRA-FLAGS is defined, it is added to the linker's default flags
18 # when the check is done. The check is thus made with the flags: "LDFLAGS
19 # EXTRA-FLAGS FLAG". This can for example be used to force the linker to
20 # issue an error when a bad flag is given.
21 #
22 # INPUT gives an alternative input source to AC_LINK_IFELSE.
23 #
24 # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
25 # macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
26 #
27 # LICENSE
28 #
29 # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
30 # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
31 #
32 # Copying and distribution of this file, with or without modification, are
33 # permitted in any medium without royalty provided the copyright notice
34 # and this notice are preserved. This file is offered as-is, without any
35 # warranty.
36
37 #serial 6
38
39 AC_DEFUN([AX_CHECK_LINK_FLAG],
40 [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
41 AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
42 AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
43 ax_check_save_flags=$LDFLAGS
44 LDFLAGS="$LDFLAGS $4 $1"
45 AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
46 [AS_VAR_SET(CACHEVAR,[yes])],
47 [AS_VAR_SET(CACHEVAR,[no])])
48 LDFLAGS=$ax_check_save_flags])
49 AS_VAR_IF(CACHEVAR,yes,
50 [m4_default([$2], :)],
51 [m4_default([$3], :)])
52 AS_VAR_POPDEF([CACHEVAR])dnl
53 ])dnl AX_CHECK_LINK_FLAGS
File configure changed (mode: 100755) (index c2525ff94..b1c37d288)
... ... then :
9215 9215 fi fi
9216 9216
9217 9217
9218 { printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
9219 printf %s "checking for dlopen in -ldl... " >&6; }
9220 if test ${ac_cv_lib_dl_dlopen+y}
9221 then :
9222 printf %s "(cached) " >&6
9223 else case e in #(
9224 e) ac_check_lib_save_LIBS=$LIBS
9225 LIBS="-ldl $LIBS"
9226 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9227 /* end confdefs.h. */
9228
9229 /* Override any GCC internal prototype to avoid an error.
9230 Use char because int might match the return type of a GCC
9231 builtin and then its argument prototype would still apply.
9232 The 'extern "C"' is for builds by C++ compilers;
9233 although this is not generally supported in C code supporting it here
9234 has little cost and some practical benefit (sr 110532). */
9235 #ifdef __cplusplus
9236 extern "C"
9237 #endif
9238 char dlopen (void);
9239 int
9240 main (void)
9241 {
9242 return dlopen ();
9243 ;
9244 return 0;
9245 }
9246 _ACEOF
9247 if ac_fn_c_try_link "$LINENO"
9248 then :
9249 ac_cv_lib_dl_dlopen=yes
9250 else case e in #(
9251 e) ac_cv_lib_dl_dlopen=no ;;
9252 esac
9253 fi
9254 rm -f core conftest.err conftest.$ac_objext conftest.beam \
9255 conftest$ac_exeext conftest.$ac_ext
9256 LIBS=$ac_check_lib_save_LIBS ;;
9257 esac
9258 fi
9259 { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
9260 printf '%s\n' "$ac_cv_lib_dl_dlopen" >&6; }
9261 if test "x$ac_cv_lib_dl_dlopen" = xyes
9262 then :
9263 LIBS="$LIBS -ldl"
9264 fi
9265
9266 as_CACHEVAR=`printf '%s\n' "ax_cv_check_ldflags__-Wl,--export-dynamic-symbol=lua_*" | sed "$as_sed_sh"`
9267 { printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -Wl,--export-dynamic-symbol=lua_*" >&5
9268 printf %s "checking whether the linker accepts -Wl,--export-dynamic-symbol=lua_*... " >&6; }
9269 if eval test \${$as_CACHEVAR+y}
9270 then :
9271 printf %s "(cached) " >&6
9272 else case e in #(
9273 e)
9274 ax_check_save_flags=$LDFLAGS
9275 LDFLAGS="$LDFLAGS -Wl,--export-dynamic-symbol=lua_*"
9276 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9277 /* end confdefs.h. */
9278
9279 int
9280 main (void)
9281 {
9282
9283 ;
9284 return 0;
9285 }
9286 _ACEOF
9287 if ac_fn_c_try_link "$LINENO"
9288 then :
9289 eval "$as_CACHEVAR=yes"
9290 else case e in #(
9291 e) eval "$as_CACHEVAR=no" ;;
9292 esac
9293 fi
9294 rm -f core conftest.err conftest.$ac_objext conftest.beam \
9295 conftest$ac_exeext conftest.$ac_ext
9296 LDFLAGS=$ax_check_save_flags ;;
9297 esac
9298 fi
9299 eval ac_res=\$$as_CACHEVAR
9300 { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
9301 printf '%s\n' "$ac_res" >&6; }
9302 if eval test \"x\$"$as_CACHEVAR"\" = x"yes"
9303 then :
9304 can_limit_symbols=yes
9305 else case e in #(
9306 e) : ;;
9307 esac
9308 fi
9309
9310 if test "$can_limit_symbols" = "yes"; then
9311 LDFLAGS="$LDFLAGS -Wl,--export-dynamic-symbol=lua_*"
9312 LDFLAGS="$LDFLAGS -Wl,--export-dynamic-symbol=luaL_*"
9313 else
9314 { printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -Wl,-E" >&5
9315 printf %s "checking whether the linker accepts -Wl,-E... " >&6; }
9316 if test ${ax_cv_check_ldflags___Wl__E+y}
9317 then :
9318 printf %s "(cached) " >&6
9319 else case e in #(
9320 e)
9321 ax_check_save_flags=$LDFLAGS
9322 LDFLAGS="$LDFLAGS -Wl,-E"
9323 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9324 /* end confdefs.h. */
9325
9326 int
9327 main (void)
9328 {
9329
9330 ;
9331 return 0;
9332 }
9333 _ACEOF
9334 if ac_fn_c_try_link "$LINENO"
9335 then :
9336 ax_cv_check_ldflags___Wl__E=yes
9337 else case e in #(
9338 e) ax_cv_check_ldflags___Wl__E=no ;;
9339 esac
9340 fi
9341 rm -f core conftest.err conftest.$ac_objext conftest.beam \
9342 conftest$ac_exeext conftest.$ac_ext
9343 LDFLAGS=$ax_check_save_flags ;;
9344 esac
9345 fi
9346 { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_ldflags___Wl__E" >&5
9347 printf '%s\n' "$ax_cv_check_ldflags___Wl__E" >&6; }
9348 if test "x$ax_cv_check_ldflags___Wl__E" = xyes
9349 then :
9350 LDFLAGS="$LDFLAGS -Wl,-E"
9351 else case e in #(
9352 e) as_fn_error $? "Linker doesn't support -E flag." "$LINENO" 5 ;;
9353 esac
9354 fi
9355
9356 fi
9357
9218 9358 { printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 { printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
9219 9359 printf %s "checking for a sed that does not truncate output... " >&6; } printf %s "checking for a sed that does not truncate output... " >&6; }
9220 9360 if test ${ac_cv_path_SED+y} if test ${ac_cv_path_SED+y}
 
... ... printf '%s\n' "#define ENABLE_REMOTE_CMDS 1" >>confdefs.h
11726 11866 fi fi
11727 11867
11728 11868 if test "$use_dyn_libX11" = "yes"; then if test "$use_dyn_libX11" = "yes"; then
11729 ORIG_LIBS="$LIBS"
11730 { printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
11731 printf %s "checking for dlopen in -ldl... " >&6; }
11732 if test ${ac_cv_lib_dl_dlopen+y}
11733 then :
11734 printf %s "(cached) " >&6
11735 else case e in #(
11736 e) ac_check_lib_save_LIBS=$LIBS
11737 LIBS="-ldl $LIBS"
11738 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11739 /* end confdefs.h. */
11740
11741 /* Override any GCC internal prototype to avoid an error.
11742 Use char because int might match the return type of a GCC
11743 builtin and then its argument prototype would still apply.
11744 The 'extern "C"' is for builds by C++ compilers;
11745 although this is not generally supported in C code supporting it here
11746 has little cost and some practical benefit (sr 110532). */
11747 #ifdef __cplusplus
11748 extern "C"
11749 #endif
11750 char dlopen (void);
11751 int
11752 main (void)
11753 {
11754 return dlopen ();
11755 ;
11756 return 0;
11757 }
11758 _ACEOF
11759 if ac_fn_c_try_link "$LINENO"
11760 then :
11761 ac_cv_lib_dl_dlopen=yes
11762 else case e in #(
11763 e) ac_cv_lib_dl_dlopen=no ;;
11764 esac
11765 fi
11766 rm -f core conftest.err conftest.$ac_objext conftest.beam \
11767 conftest$ac_exeext conftest.$ac_ext
11768 LIBS=$ac_check_lib_save_LIBS ;;
11769 esac
11770 fi
11771 { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
11772 printf '%s\n' "$ac_cv_lib_dl_dlopen" >&6; }
11773 if test "x$ac_cv_lib_dl_dlopen" = xyes
11774 then :
11775 LIBS="$LIBS -ldl"
11776 else case e in #(
11777 e) use_dyn_libX11=no ;;
11778 esac
11779 fi
11780
11869 if test "$ac_cv_lib_dl_dlopen" != yes; then
11870 use_dyn_libX11=no
11871 fi
11781 11872
11782 11873 ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default" ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default"
11783 11874 if test "x$ac_cv_header_dlfcn_h" = xyes if test "x$ac_cv_header_dlfcn_h" = xyes
 
... ... fi
11808 11899
11809 11900
11810 11901 if test "$use_dyn_libX11" != "yes"; then if test "$use_dyn_libX11" != "yes"; then
11811 LIBS="$ORIG_LIBS"
11812 { printf '%s\n' "$as_me:${as_lineno-$LINENO}: WARNING: \"libdl seems to don't work as expected. No dynamic X11.\"" >&5
11813 printf '%s\n' "$as_me: WARNING: \"libdl seems to don't work as expected. No dynamic X11.\"" >&2;}
11902 { printf '%s\n' "$as_me:${as_lineno-$LINENO}: WARNING: \"libdl seems to not work as expected. No dynamic X11.\"" >&5
11903 printf '%s\n' "$as_me: WARNING: \"libdl seems to not work as expected. No dynamic X11.\"" >&2;}
11814 11904 fi fi
11815 11905 fi fi
11816 11906
File configure.ac changed (mode: 100644) (index 3f86d0397..e6fd2a8b5)
... ... AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"])
418 418 dnl Enable POSIX shared memory dnl Enable POSIX shared memory
419 419 AC_CHECK_LIB(rt, shm_open, [LIBS="$LIBS -lrt"]) AC_CHECK_LIB(rt, shm_open, [LIBS="$LIBS -lrt"])
420 420
421 dnl Used for Lua's loadable C modules, not failing when not present because its
422 dnl existence depends on an operating system
423 AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl"])
424 AX_CHECK_LINK_FLAG([-Wl,--export-dynamic-symbol=lua_*], [can_limit_symbols=yes])
425 if test "$can_limit_symbols" = "yes"; then
426 dnl When supported, whitelist symbols to be exported by the executable
427 LDFLAGS="$LDFLAGS -Wl,--export-dynamic-symbol=lua_*"
428 LDFLAGS="$LDFLAGS -Wl,--export-dynamic-symbol=luaL_*"
429 else
430 AX_CHECK_LINK_FLAG([-Wl,-E],
431 [LDFLAGS="$LDFLAGS -Wl,-E"],
432 [AC_MSG_ERROR([Linker doesn't support -E flag.])])
433 fi
434
421 435 dnl Use pthread library dnl Use pthread library
422 436 AX_PTHREAD([ AX_PTHREAD([
423 437 LIBS="$PTHREAD_LIBS $LIBS" LIBS="$PTHREAD_LIBS $LIBS"
 
... ... if test "$remote_cmds" = "yes"; then
786 800 fi fi
787 801
788 802 if test "$use_dyn_libX11" = "yes"; then if test "$use_dyn_libX11" = "yes"; then
789 ORIG_LIBS="$LIBS"
790 AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl"], [use_dyn_libX11=no])
803 if test "$ac_cv_lib_dl_dlopen" != yes; then
804 use_dyn_libX11=no
805 fi
791 806
792 807 AC_CHECK_HEADER([dlfcn.h], [], [use_dyn_libX11=no]) AC_CHECK_HEADER([dlfcn.h], [], [use_dyn_libX11=no])
793 808 AC_CHECK_FUNC([dlsym], [], [use_dyn_libX11=no]) AC_CHECK_FUNC([dlsym], [], [use_dyn_libX11=no])
794 809 AC_CHECK_FUNC([dlclose], [], [use_dyn_libX11=no]) AC_CHECK_FUNC([dlclose], [], [use_dyn_libX11=no])
795 810
796 811 if test "$use_dyn_libX11" != "yes"; then if test "$use_dyn_libX11" != "yes"; then
797 LIBS="$ORIG_LIBS"
798 AC_MSG_WARN(["libdl seems to don't work as expected. No dynamic X11."])
812 AC_MSG_WARN(["libdl seems to not work as expected. No dynamic X11."])
799 813 fi fi
800 814 fi fi
801 815
File src/Makefile.in changed (mode: 100644) (index fc4d0acf5..165cb82ae)
... ... subdir = src
97 97 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
98 98 am__aclocal_m4_deps = \ am__aclocal_m4_deps = \
99 99 $(top_srcdir)/build-aux/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/build-aux/m4/ax_check_compile_flag.m4 \
100 $(top_srcdir)/build-aux/m4/ax_check_link_flag.m4 \
100 101 $(top_srcdir)/build-aux/m4/ax_pthread.m4 \ $(top_srcdir)/build-aux/m4/ax_pthread.m4 \
101 102 $(top_srcdir)/configure.ac $(top_srcdir)/configure.ac
102 103 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
File src/lua/lua/luaconf.h changed (mode: 100644) (index c168a2a6a..33dcea1a2)
794 794 ** without modifying the main part of the file. ** without modifying the main part of the file.
795 795 */ */
796 796
797 #ifndef _WIN32
797 #if !defined(LUA_USE_WINDOWS)
798 798 #define LUA_USE_POSIX #define LUA_USE_POSIX
799 #define LUA_USE_DLOPEN /* needs an extra library: -ldl */
799 800 #endif #endif
800 801
801 802 #endif #endif
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master