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

"make distclean" should not run "./configure" #29310

Closed
jhpalmieri opened this issue Mar 10, 2020 · 33 comments
Closed

"make distclean" should not run "./configure" #29310

jhpalmieri opened this issue Mar 10, 2020 · 33 comments

Comments

@jhpalmieri
Copy link
Member

As the summary says. It may be good enough to move the targets clean, sagelib-clean, build-clean, doc-clean, doc-src-clean, and doc-output-clean from build/make/deps to the top-level Makefile.

This would make things faster and more quiet.

Related:

CC: @jhpalmieri @mkoeppe @slel

Component: build

Keywords: quiet, speed

Author: John Palmieri

Branch: e28f093

Reviewer: Matthias Koeppe

Issue created by migration from https://trac.sagemath.org/ticket/29310

@jhpalmieri jhpalmieri added this to the sage-9.1 milestone Mar 10, 2020
@mkoeppe
Copy link
Member

mkoeppe commented Mar 29, 2020

comment:1

See also:

@mkoeppe mkoeppe modified the milestones: sage-9.1, sage-9.2 Apr 15, 2020
@jhpalmieri
Copy link
Member Author

comment:3

This could presumably be fixed by #29316.

@mkoeppe mkoeppe modified the milestones: sage-9.2, sage-9.3 Aug 29, 2020
@slel
Copy link
Member

slel commented Sep 7, 2020

comment:5

Replying to @jhpalmieri:

This could presumably be fixed by #29316.

Apparently not.

@slel
Copy link
Member

slel commented Sep 7, 2020

Changed keywords from none to quiet, speed

@slel

This comment has been minimized.

@mkoeppe
Copy link
Member

mkoeppe commented Feb 13, 2021

comment:7

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 Feb 13, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Jul 19, 2021
@mkoeppe
Copy link
Member

mkoeppe commented Oct 24, 2021

comment:9

Also, in 9.4.beta5 I am getting with make distclean:

/bin/sh: /Users/mkoeppe/s/sage/sage-rebasing/worktree-rebase/build/pkgs/sagelib/spkg-uninstall: No such file or directory

@jhpalmieri
Copy link
Member Author

comment:10

Can we naively define SAGE_ROOT, SAGE_SHARE, SAGE_LOCAL, and SAGE_SRC in the top-level Makefile, and then move the various clean targets to that file? I think that will solve the problem mentioned in this ticket, but I don't know how careful we need to be about setting those variables.

@jhpalmieri
Copy link
Member Author

comment:11

I'm confused by the logic here. I think that the issues arise from these lines in Makefile:

# Defer unknown targets to build/make/Makefile
%::
	@if [ -x relocate-once.py ]; then ./relocate-once.py; fi
	$(MAKE) build/make/Makefile --stop
	+build/bin/sage-logger \
		"cd build/make && ./install '$@'" logs/install.log

So that's why I want to move the cleaning targets to the top-level Makefile. SAGE_LOCAL should be set by the ./configure script, depending on the --prefix argument (for example), but we want make distclean to work regardless of whether ./configure has been run. Part of make distclean already does rm -rf local. We have the following uses of SAGE_ variables in the cleaning targets:

  • rm -rf "$(SAGE_LOCAL)/var/tmp/sage/build"
  • cd "$(SAGE_SRC)" && (do some stuff)
  • cd "$(SAGE_ROOT)/build/pkgs/sagelib/src/" && rm -rf build
  • (cd "$(SAGE_ROOT)/build/pkgs/sage_docbuild/src" && rm -rf build)
  • (cd "$(SAGE_ROOT)/build/pkgs/sage_setup/src" && rm -rf build)
  • cd "$(SAGE_SRC)/doc" && $(MAKE) clean
  • rm -rf "$(SAGE_SHARE)/doc/sage"

@mkoeppe
Copy link
Member

mkoeppe commented Oct 29, 2021

comment:12

Moving the cleaning targets to the top-level Makefile could make sense.

Most of the above lines really don't need configured variables.

For cleaning within SAGE_LOCAL (and SAGE_VENV):

