From 3c0feaea041525c3a209abdb86fa2d9cf343296e Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Sun, 8 Dec 2019 17:26:08 +1000 Subject: [PATCH] Update default build configs --- BUILD.txt | 29 +++++++++++++++++++++++++---- configs/mconfig.Darwin | 3 +++ configs/mconfig.FreeBSD | 12 ++++++++++-- configs/mconfig.Linux | 9 ++++++++- configs/mconfig.OpenBSD | 3 +++ 5 files changed, 49 insertions(+), 7 deletions(-) diff --git a/BUILD.txt b/BUILD.txt index 7c2f6e8..43d5fb3 100644 --- a/BUILD.txt +++ b/BUILD.txt @@ -5,10 +5,10 @@ Building Dinit should be a straight-forward process. It requires GNU make and a (GCC version 4.9 and later, or Clang ~5.0 and later, should be fine) On the directly supported operating systems - Linux, OpenBSD, FreeBSD and Darwin (macOS) - a -suitable build configuration is provided and should be used automatically. For other systems, -or to fine tune or correct the configuration, create and edit the "mconfig" file (start by -copying one for a particular OS from the "configs" directory) to choose appropriate values for -the configuration variables defined within. In particular: +suitable build configuration is provided and will be used automatically if no manual configuration +is supplied. For other systems, or to fine tune or correct the configuration, create and edit the +"mconfig" file (start by copying one for a particular OS from the "configs" directory) to choose +appropriate values for the configuration variables defined within. In particular: CXX : should be set to the name of the C++ compiler (and link driver) CXXOPTS : are options passed to the compiler during compilation (see note for GCC below) @@ -28,6 +28,27 @@ If everything goes smoothly this will build dinit, dinitctl, and optionally the utility. Use "make install" to install; you can specify an alternate installation by setting the "DESTDIR" variable, eg "make DESTDIR=/tmp/temporary-install-path install". + +Recommended Compiler options +=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +Dinit should generally build fine with no additional options, other than: + -std=c++11 : may be required to select correct C++ standard. + -D_GLIBCXX_USE_CXX11_ABI=1 : see "Special note for GCC/Libstdc++", below. Not needed for + most modern systems. + +Recommended options, supported by at least GCC and Clang, are: + -Os : optimise for size + -fno-rtti : disable RTTI (run-time type information), it is not required by Dinit. + However, on some platforms such as Mac OS (and historically FreeBSD, IIRC), this + prevents exceptions working correctly. + -fno-plt : enables better code generation for non-static builds, but may cause unit test + failures on some older versions of FreeBSD (11.2-RELEASE-p4 with clang++ 6.0.0). + -flto : perform link-time optimisation (option required at compile and link). + +Consult compiler documentation for further information on the above options. + + Other configuration variables =-=-=-=-=-=-=-=-=-=-=-=-=-=-= diff --git a/configs/mconfig.Darwin b/configs/mconfig.Darwin index 2ab837f..b6e6e08 100644 --- a/configs/mconfig.Darwin +++ b/configs/mconfig.Darwin @@ -14,3 +14,6 @@ CXXOPTS=-std=c++11 -Os -Wall -flto LDFLAGS=-flto BUILD_SHUTDOWN=no SANITIZEOPTS=-fsanitize=address,undefined + +# Notes: +# -flto (optional) : Use link-time optimisation diff --git a/configs/mconfig.FreeBSD b/configs/mconfig.FreeBSD index 36f2496..36ea49d 100644 --- a/configs/mconfig.FreeBSD +++ b/configs/mconfig.FreeBSD @@ -8,9 +8,17 @@ SYSCONTROLSOCKET=/dev/dinitctl # General build options. # FreeBSD: use clang++ by default, supports sanitizers, requires linking with -lrt -# Cannot use -fno-rtti: apparently prevents exception handling from working properly. +# Cannot use LTO with default linker. CXX=clang++ -CXXOPTS=-std=c++11 -Os -Wall +CXXOPTS=-std=c++11 -Os -Wall -fno-plt -fno-rtti LDFLAGS=-lrt BUILD_SHUTDOWN=no SANITIZEOPTS=-fsanitize=address,undefined + +# Notes: +# -fno-rtti (optional) : Dinit does not require C++ Run-time Type Information +# -fno-plt (optional) : Recommended optimisation +# -flto (optional) : Perform link-time optimisation +# -fsanitize=address,undefined : Apply sanitizers (during unit tests) +# +# Old versions of FreeBSD had issues with -fno-plt/-fno-rtti. diff --git a/configs/mconfig.Linux b/configs/mconfig.Linux index 1d73634..74ad190 100644 --- a/configs/mconfig.Linux +++ b/configs/mconfig.Linux @@ -8,9 +8,16 @@ SYSCONTROLSOCKET=/dev/dinitctl # General build options. # Linux (GCC). Note with GCC 5.x/6.x you must use the old ABI, with GCC 7.x you must use -# the new ABI. See BUILD file for more information. +# the new ABI. See BUILD.txt file for more information. CXX=g++ CXXOPTS=-D_GLIBCXX_USE_CXX11_ABI=1 -std=c++11 -Os -Wall -fno-rtti -fno-plt -flto LDFLAGS=-flto -Os BUILD_SHUTDOWN=yes SANITIZEOPTS=-fsanitize=address,undefined + +# Notes: +# -D_GLIBCXX_USE_CXX11_ABI=1 : force use of new ABI, see above / BUILD.txt +# -fno-rtti (optional) : Dinit does not require C++ Run-time Type Information +# -fno-plt (optional) : Recommended optimisation +# -flto (optional) : Perform link-time optimisation +# -fsanitize=address,undefined : Apply sanitizers (during unit tests) diff --git a/configs/mconfig.OpenBSD b/configs/mconfig.OpenBSD index acebd31..097bcbb 100644 --- a/configs/mconfig.OpenBSD +++ b/configs/mconfig.OpenBSD @@ -14,3 +14,6 @@ LDFLAGS= BUILD_SHUTDOWN=no SANITIZEOPTS= # (shutdown command not available for OpenBSD yet). + +# Notes: +# -fno-rtti (optional) : Dinit does not require C++ Run-time Type Information -- 2.25.1