lvm2: fix musl build

This commit is contained in:
Dylan Araps 2019-09-03 22:13:08 +03:00
parent ebb946103f
commit a6186e7b43
8 changed files with 271 additions and 63 deletions

View File

@ -3,14 +3,19 @@
patch -p1 < portability.patch
patch -p1 < fix-stdio-usage.patch
patch -p1 < mlockall-default-config.patch
patch -p1 < dash.patch
patch -p1 < musl-fix-include.patch
patch -p1 < disable-symver.patch
patch -p1 < 001-include_fix.patch
# Dummy 'fmt' file.
# POSIX sh 'fmt -1' script.
mkdir -p fakebin
:> fakebin/fmt
cat > fakebin/fmt <<EOF
#!/bin/sh -f
printf '%s\n' \$(cat -)
EOF
chmod +x fakebin/fmt
export PATH=/usr/bin:$PWD/fakebin
export PATH=$PATH:$PWD/fakebin
export MKDIR_P="install -d"
./configure \
@ -20,22 +25,20 @@ export MKDIR_P="install -d"
--localstatedir=/var \
--disable-selinux \
--disable-nls \
--disable-udev-systemd-background-jobs \
--enable-pkgconfig \
--enable-fsadm \
--enable-dmeventd \
--enable-cmdlib \
--enable-udev_sync \
--enable-udev_rules \
--enable-dmeventd \
--with-cache=none \
--with-thin=none \
--enable-symvers=no \
--disable-symvers \
--with-default-dm-run-dir=/run \
--with-default-locking-dir=/run/lock/lvm \
--with-default-pid-dir=/run \
--with-default-run-dir=/run/lvm \
CLDFLAGS="$LDFLAGS"
--with-default-run-dir=/run/lvm
make
make -j1 DESTDIR="$1" install
make V=1 DESTDIR="$1" install
# Make all libraries and binaries writable.
chmod -v u+w "$1/usr/lib/"* \

View File

@ -1,5 +1,7 @@
ca52815c999b20c6d25e3192f142f081b93d01f07b9d787e99664b169dba2700 LVM2.2.03.05.tgz
4c7e068efb1734728016cab4cd05f900f21a3e9caf9ff811ba91be1240304bc0 dash.patch
a15546fefd675fd6282683e93b41a5350b4e58e090f881b1a2807b44a4a5bd11 fix-stdio-usage.patch
1936f44db53a7cd2eea4cb98303994c091aa32349d9d90aa4408f0b89dd32aa6 fix-stdio-usage.patch
352ec9eff8b5f796b6767cdab6df1cac0f94d37365a33988fdb9bff11f72c547 mlockall-default-config.patch
d1f78c5a07f0ba66856e00e498c0f62164cabbcd9f0d9abcda1c25501eb235ff portability.patch
bec8a087dfb72fedc0884848959d4558c9ddbfa0b51ea404ad111b44e72d27fa musl-fix-include.patch
e785546d0fa6551364ad2a26e50672ace1262d60439727356d28970a80f30a91 disable-symver.patch
ef22a160a903bb50bfba86644eab86de381c4ec29bd0129f1088c5d61e2298b9 001-include_fix.patch

View File

@ -0,0 +1,13 @@
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 4e35220..16ae94e 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -23,7 +23,7 @@
#include "lib/label/label.h"
#ifdef BLKID_WIPING_SUPPORT
-#include <blkid.h>
+#include <blkid/blkid.h>
#endif
#ifdef UDEV_SYNC_SUPPORT

View File

@ -1,28 +0,0 @@
--- LVM2.2.03.05/configure
+++ LVM2.2.03.05/configure
@@ -3077,7 +3077,7 @@ if test -z "$CFLAGS"; then :
fi
case "$host_os" in
linux*)
- CLDFLAGS="${CLDFLAGS:"$LDFLAGS"} -Wl,--version-script,.export.sym"
+ CLDFLAGS="${CLDFLAGS:-"$LDFLAGS"} -Wl,--version-script,.export.sym"
# equivalent to -rdynamic
ELDFLAGS="-Wl,--export-dynamic"
# FIXME Generate list and use --dynamic-list=.dlopen.sym
@@ -3098,7 +3098,7 @@ case "$host_os" in
;;
darwin*)
CFLAGS="$CFLAGS -no-cpp-precomp -fno-common"
- CLDFLAGS="${CLDFLAGS:"$LDFLAGS"}"
+ CLDFLAGS="${CLDFLAGS:-"$LDFLAGS"}"
ELDFLAGS=
CLDWHOLEARCHIVE="-all_load"
CLDNOWHOLEARCHIVE=
@@ -3111,7 +3111,7 @@ case "$host_os" in
BLKDEACTIVATE=no
;;
*)
- CLDFLAGS="${CLDFLAGS:"$LDFLAGS"}"
+ CLDFLAGS="${CLDFLAGS:-"$LDFLAGS"}"
;;
esac

View File

