-
-
Notifications
You must be signed in to change notification settings - Fork 82
Compile‐Instructions
If you want to cross-compile PiSCSI on an Ubuntu host, you first need to install the cross compiler packages:
sudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf
To build for whatever target you're currently on
make ARCH= CROSS_COMPILE=
To build for x86_64 linux
make ARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu-
To explicitly build for ARM (ARM is also the default, so this shouldn't be necessary)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
Most of the PiSCSI code does not require the PiSCSI hardware and can be compiled, run and tested on a regular Linux PC. All unit tests do not depend on the Pi/PiSCSI hardware. In addition, `scsictl` runs on a Linux PC without restrictions, and when being launched with the -h option can manage PiSCSI on the Pi remotely.
Using the Eclipse IDE (CDT) for development helps with browsing, refactoring and unit-testing the C++ code. The SonarLint plugin helps with working on code quality issues reported by SonarCloud, even though in contrast to the SonarCloud web UI it reports some false positives.
The Makefile provides a default compiler, presently g++ from the gcc package. However alternative compilers can be used, in fact, at the time of writing clang++ v11 and later has been fully tested and proven more memory efficient and faster on certain hardware. The compiler can be set with the CXX environment variable, e.g.
export CXX="clang++"
The Makefile provides for using alternative (faster) linkers or adding linker options. Linkers like "mold", "gold" or "lld" are faster than the regular "bfd" linker. You can select the linker with the LDFLAGS, e.g.
export LDFLAGS="-fuse-ld=lld"
The choice of available/installable linkers depends on the OS platform. From the linkers mentioned above "mold" is the fastest, followed by "lld". On a Pi Zero alternative linkers save several minutes of build time.
The PiSCSI binaries can be further optimized by enabling link time optimization:
export EXTRA_FLAGS="-flto"
With a bit of tweaking the develop branch can be compiled on FreeBSD 14.0 and NetBSD 10.0 after installing some additional packages. On FreeBSD:
>pkg install clang protobuf spdlog gmake
On NetBSD:
>pkg_add clang protobuf spdlog gmake
On FreeBSD in the Makefile modify CXXFLAGS like this:
CXXFLAGS += -fexperimental-library -I/usr/local/include -O0 -g -DDEBUG
On NetBSD modify it like this:
CXXFLAGS += -fexperimental-library -I/usr/pkg/include -O0 -g -DDEBUG
Only on FreeBSD, in piscsi_service.cpp and piscsi_service.h replace "jthread" by "thread" and replace
if (bind(service_socket, reinterpret_cast<const sockaddr*>(&server),
sizeof(sockaddr_in)) < 0) { //NOSONAR bit_cast is not supported by the bullseye compiler
if (bind(service_socket, reinterpret_cast<const sockaddr*>(&server),
static_cast<socklen_t>(sizeof(sockaddr_in))) < 0) { //NOSONAR bit_cast is not supported by the bullseye compiler
Only on NetBSD, remove this line in scsi_daynaport.h:
#include <net/ethernet.h>
Only on NetBSD, remove this #ifdef block in sbc_version.cpp:
#elif defined __NetBSD__
In scsictl_core.cpp comment out these lines:
# if (optopt) {
# exit(EXIT_FAILURE);
# }
On NetBSD set LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=/usr/pkg/lib
Now you should be able to build everything on FreeBSD with
>gmake -i CXX=clang++ LDFLAGS=-L/usr/local/lib
>gmake -i CXX=clang++ LDFLAGS=-L/usr/pkg/lib
Just ignore any compiler warnings and errors or switch the warnings off in the Makefile. The only binaries you can actually make use of are `piscsi` for testing the protobuf remote interface and `scsictl`.
- Home
- Initial Setup
- Documentation
- Companion Apps
- Developer Notes