Building Guide (test)

From liblfds.org
Jump to navigation Jump to search

Introducton

The test binary is a thin command line veneer which provides convenient access to the test functionality in libtest. The binary depends on liblfds710, libtest and libshared.

The test library uses a porting abstraction layer to mask platform differences. Building test requires build files (makefile, etc) for your toolchain (GCC, gnumake, etc) and a port of the abstraction layer to your platform.

A small number of popular toolchains are supported out-of-the-box, along with porting abstraction layers which cover Windows (user-mode) and Linux (user-mode).

Supported Toolchains

The supported toolchains are;

  • GCC and gnumake
  • MSVC and gnumake (yes, gnumake, not nmake)

Note that in 7.1.0, Visual Studio solution files are not provided. This is because there are over liblfds and the benchmark and benchmark libraries and programmes (seven projects in all) in the end due to the multple build variants (debug, release, library, DLL, kernel library, kernel DLL, and repeated twice, once for VS2012 and once for VS2013) what comes to something like ten thousand settings, all of which have to be set using a mouse and a GUI, which is not only extraordinarily time-consuming and error-prone, but emotionally agonizing.

Mac support is not available due to lack of access to a Mac.

Directory Structure

└── test_and_benchmark
    └── test                  : test command line veneer
        ├── bin               : output directory - the binary ends up here
        ├── build             : build configuration directory - contains one directory per platform
        │   ├── gcc_gnumake   : GCC, gnumake, hosted implementation
        │   └── msvc_gnumake  : Microsoft Visual C (command line compiler) and gnumake
        ├── obj               : temporary directory for object files
        └── src               : the source files

Building

The library directory tree contains at its top level directory called build.

This directory contains one directory per supported toolchain, where each such directory contains the files necessary to build for that toolchain. Detailed descriptions of how to build for each toolchain are given below, with one heading per toolchain.

The test binary depends on liblfds710, libtest and libshared. The test build files are harcoded with relative paths to find the output from these libraries, so these libraries do not need to be installed.

On all platforms, you need to clean between changing build types (debug, release, static, dynamic, profiled, etc), as there is only one directory used to hold object files.

Per-Toolchain Build Instructions

GCC and gnumake

└── test_and_benchmark
    └── test
        └── build
            └── gcc_gnumake
                    Makefile

To build, install GCC and gnumake, enter the build directory and type;

make

The following targets are available;

cov     : coverage
dbg     : debug
prof    : profiling
rel     : release
tsan    : thread sanitizer
vanilla : no specific-build arguments

clean   : what you'd expect

When switching from one target to another, clean must be made.

If building *_ar_tsan, libtsan must be installed. This is not necessary if building *_so_tsan.

If building for ARM32 with shared object versions of the liblfds libraries, linking will fail, with the error "/usr/bin/ld: ../../bin/test: hidden symbol `__aeabi_uidiv' in /usr/lib/gcc/arm-linux-gnueabihf/4.9/libgcc.a(_udivsi3.o) is referenced by DSO". This means something has attempted to divide a 64 bit value by a 64 bit value, an operation which apparently is costly and usually unnecessary, a 32 bit divisor apparently is normally adequate, and as such is intentionally caught in a link-breaking way.

Unfortunately, as far as can be determined, liblfds itself is not performing this operation - and as such, it is not obvious how to fix it.

MSVC and gnumake

└── test_and_benchmark
    └── test
        └── build
            └── msvc_gnumake
                    makefile

To build, install an MSVC command line compiler, enter the build directory and type;

make

The following targets are available;

dlldbg  : debug   (with liblfds libs built as DLLs)
dllrel  : release (with liblfds libs built as DLLs)
libdbg  : debug   (with liblfds libs built as libs)
librel  : release (with liblfds libs built as libs)

clean   : what you'd expect

When switching from one target to another, clean must be made.

See Also