Repository navigation
Conversation
Nothing reads `ERL_INTERFACE_INCLUDE_DIR` or `ERL_INTERFACE_LIB_DIR`. Both are recursively expanded, so their `erl` calls never ran.
`-fPIE` appeared only in the shepherd's link flags, so the compiler never received it. The `-pie` link then worked only with compilers that produce position-independent code by default. Others failed with "recompile with -fPIE". Add `SHEPHERD_CFLAGS` with `-fPIE`, matching `NIF_CFLAGS`, and remove `-fPIE` from the link flags.
The build wrote object files into `c_src/`, so a build into another `PRIV_DIR` still changed the source tree. A parallel build into a new `PRIV_DIR` could also link before the directory existed. Compile and link each binary in one command, and remove `c_src/*.o` from `.gitignore`. Make `PRIV_DIR` an order-only prerequisite of both binaries. Remove `-I$(C_SRC_DIR)`, which the quoted includes do not need. CI now builds into a separate `PRIV_DIR` before any other build step and fails if `c_src/` or `priv/` changes.
Burrito ships a musl BEAM to hosts that may have only glibc. The NIF uses the libc that the BEAM loads, but the shepherd is a separate executable and needs its own libc. Add `SHEPHERD_STATIC=1` to link the shepherd as a static PIE. It requires a static libc, such as musl's. Reject it on macOS, which has no static libc, and with `SANITIZE=1`, because the sanitizer runtimes do not link statically. Document a cross-target build with `zig cc`, which links musl targets statically without this option. Add an Alpine CI step that links a static shepherd and checks that it is a PIE with no program interpreter and that it starts.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR makes it easier to build the shepherd executable and NIF library for deployment environments that differ from the build machine.
Previously, the build wrote intermediate object files into
c_src/, even when the final binaries were directed elsewhere. It now compiles and links each component in one step, writing all output intoPRIV_DIR. This allows packaging tools to build directly into a release directory without modifying the source tree.The change also fixes shepherd compilation and adds an option to reduce its runtime dependencies:
Compile the shepherd with
-fPIE. This produces position-independent code, which the existing linker configuration requires. Previously, builds depended on the compiler enabling this by default.Add
SHEPHERD_STATIC=1on Linux. This embeds the C library into the shepherd executable, allowing it to run on hosts where the build’s C library is unavailable. The executable remains position-independent. Unsupported macOS and sanitizer combinations produce an explicit error.Document cross-target builds. The README shows how to select a target compiler, matching Erlang runtime headers, and a release output directory. These builds must run on Linux because platform flags are selected from the build host.
Remove unused build configuration. Drop obsolete object-file rules and unused
erl_interfacelookups.The NIF remains a shared library and must be built for the Erlang runtime that will load it.
CI coverage added:
PRIV_DIRleaves the source tree unchanged.