BUILD 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. Building Dinit
  2. =-=-=-=-=-=-=-
  3. Building Dinit should be a straight-forward process. It requires GNU make.
  4. Edit the "mconfig" file to choose appropriate values for the configuration variables defined
  5. within. In particular:
  6. CXX : should be set to the name of the C++ compiler (and linker)
  7. CXXOPTS : are options passed to the compiler during compilation (see note for GCC below)
  8. LDFLAGS : are any extra flags required for linking; should not normally be needed
  9. (FreeBSD requires -lrt).
  10. Suitable defaults for a number of systems are provided. Note that the "eg++" or "clang++" package
  11. must be installed on OpenBSD as the default "g++" compiler is too old. Clang is part of the base
  12. system in recent releases.
  13. Then, change into the "src" directory, and run "make" (or "gmake" if the system make is not
  14. GNU make, such as on most BSD systems):
  15. cd src
  16. make
  17. If everything goes smoothly this will build dinit, dinitctl, and optionally the shutdown
  18. utility. Use "make install" to install; you can specify an alternate installation by
  19. setting the "DESTDIR" variable, eg "make DESTDIR=/tmp/temporary-install-path install".
  20. Running test suite
  21. =-=-=-=-=-=-=-=-=-
  22. Build the "check" target in order to run the test suite:
  23. make check
  24. The standard mconfig options enable various sanitizers during build of the tests. On Linux you may
  25. see an error such as the following:
  26. make[3]: Leaving directory '/home/davmac/workspace/dinit/src/tests/cptests'
  27. ./tests
  28. ==25332==ERROR: AddressSanitizer failed to allocate 0xdfff0001000 (15392894357504) bytes at
  29. address 2008fff7000 (errno: 12)
  30. ==25332==ReserveShadowMemoryRange failed while trying to map 0xdfff0001000 bytes. Perhaps
  31. you're using ulimit -v
  32. make[2]: *** [Makefile:12: run-tests] Aborted
  33. If you get this, either disable the address sanitizer or make sure you have overcommit enabled:
  34. echo 1 > /proc/sys/vm/overcommit_memory
  35. Any test failures will abort the test suite run immediately.
  36. In addition to the standard test suite, there is experimental support for fuzzing the control
  37. protocol handling using LLVM/clang's fuzzer (libFuzzer). Change to the `src/tests/cptests`
  38. directory and build the "fuzz" target:
  39. make fuzz
  40. Then create a "corpus" directory and run the fuzzer:
  41. mkdir corpus
  42. ./fuzz corpus
  43. This will auto-generate test data as it finds input which triggers new execution paths. Check
  44. libFuzzer documentation for further details.
  45. Special note for GCC/Libstdc++
  46. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  47. (Note: the issue discussed here has apparently been resolved in recent GCC versions).
  48. GCC 5.x onwards includes a "dual ABI" in its standard library implementation, aka Libstdc++.
  49. Compiling against the newer (C++11 and later) ABI can be achieved by adding
  50. -D_GLIBCXX_USE_CXX11_ABI=1 to the compiler command line; this uses a non-standard language
  51. extension to differently mangle symbol names in order to link against the new ABI versions.
  52. (Some systems may be configured to build with the new ABI by default, and in that case you
  53. build against the old ABI using D_GLIBCXX_USE_CXX11_ABI=1).
  54. This is problematic for several reasons. First, it prevents linking against the new ABI with
  55. other compilers that do not understand the language extension (LLVM i.e. clang++ does so
  56. in recent versions, so this is perhaps no longer much of a problem in practice). Secondly,
  57. some aspects of library behavior are ABI-dependent but cannot be changed using the ABI
  58. macro; in particular, exceptions thrown as a result of failed I/O operations are, in GCC
  59. versions 5.x and 6.x, always "old ABI" exceptions which cannot be caught by code compiled
  60. against the new ABI, and in GCC version 7.x they are always "new ABI" exceptions which cannot
  61. be caught by code compiled against the old ABI. Since the one library object now supposedly
  62. houses both ABIs, this means that at least one of the two ABIs is always broken.
  63. A blog post describing the dual ABI mechanism can be found here:
  64. https://developers.redhat.com/blog/2015/02/05/gcc5-and-the-c11-abi/
  65. The bug regarding the issue with catching other-ABI exceptions is here:
  66. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66145
  67. Since Dinit is affected by this bug, the unfortunate possibility exists to break Dinit by
  68. upgrading GCC. If you have libstdc++ corresponding to GCC 5.x or 6.x, you *must* build with
  69. the old ABI, but Dinit will be broken if you upgrade to GCC 7. If you have libstdc++ from
  70. GCC 7, you *must* build with the new ABI. If the wrong ABI is used, Dinit may still run
  71. successfully but any attempt to load a non-existing service, for example, will cause Dinit
  72. to crash.