about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2019-01-13 01:48:24 +0100
committeraszlig <aszlig@nix.build>2019-01-13 01:54:19 +0100
commit2e9a9d5639385ab18a040afc894731428f70ee1f (patch)
treef45ba89e272b8ae706fa0774d71ab494fd84d2e4 /pkgs/build-support
parent581a8f30b5952ae8de0587589034bc4a338d10f2 (diff)
sandbox: Fix linking against libnixmain
Since add_DT_NEEDED_for_dynamic is no longer the default for ld[1],
we'll get a linking error like this:

  nix-query.o: undefined reference to symbol '_ZNK3nix5Store22followLinksToStorePathERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'

Unfortunately, the only way to work around this without re-enabling the
same flag is directly specify dependencies we really *should* not need
to specify because they're a transient dependency of libnixmain.

So for now I'm reverting back to the previous behaviour with
--copy-dt-needed-entries until I got time to look into it in detail.

From the ld(1) manual page:

  --copy-dt-needed-entries
  --no-copy-dt-needed-entries
    This option affects the treatment of dynamic libraries referred to
    by DT_NEEDED tags inside ELF dynamic libraries mentioned on the
    command line. Normally the linker will add a DT_NEEDED tag to the
    output binary for each library mentioned in a DT_NEEDED tag in an
    input dynamic library. With --no-copy-dt-needed-entries specified on
    the command line however any dynamic libraries that follow it will
    have their DT_NEEDED entries ignored. The default behaviour can be
    restored with --copy-dt-needed-entries.

    This option also has an effect on the resolution of symbols in
    dynamic libraries. With the default setting dynamic libraries
    mentioned on the command line will be recursively searched,
    following their DT_NEEDED tags to other libraries, in order to
    resolve symbols required by the output binary. With
    --no-copy-dt-needed-entries specified however the searching of
    dynamic libraries that follow it will stop with the dynamic library
    itself. No DT_NEEDED links will be traversed to resolve symbols.

[1]: https://github.com/NixOS/nixpkgs/commit/bcfe7af84b3628a31bfcc43dde30fc553a73adac

Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/build-sandbox/src/Makefile2
1 files changed, 1 insertions, 1 deletions
diff --git a/pkgs/build-support/build-sandbox/src/Makefile b/pkgs/build-support/build-sandbox/src/Makefile
index 199e025a..a5b9b32d 100644
--- a/pkgs/build-support/build-sandbox/src/Makefile
+++ b/pkgs/build-support/build-sandbox/src/Makefile
@@ -10,7 +10,7 @@ OBJECTS = nix-query.o path-cache.o params.o setup.o
 CFLAGS = -g -Wall -std=gnu11 -DFS_ROOT_DIR=\"$(out)\"
 CXXFLAGS = -g -Wall -std=c++14 `pkg-config --cflags nix-main`
 CXXFLAGS += -DNIX_VERSION=$(NIX_VERSION)
-LDFLAGS = `pkg-config --libs nix-main`
+LDFLAGS = -Wl,--copy-dt-needed-entries `pkg-config --libs nix-main`
 
 all: $(OBJECTS)