@ -0,0 +1,181 @@
diff --git a/configure b/configure
index 7d945dfa8..94cd6b1ea 100755
--- a/configure
+++ b/configure
@@ -975,6 +975,7 @@ enable_fsadm
enable_blkdeactivate
enable_dmeventd
enable_selinux
+enable_symvers
enable_nls
with_localedir
with_confdir
@@ -1725,6 +1726,9 @@ Optional Features:
--disable-blkdeactivate disable blkdeactivate
--enable-dmeventd enable the device-mapper event daemon
--disable-selinux disable selinux support
+ --enable-symvers[=STYLE]
+ enables symbol versioning of the shared library
+ [default=gnu]
--enable-nls enable Native Language Support
Optional Packages:
@@ -3156,7 +3160,6 @@ if test -z "$CFLAGS"; then :
fi
case "$host_os" in
linux*)
- CLDFLAGS="${CLDFLAGS:"$LDFLAGS"} -Wl,--version-script,.export.sym"
# equivalent to -rdynamic
ELDFLAGS="-Wl,--export-dynamic"
# FIXME Generate list and use --dynamic-list=.dlopen.sym
@@ -3178,7 +3181,6 @@ case "$host_os" in
;;
darwin*)
CFLAGS="$CFLAGS -no-cpp-precomp -fno-common"
- CLDFLAGS="${CLDFLAGS:"$LDFLAGS"}"
ELDFLAGS=
CLDWHOLEARCHIVE="-all_load"
CLDNOWHOLEARCHIVE=
@@ -14401,6 +14403,32 @@ done
LIBS=$lvm_saved_libs
fi
+################################################################################
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable symbol versioning" >&5
+$as_echo_n "checking whether to enable symbol versioning... " >&6; }
+# Check whether --enable-symvers was given.
+if test "${enable_symvers+set}" = set; then :
+ enableval=$enable_symvers;
+ case "$enableval" in
+ gnu|no) ;;
+ *) as_fn_error $? "Unknown argument to enable/disable symvers" "$LINENO" 5 ;;
+ esac
+else
+ enable_symvers=gnu
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_symvers" >&5
+$as_echo "$enable_symvers" >&6; }
+
+if test x$GCC = xyes && test x$enable_symvers = xgnu ; then
+
+$as_echo "#define GNU_SYMVER 1" >>confdefs.h
+
+ case "$host_os" in
+ linux*) CLDFLAGS="$CLDFLAGS -Wl,--version-script,.export.sym" ;;
+ esac
+fi
+
################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable internationalisation" >&5
$as_echo_n "checking whether to enable internationalisation... " >&6; }
diff --git a/include/configure.h.in b/include/configure.h.in
index 15fd150ed..7a07a10ef 100644
--- a/include/configure.h.in
+++ b/include/configure.h.in
@@ -147,6 +147,9 @@
/* Path to fsadm binary. */
#undef FSADM_PATH
+/* Define to use GNU versioning in the shared library. */
+#undef GNU_SYMVER
+
/* Define to 1 if you have the `alarm' function. */
#undef HAVE_ALARM
diff --git a/lib/misc/lib.h b/lib/misc/lib.h
index d7fa5c721..7cf98f932 100644
--- a/lib/misc/lib.h
+++ b/lib/misc/lib.h
@@ -41,16 +41,16 @@
* macro DM_EXPORT_SYMBOL to export the function and bind it to the
* specified version string.
*
- * Since versioning is only available when compiling with GCC the entire
- * compatibility version should be enclosed in '#if defined(__GNUC__)',
- * for example:
+ * Since versioning is only available when compiling with GCC
+ * and GLIBC the entire compatibility version should be enclosed
+ * in '#if defined(GNU_SYMVER)', for example:
*
* int dm_foo(int bar)
* {
* return bar;
* }
*
- * #if defined(__GNUC__)
+ * #if defined(GNU_SYMVER)
* // Backward compatible dm_foo() version 1.02.104
* int dm_foo_v1_02_104(void);
* int dm_foo_v1_02_104(void)
@@ -67,7 +67,7 @@
* versions of library symbols prior to the introduction of symbol
* versioning: it must never be used for new symbols.
*/
-#if defined(__GNUC__)
+#if defined(GNU_SYMVER)
#define DM_EXPORT_SYMBOL(func, ver) \
__asm__(".symver " #func "_v" #ver ", " #func "@DM_" #ver )
#define DM_EXPORT_SYMBOL_BASE(func) \
diff --git a/libdm/datastruct/bitset.c b/libdm/datastruct/bitset.c
index b0826e1eb..2ec3f8f84 100644
--- a/libdm/datastruct/bitset.c
+++ b/libdm/datastruct/bitset.c
@@ -242,7 +242,7 @@ bad:
return NULL;
}
-#if defined(__GNUC__)
+#if defined(GNU_SYMVER)
/*
* Maintain backward compatibility with older versions that did not
* accept a 'min_num_bits' argument to dm_bitset_parse_list().
@@ -253,7 +253,4 @@ dm_bitset_t dm_bitset_parse_list_v1_02_129(const char *str, struct dm_pool *mem)
return dm_bitset_parse_list(str, mem, 0);
}
DM_EXPORT_SYMBOL(dm_bitset_parse_list, 1_02_129);
-
-#else /* if defined(__GNUC__) */
-
#endif
diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c
index 769b69c1b..28e2eadee 100644
--- a/libdm/ioctl/libdm-iface.c
+++ b/libdm/ioctl/libdm-iface.c
@@ -2145,7 +2145,7 @@ void dm_lib_exit(void)
_version_checked = 0;
}
-#if defined(__GNUC__)
+#if defined(GNU_SYMVER)
/*
* Maintain binary backward compatibility.
* Version script mechanism works with 'gcc' compatible compilers only.
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index ab0545659..00651c0b2 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -3797,7 +3797,7 @@ void dm_tree_node_set_callback(struct dm_tree_node *dnode,
dnode->callback_data = data;
}
-#if defined(__GNUC__)
+#if defined(GNU_SYMVER)
/*
* Backward compatible implementations.
*
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 94ad380e0..76efbbe35 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -5065,7 +5065,7 @@ int dm_stats_start_filemapd(int fd, uint64_t group_id, const char *path,
* current dm_stats_create_region() version.
*/
-#if defined(__GNUC__)
+#if defined(GNU_SYMVER)
int dm_stats_create_region_v1_02_106(struct dm_stats *dms, uint64_t *region_id,
uint64_t start, uint64_t len, int64_t step,
int precise, const char *program_id,
--
2.18.0

View File

@ -2,7 +2,7 @@
+++ ./tools/lvmcmdline.c
@@ -1252,7 +1252,7 @@
int err = is_valid_fd(STDERR_FILENO);
if (!is_valid_fd(STDIN_FILENO) &&
- !(stdin = fopen(_PATH_DEVNULL, "r"))) {
+ !freopen(_PATH_DEVNULL, "r", stdin)) {
@ -11,7 +11,7 @@
else
@@ -1262,7 +1262,7 @@
}
if (!is_valid_fd(STDOUT_FILENO) &&
- !(stdout = fopen(_PATH_DEVNULL, "w"))) {
+ !freopen(_PATH_DEVNULL, "w", stdout)) {
@ -20,30 +20,53 @@
/* else no stdout */
@@ -1270,7 +1270,7 @@
}
if (!is_valid_fd(STDERR_FILENO) &&
- !(stderr = fopen(_PATH_DEVNULL, "w"))) {
+ !freopen(_PATH_DEVNULL, "w", stderr)) {
printf("stderr stream open: %s\n",
strerror(errno));
return 0;
--- ./lib/commands/toolcontext.c.orig
+++ ./lib/commands/toolcontext.c
@@ -1860,7 +1860,7 @@
/* FIXME Make this configurable? */
reset_lvm_errno(1);
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -1649,7 +1649,7 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd,
/* FIXME Make this configurable? */
reset_lvm_errno(1);
-#ifndef VALGRIND_POOL
+#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
/* Set in/out stream buffering before glibc */
if (set_buffering
+#if defined(__GLIBC__) && !defined(VALGRIND_POOL)
/* Set in/out stream buffering before glibc */
if (set_buffering
#ifdef SYS_gettid
@@ -2254,7 +2254,7 @@
if (cmd->libmem)
dm_pool_destroy(cmd->libmem);
@@ -2031,7 +2031,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
if (cmd->libmem)
dm_pool_destroy(cmd->libmem);
-#ifndef VALGRIND_POOL
+#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
if (cmd->linebuffer) {
/* Reset stream buffering to defaults */
if (is_valid_fd(STDIN_FILENO) &&
+#if defined(__GLIBC__) && !defined(VALGRIND_POOL)
if (cmd->linebuffer) {
/* Reset stream buffering to defaults */
if (is_valid_fd(STDIN_FILENO) &&
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -3055,6 +3055,7 @@ int lvm_split(char *str, int *argc, char **argv, int max)
/* Make sure we have always valid filedescriptors 0,1,2 */
static int _check_standard_fds(void)
{
+#ifdef __GLIBC__
int err = is_valid_fd(STDERR_FILENO);
if (!is_valid_fd(STDIN_FILENO) &&
@@ -3081,6 +3082,12 @@ static int _check_standard_fds(void)
strerror(errno));
return 0;
}
+#else
+ if (!is_valid_fd(STDERR_FILENO) ||
+ !is_valid_fd(STDOUT_FILENO) ||
+ !is_valid_fd(STDIN_FILENO))
+ return 0;
+#endif
return 1;
}

View File

@ -0,0 +1,12 @@
diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c
index 79b54d0..e768e7e 100644
--- a/libdaemon/server/daemon-server.c
+++ b/libdaemon/server/daemon-server.c
@@ -30,6 +30,7 @@
#include <sys/un.h>
#include <unistd.h>
#include <signal.h>
+#include <fcntl.h>
#include <syslog.h> /* FIXME. For the global closelog(). */

View File

@ -1,5 +1,7 @@
https://mirrors.kernel.org/sourceware/lvm2/releases/LVM2.2.03.05.tgz
patches/dash.patch
patches/fix-stdio-usage.patch
patches/mlockall-default-config.patch
patches/portability.patch
patches/musl-fix-include.patch
patches/disable-symver.patch
patches/001-include_fix.patch