From 2e9a9d5639385ab18a040afc894731428f70ee1f Mon Sep 17 00:00:00 2001 From: aszlig Date: Sun, 13 Jan 2019 01:48:24 +0100 Subject: 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 --- pkgs/build-support/build-sandbox/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkgs/build-support/build-sandbox') 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) -- cgit 1.4.1