Overview
When building for multiple target architectures sequentially in a CI pipeline for an Elixir project that preserves the deps/ directory across stages, ezstd fails to link due to stale object files from previous architecture builds.
Description
In CI pipelines that build for multiple architectures (e.g. first armhf, then amd64) while caching/preserving the deps/ directory between stages, the build system does not clean or rebuild c_src/ezstd_nif.o for the new target architecture. This causes the linker to fail when it encounters an object file compiled for a different architecture:
🖥️ Detected system configuration:
➤ OS Type : Linux
➤ OS Name : PRETTY_NAME="Debian
➤ CPU Cores : 12
✅ zstd already exists at _build/deps/zstd/lib/libzstd.a
To rebuild, delete: _build/deps/zstd
make[1]: Entering directory '/builds/devs/retina/deps/ezstd/c_src'
LD ezstd_nif.so
/usr/bin/ld: /builds/devs/retina/deps/ezstd/c_src/ezstd_nif.o: relocations in generic ELF (EM: 40)
/usr/bin/ld: /builds/devs/retina/deps/ezstd/c_src/ezstd_nif.o: relocations in generic ELF (EM: 40)
/usr/bin/ld: /builds/devs/retina/deps/ezstd/c_src/ezstd_nif.o: relocations in generic ELF (EM: 40)
/usr/bin/ld: /builds/devs/retina/deps/ezstd/c_src/ezstd_nif.o: relocations in generic ELF (EM: 40)
/usr/bin/ld: /builds/devs/retina/deps/ezstd/c_src/ezstd_nif.o: relocations in generic ELF (EM: 40)
/usr/bin/ld: /builds/devs/retina/deps/ezstd/c_src/ezstd_nif.o: relocations in generic ELF (EM: 40)
/usr/bin/ld: /builds/devs/retina/deps/ezstd/c_src/ezstd_nif.o: relocations in generic ELF (EM: 40)
/usr/bin/ld: /builds/devs/retina/deps/ezstd/c_src/ezstd_nif.o: relocations in generic ELF (EM: 40)
/usr/bin/ld: /builds/devs/retina/deps/ezstd/c_src/ezstd_nif.o: relocations in generic ELF (EM: 40)
/usr/bin/ld: /builds/devs/retina/deps/ezstd/c_src/ezstd_nif.o: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
make[1]: *** [nif.mk:78: /builds/devs/retina/_build/prod/lib/ezstd/priv/ezstd_nif.so] Error 1
make[1]: Leaving directory '/builds/devs/retina/deps/ezstd/c_src'
make: *** [Makefile:7: compile_nif] Error 2
===> Hook for compile failed!
Steps to Reproduce:
- Build project with ezstd dependency for architecture A (e.g., armhf)
- Preserve/cache the deps/ directory
- Build project for architecture B (e.g., amd64) using the same deps/ directory
- Linking fails with "file in wrong format" error
Suggested Solution
Build artifacts should be stored in _build/$MIX_ENV/lib/ezstd when building as part of an Elixir project. I am not sure what the proper solution is for erlang projects.
Thank you!
Overview
When building for multiple target architectures sequentially in a CI pipeline for an Elixir project that preserves the
deps/directory across stages, ezstd fails to link due to stale object files from previous architecture builds.Description
In CI pipelines that build for multiple architectures (e.g. first
armhf, thenamd64) while caching/preserving thedeps/directory between stages, the build system does not clean or rebuildc_src/ezstd_nif.ofor the new target architecture. This causes the linker to fail when it encounters an object file compiled for a different architecture:Steps to Reproduce:
Suggested Solution
Build artifacts should be stored in
_build/$MIX_ENV/lib/ezstdwhen building as part of an Elixir project. I am not sure what the proper solution is for erlang projects.Thank you!