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

Re: [FTBFS] PolyORB debug under kfreebsd



On Sun, Jun 24, 2012 at 10:42:55PM +0200, Eugeniy Meshcheryakov wrote:

> > But now this is the -Wl,-as-needed option that causes the error message.
> > If I compile without this flag, no more missing symbols.
> Hi this could be bug in gnat or somewhere else that passes options in
> the incorrect order. Compare these two commands:
>    eugen@loki:/tmp% gcc -o main main.o -Wl,--as-needed test1.so test2.so 
>    eugen@loki:/tmp% gcc -o main -Wl,--as-needed test1.so test2.so main.o 
>    main.o: In function `main':
>    main.c:(.text+0xf): undefined reference to `test2'
> The linker looks for symbols needed for objects that come _before_ the
> --as-needed option.

It ignores libraries that do not define at least a symbol needed by
previous objects. The --as-needed options is intended for that, see
http://www.gentoo.org/proj/en/qa/asneeded.xml. Two sections deal with
the kind of problem you are encountering:
 - Failure in final linking, undefined symbols
 - Importance of linking order

I would advice to remove the flag from debian/rules:
## (with a trick because the comma also is a Make separator)
comma := ,
LDFLAGS := $(filter-out -Wl$(comma)--as-needed,$(LDFLAGS))
##
so that you can activate it again once the problem it reveals is
solved. If the problem is that
- dh_shlibdeps warns about polyorb depending on a library and not
  using any of its symbols, or
- your package fails to build from scratch with the GNU gold linker,
you may ignore it happily until the freeze happens.

In the long run, the right patch is to order the -l options during the
linker invokation. This can be tricky: even a correct gpr file
mixes -lxxx flags (LDLIBS) and -Wlxxxx flags (LDFLAGS). Replacing
gnatmake with gprbuild may sometimes solve the problem, as the latter
generates a different (better?) linker invokation, and understands
some workarounds as described in

## http://docs.adacore.com/gprbuild-docs/html/gprbuild_ug.html
Library_Options:
    This attribute may be used to specify additional switches (last switches) when linking a shared library.
Leading_Library_Options:
    This attribute, that is taken into account only by gprbuild, may be used to specified leading options (first switches) when linking a shared library.

Linker.Linker_Options:
    This attribute specifies additional switches to be given to the linker when linking an executable. It is ignored when defined in the main project and taken into account in all other projects that are imported directly or indirectly. These switches complement the Linker.Switches defined in the main project. This is useful when a particular subsystem depends on an external library: adding this dependency as a Linker_Options in the project of the subsystem is more convenient than adding it to all the Linker.Switches of the main projects that depend upon this subsystem.
##

PS: This is unrelated, but you should insert $(CPPFLAGS) before
$(CFLAGS) in the two lines compiling the .c file in debian/rules.
Else, log checkers will complain that hardening flags like
"-DFORTIFY…" are missing.


Reply to: