From 5fe723c92da05d9a2d7763fd9d54d223f4381571 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 27 Apr 2020 23:31:54 +0300 Subject: [PATCH] Fix libtool to provide a simple way to generate only "shared" object files or libraries. - Support for "-shared" option is taken from libtool-2.0 that is already at lease 15 years old. - Change PHP build system to use "-shared" instead of "--tag=disable-static". --- build/Makefile.global | 2 +- build/ltmain.sh | 13 +++++++++++++ build/php.m4 | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/build/Makefile.global b/build/Makefile.global index 237308d26597..17482043f9c5 100644 --- a/build/Makefile.global +++ b/build/Makefile.global @@ -16,7 +16,7 @@ build-modules: $(PHP_MODULES) $(PHP_ZEND_EX) build-binaries: $(PHP_BINARIES) libphp.la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) - $(LIBTOOL) --mode=link --tag=disable-static $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ + $(LIBTOOL) --mode=link $(CC) -shared $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ -@$(LIBTOOL) --silent --mode=install cp $@ $(phptempdir)/$@ >/dev/null 2>&1 libs/libphp.bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) diff --git a/build/ltmain.sh b/build/ltmain.sh index 7e2240e980e0..2f1c8c9dc80f 100755 --- a/build/ltmain.sh +++ b/build/ltmain.sh @@ -811,6 +811,13 @@ if test -z "$show_help"; then for arg in $later; do case $arg in + -shared) + test yes = "$build_libtool_libs" \ + || func_fatal_configuration "cannot build a shared library" + build_old_libs=no + continue + ;; + -static) build_old_libs=yes continue @@ -1177,6 +1184,12 @@ EOF for arg do case $arg in + -shared) + test yes != "$build_libtool_libs" \ + && func_fatal_configuration "cannot build a shared library" + build_old_libs=no + break + ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) diff --git a/build/php.m4 b/build/php.m4 index 1b9940147e16..c5ce38026462 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -851,7 +851,7 @@ AC_DEFUN([PHP_SHARED_MODULE],[ \$(LIBTOOL) --mode=install cp $3/$1.$suffix \$(phplibdir) $3/$1.$suffix: \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_DEPENDENCIES) - \$(LIBTOOL) --mode=link --tag=disable-static ifelse($4,,[\$(CC)],[\$(CXX)]) \$(COMMON_FLAGS) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(LDFLAGS) $additional_flags -o [\$]@ -export-dynamic -avoid-version -prefer-pic -module -rpath \$(phplibdir) \$(EXTRA_LDFLAGS) \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_LIBADD) + \$(LIBTOOL) --mode=link ifelse($4,,[\$(CC)],[\$(CXX)]) -shared \$(COMMON_FLAGS) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(LDFLAGS) $additional_flags -o [\$]@ -export-dynamic -avoid-version -prefer-pic -module -rpath \$(phplibdir) \$(EXTRA_LDFLAGS) \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_LIBADD) EOF ])