Skip to content

configure: support out-of-source builds#1558

Merged
axboe merged 3 commits intoaxboe:masterfrom
travisdowns:td-out-of-source-builds
Mar 24, 2026
Merged

configure: support out-of-source builds#1558
axboe merged 3 commits intoaxboe:masterfrom
travisdowns:td-out-of-source-builds

Conversation

@travisdowns
Copy link
Copy Markdown
Contributor

This adds support for out-of-source builds, so you can do:

mkdir build && cd build && ../configure && make

and keep the source tree completely clean.

This is a follow-up to the discussion in
#1557.

Out-of-source builds are useful for:

  • Maintaining parallel build configurations side-by-side (e.g.,
    debug vs release, or sanitizer builds, each in their own build
    directory)
  • Packaging systems like Bazel that expect the source tree to
    remain unmodified, relying on relative paths for hermiticity
  • General cleanliness: keeping generated artifacts out of the
    source tree

The approach is lightweight: configure detects when it is invoked
from outside the source root and generates thin wrapper Makefiles
that set a $(root) variable pointing back to the source tree. All
existing Makefiles are updated to use $(root) for source-tree
references and VPATH for finding source files. In-source builds
continue to work exactly as before.

Closes: #1557

Add support for out-of-source builds (e.g., mkdir build && cd build &&
../configure && make). This is useful for maintaining parallel build
configurations side-by-side (e.g., debug vs release with unique build
dir names), and for packaging systems like Bazel that expect the source
tree to remain clean.

configure detects when it is invoked from a directory other than the
source root, creates the necessary build subdirectories, and generates
thin wrapper Makefiles that set $(root) and include the real Makefiles.

All Makefiles now use $(root) to locate source-tree files (headers,
linker maps, scripts, man pages) and VPATH to find source files for
compilation. In-source builds continue to work as before with
$(root) defaulting to "." or "..".

Signed-off-by: Travis Downs <travis.downs@redpanda.com>
.gitignore Outdated
cscope.out

# build directories
/build
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we should add those, that's hard-wiring a convention that some may use? I know build/ is common with other build systems, but you could use anything here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, fair, I wasn't sure about this one, perhaps I did it more for my own convenience :).

I will remove this and users can add their own local ignores as necessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in ebbd32e.

@axboe
Copy link
Copy Markdown
Owner

axboe commented Mar 24, 2026

Overall looks very clean, I like it. Just one minor comment on the the gitignore parts.

Test that out-of-source builds work in CI: configure from a separate
build directory, build, install, link against the installed library,
and verify nothing leaked into the source tree.

Signed-off-by: Travis Downs <travis.downs@redpanda.com>
Signed-off-by: Travis Downs <travis.downs@redpanda.com>
@travisdowns travisdowns force-pushed the td-out-of-source-builds branch from f7120f8 to ebbd32e Compare March 24, 2026 19:11
@travisdowns
Copy link
Copy Markdown
Contributor Author

ebbd32e removes the .gitignore modifications.

@axboe axboe merged commit 26c5409 into axboe:master Mar 24, 2026
20 checks passed
travisdowns added a commit to travisdowns/redpanda that referenced this pull request Mar 25, 2026
Upgrade from 2.5 to 2.14 with a patch to work around out-of-source
build issues (bazelbuild/bazel-central-registry#8079) which itself is
hard to fix until BCR picks up axboe/liburing#1558.
travisdowns added a commit to travisdowns/redpanda that referenced this pull request Mar 25, 2026
Upgrade from 2.5 to 2.14 with a patch to work around out-of-source
build issues (bazelbuild/bazel-central-registry#8079) which itself is
hard to fix until BCR picks up axboe/liburing#1558.
travisdowns added a commit to travisdowns/bazel-central-registry that referenced this pull request Apr 1, 2026
Replace pushd/popd with symlink-based out-of-source build so that
CWD does not change and relative paths (e.g., --sysroot) resolve
correctly. Also simplify output copying to use parameter expansion
instead of realpath.

Upstream now supports out-of-source builds natively
(axboe/liburing#1558) but that landed after
the 2.14 release, so this workaround is needed for the current BCR
version.
travisdowns added a commit to travisdowns/bazel-central-registry that referenced this pull request Apr 1, 2026
Replace pushd/popd with symlink-based out-of-source build so that
CWD does not change and relative paths (e.g., --sysroot) resolve
correctly. Also simplify output copying to use parameter expansion
instead of realpath.

Upstream now supports out-of-source builds natively
(axboe/liburing#1558) but that landed after
the 2.14 release, so this workaround is needed for the current BCR
version.
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.

QUESTION: out of source builds

2 participants