As you say, make distclean unconditionally removes all of SAGE_ROOT/local. But if --prefix has been used to set SAGE_LOCAL to something else, that tree is not removed (and it should not; see discussion in #21775).

So it only matters what is to be done when SAGE_LOCAL has been set to something else.

To run a line such as rm -rf "$(SAGE_LOCAL)/var/tmp/sage/build", we could try to source SAGE_ROOT/src/bin/sage-src-env-config, which defines the configured SAGE_LOCAL and SAGE_VENV. If that fails (because configure has not run), do nothing.

I'm not sure about rm -rf "$(SAGE_SHARE)/doc/sage". This not only removes build artifacts such as the inventory files, but it also uninstalls the built HTML documentation. I don't think this should be done by any target called ...-clean.
(see #29097 - build/make/Makefile.in: Rename make targets SPKG-clean to SPKG-uninstall)

@jhpalmieri
Copy link
Member Author

Branch: u/jhpalmieri/distclean

@jhpalmieri
Copy link
Member Author

comment:14

Here is an attempt. A few comments:

  • I added the line if [ -d "$(SAGE_SRC)" ]; then \ because I kept making mistakes which resulted in SAGE_SRC not being set, and then the ensuing lines did things like cd $(SAGE_SRC) && rm -rf build which ended up being bad. So this is a safety net.
  • The new target doc-uninstall is not currently used anywhere. Maybe it should be.

New commits:

c7cfd31trac 29310: move various ...-clean targets to top-level Makefile

@jhpalmieri
Copy link
Member Author

Commit: c7cfd31

@jhpalmieri
Copy link
Member Author

comment:15

Oh, and I used $(shell pwd) when setting SAGE_ROOT because (with what I think is a non-GNU make on OS X) it was the only way I found to set SAGE_ROOT and have it expand immediately when being set. When I tried something like

SAGE_ROOT = $$(pwd)

clean-test:
    echo $(SAGE_ROOT)

then make clean-test would print

echo $(pwd)
/Users/palmieri/....

With the current version, if I add the same target clean-test, then make clean-test prints

echo /Users/...
/Users/...

It seems safest to have SAGE_ROOT defined once, not defined in terms of pwd which could change in the middle of a recipe.

@mkoeppe
Copy link
Member

mkoeppe commented Oct 29, 2021

comment:16

Try $(CURDIR)

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 29, 2021

Changed commit from c7cfd31 to d3d1405

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 29, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

d3d1405trac 29310: use CURDIR

@jhpalmieri
Copy link
Member Author

comment:18

Replying to @mkoeppe:

Try $(CURDIR)

Thanks, done.

@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 14, 2021
@jhpalmieri
Copy link
Member Author

comment:20

I think this is ready for review.

@jhpalmieri
Copy link
Member Author

Author: John Palmieri

@mkoeppe
Copy link
Member

mkoeppe commented Dec 17, 2021

comment:22
+SAGE_ROOT ?= $(CURDIR)
+SAGE_SRC ?= $(SAGE_ROOT)/src

I think it would be safer to just use = instead of ?=. We don't want environment variable settings to be used here

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 17, 2021

Changed commit from d3d1405 to 67d69da

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 17, 2021

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

f53be61trac 29310: move various ...-clean targets to top-level Makefile
3a7712etrac 29310: use CURDIR
67d69datrac 29310: use "=" instead of "?="

@jhpalmieri
Copy link
Member Author

comment:24

Fixed, thanks.

@mkoeppe
Copy link
Member

mkoeppe commented Dec 20, 2021

comment:25
+clean:
+	@echo "Deleting package build directories..."
+	if [ -x "$(SAGE_SRC)"/bin/sage-env-config ]; then \
+	    . "$(SAGE_SRC)"/bin/sage-env-config; \
+            rm -rf "$(SAGE_LOCAL)/var/tmp/sage/build"; \
+	fi

The reference to SAGE_LOCAL does not work - the syntax $(...) is referring to a Make variable, but you want a shell variable. So $$... should be used instead.

Also, for extra safety, best to test that the variable is nonempty before passing it to rm -rf...

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 21, 2021

Changed commit from 67d69da to e28f093

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 21, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

e28f093trac 29310: use $$SAGE_LOCAL instead of $(SAGE_LOCAL) --

@jhpalmieri
Copy link
Member Author

comment:27

It was okay because that branch wasn't being run anyway, since sage-env-config is not executable. Fixed now.

@mkoeppe
Copy link
Member

mkoeppe commented Dec 23, 2021

comment:28

LGTM and seems to work well.

@mkoeppe
Copy link
Member

mkoeppe commented Dec 23, 2021

Reviewer: Matthias Koeppe

@jhpalmieri
Copy link
Member Author

comment:30

Thank you!

@vbraun
Copy link
Member

vbraun commented Dec 28, 2021

Changed branch from u/jhpalmieri/distclean to e28f093

@mkoeppe
Copy link
Member

mkoeppe commented Dec 28, 2021

Changed commit from e28f093 to none

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants