Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc/manual/local.mk: handle DESTDIR= for inplace builds #6005

Closed
wants to merge 1 commit into from
Closed

doc/manual/local.mk: handle DESTDIR= for inplace builds #6005

wants to merge 1 commit into from

Conversation

trofi
Copy link
Contributor

@trofi trofi commented Jan 27, 2022

Linux distributions usually install packages into sandboxed environments before moving packages into live system:

$ ./configure --prefix=/usr
$ make install DESTDIR=/sandbox
$ mv /sandbox/* /

nix fails at make install stage:

make: *** No rule to make target '/usr/bin/nix', needed by 'doc/manual/nix.json'.  Stop.
make: *** Waiting for unfinished jobs....

The change sprinkles enough $(DESTDIR) prefixes to make it work.
To allow nix inplace execution LD_LIBRARY_PATH was added into $DESTDIR location.

Closes: #5781

Linux distributions usually install packages into sandboxed environments before moving packages into live system:

    $ ./configure --prefix=/usr
    $ make install DESTDIR=/sandbox
    $ mv /sandbox/* /

`nix` fails at `make install` stage:

    make: *** No rule to make target '/usr/bin/nix', needed by 'doc/manual/nix.json'.  Stop.
    make: *** Waiting for unfinished jobs....

The change sprinkles enough $(DESTDIR) prefixes to make it work.
To allow nix inplace execution LD_LIBRARY_PATH was added into $DESTDIR location.

Closes: #5781
@thkoch2001
Copy link
Contributor

Thank you for working on this, but please do not merge this PR, as it is not fixing the root cause. See instead this patch:
#6015

The root cause is, that something (doc/manual/local.mk) in the build-phase has prerequisites on an install-phase target ($(bindir)/nix). The fix is to depend on a build-phase target instead.

@trofi
Copy link
Contributor Author

trofi commented Jan 30, 2022

Thank you for working on this, but please do not merge this PR, as it is not fixing the root cause. See instead this patch: #6015

The root cause is, that something (doc/manual/local.mk) in the build-phase has prerequisites on an install-phase target ($(bindir)/nix). The fix is to depend on a build-phase target instead.

Heh, I think I tried it before and @edolstra rejected it in #5185. It was at time when nix did not require running itself during build process. I wonder how many more hour will people waste on it.

Does it work for you as is? I would expect $(nix_DIR)/nix not to be runnable as it links against inplace shared libraries (libnixexpr.so and so on). You would need to pass them through somehow. Say, via LD_LIBRARY_PATH= variable.

I suspect it works for you only because you already have nix installed with libraries in /usr/lib (or equivalent).

@thkoch2001
Copy link
Contributor

You can see the build log of my Debian package here:
https://buildd.debian.org/status/fetch.php?pkg=nix&arch=amd64&ver=2.6.0%2Bdfsg-1&stamp=1643544675&raw=0

When you search for "src/nix/nix" you find invocations of the inplace-build nix binary. They work. There's definitely no nix preinstalled on these machines.

I believe that this works because the nix build system is actually linking the nix binary two times for the inplace and the install target instead of linking it once and then copying it. See mk/programs.mk and these two rules:

inplace linking:

  $$($(1)_PATH): $$($(1)_OBJS) $$(_libs) | $$(_d)/
	$$(trace-ld) $(CXX) -o $$@ $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))

install-place linking:

      $(DESTDIR)$$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $(DESTDIR)$$($(1)_INSTALL_DIR)/
	$$(trace-ld) $(CXX) -o $$@ $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))

@trofi
Copy link
Contributor Author

trofi commented Jan 31, 2022

Ah, good point!

@trofi trofi closed this Mar 21, 2022
@trofi trofi deleted the fix-DESTDIR branch March 21, 2022 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build fails on DESTDIR= build environments: No rule to make target '/usr/bin/nix'
2 participants