Accepting request 99345 from home:elvigia:branches:Archiving

- bzlib: open file descriptors with O_CLOEXEC, but just like 
 the zlib case, only when bzopen() is used and not bzdopen()
 to avoid messing up with the caller's semantics.
 It is responsability of to initiator to set that flag in such case.
- Replace error prone list of exported symbols with proper use of
  GCC visibility features.

OBS-URL: https://build.opensuse.org/request/show/99345
OBS-URL: https://build.opensuse.org/package/show/Archiving/bzip2?expand=0&rev=26
This commit is contained in:
Cristian Rodríguez 2012-01-07 20:37:58 +00:00 committed by Git OBS Bridge
parent c0d3f57f48
commit e8b7e041b9
4 changed files with 140 additions and 58 deletions

View File

@ -53,7 +53,7 @@
+both instances of the shared library can live together.
--- /dev/null
+++ configure.ac
@@ -0,0 +1,71 @@
@@ -0,0 +1,62 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
@ -65,19 +65,20 @@
+AC_CONFIG_SRCDIR([bzlib.h])
+AC_CONFIG_MACRO_DIR([m4])
+
+AM_INIT_AUTOMAKE
+AM_INIT_AUTOMAKE([foreign subdir-objects])
+AM_MAINTAINER_MODE
+
+# Checks for programs.
+AC_PROG_AWK
+AC_PROG_CC_STDC
+AC_PROG_CC_C_O
+AC_USE_SYSTEM_EXTENSIONS
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+AC_PROG_LIBTOOL
+LT_INIT([disable-static pic-only])
+PKG_PROG_PKG_CONFIG
+
+gl_VISIBILITY
+# Checks for libraries.
+
+# Checks for header files.
@ -107,16 +108,6 @@
+ CFLAGS="$save_CFLAGS"
+])
+
+AC_MSG_CHECKING([whether compiler understands -fno-strength-reduce])
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -fno-strength-reduce"
+AC_TRY_COMPILE([], [], [
+ AC_MSG_RESULT([yes])
+], [
+ AC_MSG_RESULT([no])
+ CFLAGS="$save_CFLAGS"
+])
+
+# Checks for library functions.
+
+# Write the output.
@ -127,9 +118,10 @@
+AC_OUTPUT
--- /dev/null
+++ Makefile.am
@@ -0,0 +1,138 @@
@@ -0,0 +1,137 @@
+ACLOCAL_AMFLAGS = -I m4
+lib_LTLIBRARIES = libbz2.la
+
+AM_CFLAGS = $(CFLAG_VISIBILITY)
+libbz2_la_SOURCES = \
+ blocksort.c \
+ huffman.c \
@ -141,7 +133,7 @@
+
+libbz2_la_LDFLAGS = \
+ -version-info $(BZIP2_LT_CURRENT):$(BZIP2_LT_REVISION):$(BZIP2_LT_AGE) \
+ -no-undefined -Wl,--version-script=$(srcdir)/libbz2.map
+ -no-undefined
+
+include_HEADERS = bzlib.h
+
@ -264,8 +256,6 @@
+ words2 \
+ words3 \
+ xmlproc.sh
+
+ACLOCAL_AMFLAGS = -I m4
--- /dev/null
+++ bzip2.pc.in
@@ -0,0 +1,11 @@
@ -281,36 +271,98 @@
+Libs: -L${libdir} -lbz2
+Cflags: -I${includedir}
--- /dev/null
+++ libbz2.map
@@ -0,0 +1,31 @@
+{
+global:
+++ m4/visibility.m4
@@ -0,0 +1,78 @@
+# visibility.m4 serial 4 (gettext-0.18.2)
+dnl Copyright (C) 2005, 2008, 2010-2011 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+ BZ2_bzBuffToBuffCompress;
+ BZ2_bzBuffToBuffDecompress;
+ BZ2_bzCompress;
+ BZ2_bzCompressEnd;
+ BZ2_bzCompressInit;
+ BZ2_bzDecompress;
+ BZ2_bzDecompressEnd;
+ BZ2_bzDecompressInit;
+ BZ2_bzRead;
+ BZ2_bzReadClose;
+ BZ2_bzReadGetUnused;
+ BZ2_bzReadOpen;
+ BZ2_bzWrite;
+ BZ2_bzWriteClose;
+ BZ2_bzWriteClose64;
+ BZ2_bzWriteOpen;
+ BZ2_bzclose;
+ BZ2_bzdopen;
+ BZ2_bzerror;
+ BZ2_bzflush;
+ BZ2_bzlibVersion;
+ BZ2_bzopen;
+ BZ2_bzread;
+ BZ2_bzwrite;
+dnl From Bruno Haible.
+
+local: *;
+dnl Tests whether the compiler supports the command-line option
+dnl -fvisibility=hidden and the function and variable attributes
+dnl __attribute__((__visibility__("hidden"))) and
+dnl __attribute__((__visibility__("default"))).
+dnl Does *not* test for __visibility__("protected") - which has tricky
+dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on
+dnl MacOS X.
+dnl Does *not* test for __visibility__("internal") - which has processor
+dnl dependent semantics.
+dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
+dnl "really only recommended for legacy code".
+dnl Set the variable CFLAG_VISIBILITY.
+dnl Defines and sets the variable HAVE_VISIBILITY.
+
+};
+AC_DEFUN([gl_VISIBILITY],
+[
+ AC_REQUIRE([AC_PROG_CC])
+ CFLAG_VISIBILITY=
+ HAVE_VISIBILITY=0
+ if test -n "$GCC"; then
+ dnl First, check whether -Werror can be added to the command line, or
+ dnl whether it leads to an error because of some other option that the
+ dnl user has put into $CC $CFLAGS $CPPFLAGS.
+ AC_MSG_CHECKING([whether the -Werror option is usable])
+ AC_CACHE_VAL([gl_cv_cc_vis_werror], [
+ gl_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Werror"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[]], [[]])],
+ [gl_cv_cc_vis_werror=yes],
+ [gl_cv_cc_vis_werror=no])
+ CFLAGS="$gl_save_CFLAGS"])
+ AC_MSG_RESULT([$gl_cv_cc_vis_werror])
+ dnl Now check whether visibility declarations are supported.
+ AC_MSG_CHECKING([for simple visibility declarations])
+ AC_CACHE_VAL([gl_cv_cc_visibility], [
+ gl_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -fvisibility=hidden"
+ dnl We use the option -Werror and a function dummyfunc, because on some
+ dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning
+ dnl "visibility attribute not supported in this configuration; ignored"
+ dnl at the first function definition in every compilation unit, and we
+ dnl don't want to use the option in this case.
+ if test $gl_cv_cc_vis_werror = yes; then
+ CFLAGS="$CFLAGS -Werror"
+ fi
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[extern __attribute__((__visibility__("hidden"))) int hiddenvar;
+ extern __attribute__((__visibility__("default"))) int exportedvar;
+ extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
+ extern __attribute__((__visibility__("default"))) int exportedfunc (void);
+ void dummyfunc (void) {}
+ ]],
+ [[]])],
+ [gl_cv_cc_visibility=yes],
+ [gl_cv_cc_visibility=no])
+ CFLAGS="$gl_save_CFLAGS"])
+ AC_MSG_RESULT([$gl_cv_cc_visibility])
+ if test $gl_cv_cc_visibility = yes; then
+ CFLAG_VISIBILITY="-fvisibility=hidden"
+ HAVE_VISIBILITY=1
+ AC_DEFINE([BZ_EXTERN], [__attribute__((__visibility__("default")))], [To make symbol visible])
+ fi
+ fi
+ AC_SUBST([CFLAG_VISIBILITY])
+ AC_SUBST([HAVE_VISIBILITY])
+ AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY],
+ [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.])
+])
--- bzlib.h.orig
+++ bzlib.h
@@ -91,9 +91,11 @@ typedef
# endif
#else
# define BZ_API(func) func
-# define BZ_EXTERN extern
#endif
+#ifndef BZ_EXTERN
+#define BZ_EXTERN extern
+#endif
/*-- Core (low-level) library functions --*/

