-
-
Notifications
You must be signed in to change notification settings - Fork 82
Compilation Instructions
If you want to cross-compile PiSCSI on a 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 any PC. The 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.
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 NetBSD, remove this line in scsi_daynaport.h:
#include <net/ethernet.h>
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
Ignore any compiler warnings 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`.
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"
- Home
- Initial Setup
- Documentation
- Companion Apps
- Developer Notes