Bug 681941 - Unnecessary libicu linkage
Unnecessary libicu linkage
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: icu (Show other bugs)
rawhide
All Linux
unspecified Severity unspecified
: ---
: ---
Assigned To: Caolan McNamara
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks: ARMTracker
  Show dependency treegraph
 
Reported: 2011-03-03 11:42 EST by Jerry James
Modified: 2012-01-31 04:29 EST (History)
3 users (show)

See Also:
Fixed In Version: icu-4.8.1.1-2.fc17
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-01-31 04:29:51 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Jerry James 2011-03-03 11:42:35 EST
Description of problem:
I'm preparing a package for review and am working on eliminating rpmlint warnings.  The package has binaries that are linked against various libicu libraries.  One warning I can't get rid of is an unused-direct-shlib-dependency on /lib(64)/libm.so.6.  This turns out to be libicu's fault:

$ pkg-config --libs icu
-licui18n -licuuc -licudata -lpthread -ldl -lm

It appears that -lm is not, in fact, necessary.  So I used sed to remove -lm before linking my binary ... but rpmlint still complains.  Why?  Because the libicu libraries are themselves linked against libm:

$ rpmlint libicu
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicutu.so.44.1 /usr/lib64/libicudata.so.44
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicutu.so.44.1 /lib64/libdl.so.2
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicutu.so.44.1 /lib64/libm.so.6
libicu.x86_64: W: shared-lib-calls-exit /usr/lib64/libicutu.so.44.1 exit@GLIBC_2.2.5
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicui18n.so.44.1 /usr/lib64/libicudata.so.44
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicui18n.so.44.1 /lib64/libdl.so.2
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicule.so.44.1 /usr/lib64/libicudata.so.44
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicule.so.44.1 /lib64/libpthread.so.0
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicule.so.44.1 /lib64/libdl.so.2
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicule.so.44.1 /lib64/libm.so.6
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libiculx.so.44.1 /usr/lib64/libicudata.so.44
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libiculx.so.44.1 /lib64/libpthread.so.0
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libiculx.so.44.1 /lib64/libdl.so.2
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libiculx.so.44.1 /lib64/libm.so.6
libicu.x86_64: W: unstripped-binary-or-object /usr/lib64/libicudata.so.44.1
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicuio.so.44.1 /usr/lib64/libicudata.so.44
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicuio.so.44.1 /lib64/libpthread.so.0
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicuio.so.44.1 /lib64/libdl.so.2
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicuio.so.44.1 /lib64/libm.so.6
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicuio.so.44.1 /lib64/libgcc_s.so.1
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicutest.so.44.1 /usr/lib64/libicui18n.so.44
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicutest.so.44.1 /usr/lib64/libicudata.so.44
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicutest.so.44.1 /lib64/libpthread.so.0
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicutest.so.44.1 /lib64/libdl.so.2
libicu.x86_64: W: unused-direct-shlib-dependency /usr/lib64/libicutest.so.44.1 /lib64/libm.so.6
1 packages and 0 specfiles checked; 0 errors, 25 warnings.

Version-Release number of selected component (if applicable):
libicu-4.4.1-6.fc14.x86_64

How reproducible:
Always.

Steps to Reproduce:
1. See above.
2.
3.
  
Actual results:
The libicu libraries are unnecessarily linked against various libraries, and also pkg-config reports an unnecessary -lm requirement.

Expected results:
No unnecessary linkage, and pkg-config reports only what is really necessary.

Additional info:
I'm happy to help with fixing this, if you like.  Also, are there any plans for an update to 4.4.2 or 4.6?
Comment 1 Caolan McNamara 2011-03-03 12:02:43 EST
Sure, cook up a patch.

There won't be any updates for Fedora 14 to move icu to a new version, icu upgrades change all the symbol names so would have to rebuild a crazy amount of packages. But good for rawhide, haven't had the time to look at bumping rawhide icu to 4.6 yet.
Comment 2 Caolan McNamara 2011-03-07 05:56:15 EST
bumping rawhide to 4.6, dropping -lm as well from direct .so link flags
Comment 3 Caolan McNamara 2011-03-07 06:12:49 EST
done in rawhide (I think, rpmlint doesn't moan anyway)
Comment 4 Jerry James 2011-03-08 13:01:44 EST
Really?  I'm getting exactly the same output from rpmlint on rawhide after building from git head.  Are you running rpmlint on the binary RPMs, or on the installed packages?  As far as I know, the linkage tests cannot be run on the former.

I applied the following patch to the spec file and eliminated all of the warnings about unnecessary links.  The -nostdlib flag appears to be necessary to avoid picking up -lm transitively.

diff --git a/icu.spec b/icu.spec
index 4353f4b..5bb0db3 100644
--- a/icu.spec
+++ b/icu.spec
@@ -12,7 +12,6 @@ Requires: lib%{name} = %{version}-%{release}
 
 Patch1: icu.8198.revert.icu5431.patch
 Patch2: icu.8320.freeserif.crash.patch
-Patch3: icu.rhbz681941.extralinklm.patch
 
 %description
 Tools and utilities for developing with icu.
@@ -54,7 +53,6 @@ BuildArch: noarch
 %setup -q -n %{name}
 %patch1 -p2 -R -b .icu8198.revert.icu5431.patch
 %patch2 -p1 -b .icu8320.freeserif.crash.patch
-%patch3 -p1 -b .rhbz681941.extralinklm.patch
 
 %build
 cd source
@@ -64,6 +62,13 @@ CXXFLAGS='%optflags -fno-strict-aliasing'
 %configure --with-data-packaging=library --disable-samples
 #rhbz#225896
 sed -i -- "s/-nodefaultlibs -nostdlib//" config/mh-linux
+#rhbz#681491
+sed -i 's|^LIBS =.*|LIBS = -L../lib -licuuc -lpthread -lm|' i18n/Makefile
+sed -i 's|^LIBS =.*|LIBS = -nostdlib -L../lib -licuuc -licui18n -lc|' io/Makefie
+sed -i 's|^LIBS =.*|LIBS = -nostdlib -L../lib -licuuc -lc|' layout/Makefile
+sed -i 's|^LIBS =.*|LIBS = -nostdlib -L../lib -licuuc -licule -lc|' layoutex/Makefile
+sed -i 's|^LIBS =.*|LIBS = -nostdlib -L../../lib -licutu -licuuc -lc|' tools/ctestfw/Makefile
+sed -i 's|^LIBS =.*|LIBS = -nostdlib -L../../lib -licui18n -licuuc -lpthread -lc|' tools/toolutil/Makefile
 make # %{?_smp_mflags} # -j(X>1) may "break" man pages as of 3.2, b.f.u #2357
 make doc
 

The last hunk of this patch also fixes the problem on Fedora 15 with 4.4.2, by the way.  I don't know if you want to mess with it at this point, where so many packages depend on libicu, but there's a solution if you want it.
Comment 5 Caolan McNamara 2011-03-08 15:43:22 EST
"Are you running rpmlint on the binary RPMs, or on the installed packages?"

ah, indeed, on the rpms. So shovelled your patch in there instead now, for rawhide.
Comment 6 Jerry James 2011-03-10 10:49:41 EST
Thank you very much!
Comment 7 Jon Masters 2012-01-30 16:02:09 EST
Hello Jerry, Caolan,

I understand how frustrating it can be to have a few extra libraries linked against an application if you are trying to be as minimal as possible, and I understand the intention behind including these sed scripts. However, I have re-opened this bug because the change that has been made to icu to avoid linking in the math library has had an unfortunate consequence of introducing an unrelated FTBFS on ARM. Let me summarize what the breakage was, then offer some advice that I hope will be helpful as you try to find an alternative solution that is less heavyweight than the one that is currently used.

A slight digression into GCC atomic functions within libgcc...On ARM systems, "intrinsic" functions like __sync_synchronize are implemented differently from x86. On x86 systems, such calls are replaced at compile time with inline assembly code that performs a data memory barrier. On ARM, the call is to a real function that is implemented within libgcc. The same is true on some other architectures. Beyond that, libgcc provides many useful functions that could be needed in future updates of this package on any architecture. Therefore, it is very important that libgcc is always available, which it is unless gcc is specifically told not to include it during link time :) There are other similar libraries that can be required, making it very difficult to use "nostdlib".

The current icu SPEC file intends to tell gcc not to use any of its standard libraries, and then lists those libraries that it should be linking against. While this will prevent unwanted linkage against the math library, it also causes gcc to no longer link against libgcc, and may cause other important libraries to be missed during linkage. As a temporary fix solely for the ARM problem, it is possible to include "-lgcc" during the build of the "io" LIBS in the io/Makefile, but I do not believe that is a long term solution to this bug because a similar issue may cause breakage in the future. In general, I would recommend strongly not to use "nostdlib" or similar, and find an alternative.

Please can I request the following one line change in the interim:

sed -i 's|^LIBS =.*|LIBS = -nostdlib -L../lib -licuuc -licui18n -lc|' io/Makefile

to this line:

sed -i 's|^LIBS =.*|LIBS = -nostdlib -L../lib -licuuc -licui18n -lc -lgcc|' io/Makefile

That will allow icu to build on rawhide for ARM systems, and pass the tests. I would strongly recommend an alternative to the current sed scripts in the longer term, but I am quite sure that you had that in mind anyway.

Thanks very much,

Jon.
Comment 8 Caolan McNamara 2012-01-31 04:29:51 EST
I see that change went into rawhide already

Note You need to log in before you can comment on or make changes to this bug.