19
bzip2-ocloexec.patch Normal file
View File

@ -0,0 +1,19 @@
--- bzlib.c.orig
+++ bzlib.c
@@ -1414,7 +1414,15 @@ BZFILE * bzopen_or_bzdopen
}
mode++;
}
- strcat(mode2, writing ? "w" : "r" );
+
+ /* open fds with O_CLOEXEC _only_ when we are the initiator
+ * aka. bzopen() but not bzdopen() */
+ if(open_mode == 0) {
+ strcat (mode2, writing ? "we" : "re" );
+ } else {
+ strcat(mode2, writing ? "w" : "r" );
+ }
+
strcat(mode2,"b"); /* binary mode */
if (open_mode==0) {

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Sat Jan 7 19:26:14 UTC 2012 - crrodriguez@opensuse.org
- bzlib: open file descriptors with O_CLOEXEC, but just like
the zlib case, only when bzopen() is used and not bzdopen()
to avoid messing up with the caller's semantics.
It is responsability of to initiator to set that flag in such case.
- Replace error prone list of exported symbols with proper use of
GCC visibility features.
-------------------------------------------------------------------
Fri Sep 30 20:07:46 UTC 2011 - coolo@suse.com

View File

@ -1,7 +1,7 @@
#
# spec file for package bzip2
#
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -32,7 +32,7 @@ Obsoletes: bzip2-64bit
%endif
#
Group: Productivity/Archiving/Compression
License: BSD3c
License: BSD-3-Clause
Url: http://www.bzip.org/
Summary: A Program for Compressing Files
Source: bzip2-%{version}.tar.gz
@ -46,13 +46,14 @@ Patch2: bzip2-maxlen20.patch
Patch3: bzip2-faster.patch
Patch5: bzip2-unsafe_strcpy.patch
Patch6: bzip2-point-to-doc-pkg.patch
Patch7: bzip2-ocloexec.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
The bzip2 program is a very powerful program for compressing files.
%package doc
License: BSD3c
License: BSD-3-Clause
Summary: The bzip2 program and Library Documentation
Group: Productivity/Archiving/Compression
%if 0%{?suse_version} >= 1120
@ -63,7 +64,7 @@ BuildArch: noarch
The bzip2 program and library documentation.
%package -n libbz2-1
License: BSD3c
License: BSD-3-Clause
Summary: The bzip2 runtime library
Group: Productivity/Archiving/Compression
@ -71,7 +72,7 @@ Group: Productivity/Archiving/Compression
The bzip2 runtime library
%package -n libbz2-devel
License: BSD3c
License: BSD-3-Clause
Summary: The bzip2 runtime library development files
Group: Development/Libraries/Other
Requires: libbz2-1 = %{version} glibc-devel
@ -86,6 +87,7 @@ The bzip2 runtime library development files.
%patch3
%patch5
%patch6 -p1
%patch7
%build
profile_bzip2()
@ -96,7 +98,7 @@ profile_bzip2()
# time ./bzip2 $tmpfile
time ./bzip2 -d < $tmpfile.bz2 > /dev/null
}
sh ./autogen.sh
autoreconf -fiv
%if %{do_profiling}
export CFLAGS="$RPM_OPT_FLAGS %{cflags_profile_generate}"
%endif
@ -111,7 +113,7 @@ mv .libs/*.gcda .libs.save/
make clean
mv .libs.save .libs
export CFLAGS="$RPM_OPT_FLAGS %{cflags_profile_feedback}"
%configure\
%configure \
--libdir=/%{_lib}\
--disable-static
%endif
@ -133,7 +135,6 @@ install -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_mandir}/man1
%files
%defattr(-,root,root)
%doc COPYING NEWS README
%doc %{_mandir}/man1/*
%{_bindir}/*
@ -143,12 +144,12 @@ install -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_mandir}/man1
%files -n libbz2-1
%defattr(-,root,root)
%doc COPYING NEWS README
/%{_lib}/libbz2.so.1
/%{_lib}/libbz2.so.1.*
%files -n libbz2-devel
%defattr(-,root,root)
%doc LICENSE CHANGES
%{_includedir}/bzlib.h
%{_libdir}/libbz2.so
%{_libdir}/pkgconfig/bzip2.pc