[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#680292: gnatmake: linker arguments order incompatible with --as-needed



Package: gnat-4.6
Version: 4.6.3-4
Severity: minor

Hello. Gnatmake calls gcc -shared in a way incompatible with
--as-needed. Gprbuild uses a better ordering.

-- bug.ads
package Bug is
end Bug;
-- bug.gpr
project Bug is
  for Library_Name use "bug";
  for Library_Version use "libbug.so.1";
  for Library_Kind use "dynamic";
  for Library_Dir use "lib";
  for Library_Options use ("-lncurses");
end Bug;
$ mkdir lib
$ gnatmake -v -Pbug
...
/usr//bin/gcc-4.6 -shared ... -lncurses ... -lgnat-4.6 -Wl,-soname,libbug.so.1 /tmp/bug/bug.o
...
$ gnatclean -Pbug
...
$ gprbuild -v -Pbug
...
/usr/bin/gcc-4.6 -shared ... -lgnat-4.6 ... -Wl,-soname,libbug.so.1 /tmp/bug/bug.o -lncurses
...

When adding -Wl,--as-needed before -lncurses in Library_Options (or
using GNU gold linker with default options), symbols from -lgnat-4.6
are ignored because they are not used by any object *yet*. In this
minimal example, this is not a problem, but any useful library will
use symbols from -lgnat-4.6.

As a more real-life example, read dpkg_shlibdeps warnings when building
libtexttools-2.1.0-1 with

LDFLAGS += -Wl,--as-needed # or remove the lines stripping it
BUILDER_OPTIONS += -v

-- System Information:
ii  gcc-4.6            4.6.3-1



Reply to: