Skip to content

spack develop: stage build artifacts in same root as non-dev builds#41373

Merged
tgamblin merged 31 commits intospack:developfrom
scheibelp:features/develop-stage
Mar 14, 2024
Merged

spack develop: stage build artifacts in same root as non-dev builds#41373
tgamblin merged 31 commits intospack:developfrom
scheibelp:features/develop-stage

Conversation

@scheibelp
Copy link
Copy Markdown
Member

@scheibelp scheibelp commented Dec 1, 2023

Currently (outside of this PR) when you spack develop a path, this path is treated as the staging directory (this means that for example all build artifacts are placed in the develop path).

This PR creates a separate staging directory for all spack developed builds. It looks like:

# the stage root
/the-stage-root-for-all-spack-builds/
    spack-stage-<hash>
        # Spack packages inheriting CMakePackage put their build artifacts here
        spack-build-<hash>/

Unlike non-develop builds, there is no spack-src directory, source_path is the provided dev_path. Instead, separately, in the dev_path, we have:

/dev/path/for/foo/
    build-{arch}-<hash> -> /the-stage-root-for-all-spack-builds/spack-stage-<hash>/

The main benefit of this is that build artifacts for out-of-source builds that are relative to Stage.path are easily identified (and you can delete them with spack clean).

Other behavior added here:

  • A symlink is made from the dev_path to the stage directory. This symlink name incorporates spec details, so that multiple Spack environments that develop the same path will not conflict with one another

  • spack cd and spack location have added a -c shorthand for --source-dir

Spack builds can still change the develop path (in particular to keep track of applied patches), and for in-source builds, this doesn't change much (although logs would not be written into the develop path). Packages inheriting from CMakePackage should get this benefit automatically though.

@scheibelp scheibelp self-assigned this Dec 1, 2023
@spackbot-app spackbot-app bot added commands core PR affects Spack core functionality stage stand-alone-tests Stand-alone (or smoke) tests for installed packages tests General test capability(ies) labels Dec 1, 2023
@scheibelp scheibelp marked this pull request as draft December 1, 2023 07:48
…lure) can now generate artifacts in stage (they definitely will if e.g. including the build phase of a cmake package, but could in other cases as well)
@scheibelp scheibelp changed the title [WIP] "spack develop": stage build artifacts in same root as non-dev builds "spack develop": stage build artifacts in same root as non-dev builds Dec 20, 2023
@psakievich
Copy link
Copy Markdown
Contributor

So to confirm, the source will still default to cloning into the environment, but the spack-build-* artifacts will now be in the stage directory managed by spack? When I initially read this I thought it was the reverse of that which I would not like. Moving the spack artifacts out of the source directory would be nice though.

@tgamblin tgamblin changed the title "spack develop": stage build artifacts in same root as non-dev builds spack develop: stage build artifacts in same root as non-dev builds Feb 14, 2024
@psakievich
Copy link
Copy Markdown
Contributor

Does this PR fix the cloning and building of resources with develop specs? #25370

It seems like it has the potential too, but it is not clear to me if it does in its current form.

@scheibelp scheibelp marked this pull request as draft February 16, 2024 01:56
@scheibelp scheibelp marked this pull request as ready for review February 17, 2024 07:41
@scheibelp scheibelp requested a review from psakievich February 17, 2024 07:41
@scheibelp
Copy link
Copy Markdown
Member Author

@psakievich FYI there has been a significant change since your last review: there is no longer a symlink in the stage directory to the source directory (i.e. stages for spack developed packages no longer have a spack-src directory. There is now a symlink from the source directory to the staging directory; it was deemed useful to allow users to navigate from the source to the stage, and we didn't want t a symlink cycle (i.e. if we kept spack-src pointing to the source dir, we'd have spack-src -> <the-source> -> <source-symlink> -> <the-stage>.

@psakievich
Copy link
Copy Markdown
Contributor

Sorry just seeing this. I will try to review in the next day or two.

@tgamblin tgamblin added this to the v0.22.0 milestone Mar 14, 2024
@tgamblin tgamblin merged commit ec517b4 into spack:develop Mar 14, 2024
mathomp4 pushed a commit to mathomp4/spack that referenced this pull request Mar 27, 2024
…spack#41373)

Currently (outside of this PR) when you `spack develop` a path, this path is treated as the staging
directory (this means that for example all build artifacts are placed in the develop path).

This PR creates a separate staging directory for all `spack develop`ed builds. It looks like

```
# the stage root
/the-stage-root-for-all-spack-builds/
    spack-stage-<hash>
        # Spack packages inheriting CMakePackage put their build artifacts here
        spack-build-<hash>/
```

Unlike non-develop builds, there is no `spack-src` directory, `source_path` is the provided `dev_path`.
Instead, separately, in the `dev_path`, we have:

```
/dev/path/for/foo/
    build-{arch}-<hash> -> /the-stage-root-for-all-spack-builds/spack-stage-<hash>/
```

The main benefit of this is that build artifacts for out-of-source builds that are relative to
`Stage.path` are easily identified (and you can delete them with `spack clean`).

Other behavior added here:

- [x] A symlink is made from the `dev_path` to the stage directory. This symlink name incorporates
    spec details, so that multiple Spack environments that develop the same path will not conflict
    with one another

- [x] `spack cd` and `spack location` have added a `-c` shorthand for `--source-dir`

Spack builds can still change the develop path (in particular to keep track of applied patches), 
and for in-source builds, this doesn't change much (although logs would not be written into 
the develop path). Packages inheriting from `CMakePackage` should get this benefit
automatically though.
tgamblin pushed a commit that referenced this pull request Mar 29, 2024
After #41373, where we stopped considering the source directory to be the stage for develop builds,
we resumed *deleting* the stage even after a successful build.

We don't want this for develop builds because developers need to iterate; we should keep the artifacts
unless they explicitly run `spack clean`.  

Now:
- [x] Build artifacts for develop packages are not removed after a successful install
- [x] They are also not removed before an install starts, i.e. develop packages always 
      reuse prior artifacts, if available.
- [x] They can be deleted in any other context, e.g. by running  `spack clean --stage`
G-Ragghianti pushed a commit to G-Ragghianti/spack that referenced this pull request Apr 2, 2024
After spack#41373, where we stopped considering the source directory to be the stage for develop builds,
we resumed *deleting* the stage even after a successful build.

We don't want this for develop builds because developers need to iterate; we should keep the artifacts
unless they explicitly run `spack clean`.  

Now:
- [x] Build artifacts for develop packages are not removed after a successful install
- [x] They are also not removed before an install starts, i.e. develop packages always 
      reuse prior artifacts, if available.
- [x] They can be deleted in any other context, e.g. by running  `spack clean --stage`
RMeli added a commit to RMeli/DLA-Future-Fortran that referenced this pull request Apr 22, 2024
tldahlgren pushed a commit to tldahlgren/spack that referenced this pull request Apr 23, 2024
After spack#41373, where we stopped considering the source directory to be the stage for develop builds,
we resumed *deleting* the stage even after a successful build.

We don't want this for develop builds because developers need to iterate; we should keep the artifacts
unless they explicitly run `spack clean`.  

Now:
- [x] Build artifacts for develop packages are not removed after a successful install
- [x] They are also not removed before an install starts, i.e. develop packages always 
      reuse prior artifacts, if available.
- [x] They can be deleted in any other context, e.g. by running  `spack clean --stage`
teaguesterling pushed a commit to teaguesterling/spack that referenced this pull request Jun 15, 2024
…spack#41373)

Currently (outside of this PR) when you `spack develop` a path, this path is treated as the staging
directory (this means that for example all build artifacts are placed in the develop path).

This PR creates a separate staging directory for all `spack develop`ed builds. It looks like

```
# the stage root
/the-stage-root-for-all-spack-builds/
    spack-stage-<hash>
        # Spack packages inheriting CMakePackage put their build artifacts here
        spack-build-<hash>/
```

Unlike non-develop builds, there is no `spack-src` directory, `source_path` is the provided `dev_path`.
Instead, separately, in the `dev_path`, we have:

```
/dev/path/for/foo/
    build-{arch}-<hash> -> /the-stage-root-for-all-spack-builds/spack-stage-<hash>/
```

The main benefit of this is that build artifacts for out-of-source builds that are relative to
`Stage.path` are easily identified (and you can delete them with `spack clean`).

Other behavior added here:

- [x] A symlink is made from the `dev_path` to the stage directory. This symlink name incorporates
    spec details, so that multiple Spack environments that develop the same path will not conflict
    with one another

- [x] `spack cd` and `spack location` have added a `-c` shorthand for `--source-dir`

Spack builds can still change the develop path (in particular to keep track of applied patches), 
and for in-source builds, this doesn't change much (although logs would not be written into 
the develop path). Packages inheriting from `CMakePackage` should get this benefit
automatically though.
teaguesterling pushed a commit to teaguesterling/spack that referenced this pull request Jun 15, 2024
After spack#41373, where we stopped considering the source directory to be the stage for develop builds,
we resumed *deleting* the stage even after a successful build.

We don't want this for develop builds because developers need to iterate; we should keep the artifacts
unless they explicitly run `spack clean`.  

Now:
- [x] Build artifacts for develop packages are not removed after a successful install
- [x] They are also not removed before an install starts, i.e. develop packages always 
      reuse prior artifacts, if available.
- [x] They can be deleted in any other context, e.g. by running  `spack clean --stage`
@haampie haampie mentioned this pull request Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-systems commands core PR affects Spack core functionality shell-support stage stand-alone-tests Stand-alone (or smoke) tests for installed packages tests General test capability(ies)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants