LXBuild: Monitor build for C/C++ analysis

LXBuild: Monitor build for C/C++ analysis#

The lxbuild command will monitor the build and generate a buildspec file that allows the project to be created in Lattix.

To use LXBuild on Linux, please upgrade to Lattix 10.1.2 or higher.

To use LXBuild on Windows, please upgrade to Lattix 11.1 or higher. Note that on Windows, currently LXBuild works only on the json output of cmake. Therefore, on Windows, LXBuild must always include the “-j” option.


lxbuild [options...] <build-command>


lxbuild make

Specifying output filename

lxbuild -o mybuildspec.xml make
lxbuild -t mylattix.trace make
lxbuild -i mylattix.trace
lxbuild -j compile_commands.json
lxbuild -j <directory> -o buildspec.xml

Merge existing buildspec.xml files into one merged_buildspec.xml

lxbuild -o merged_buildspec.xml -m buildspec1.xml buildspec2.xml buildspec3.xml

Command Line Arguments#

The following arguments are available for lxbuild:





-o <buildspec.xml>

Output buildspec file (optional, default is buildspec.xml)

-i <lattix.trace>

Input lattix.trace file (optional)

-j <cmake.json>

Input cmake.json file (optional)

-j <directory>

Recursively find compile_commands.json in given directory (optional)

-m <buildspec files>

merge buildspec.xml files into one buildspec file

-t <lattix.trace>

Output lattix.trace file (optional)


Force overwrite of buildspec.xml file



-compile <compiler-name>

Specify an additional string to be recognized as a compiler command

-link <linker-name>

Specify an additional string to be recognized as a link command

-c <config.file>

Use specified config file to specify trace command, compiler strings, match patterns etc.

-E <config.file>

Extract default config file

How it works#

The lxbuild tool trace all the commands that get run using the “strace” command line tool (This is supported on linux only)

strace can “see” the actual programs, arguments and environment variables for each forked process, so we use that to determine how to build the model.

Compile commands are determined by keying off known compiler commands such as “gcc”, “g++”, “cc”, etc.
Link commands are determined by keying off known commands such as “ld”, “ar”, etc.

The command line arguments are examined and converted to buildspec options. Some arguments like “-I” and “-D” are simply passed through. Some arguments are used to determine which default system headers to include in the build.

File and Directory arguments are converted to absolute paths by using either the “PWD” environment variable or by tracking the “chdir” system call to determine the full path.

Each compile command keeps track of the output object files that are created.
Each link command is examined to find the input objects and match them to the correct compile command.


  1. Since lxbuild traces system calls made by all its descendant processes, it cannot trace calls that are made by a separate daemon that is not a descendant of the program run under lxbuild. For example, if you are using gradle and you are using the optional daemon process to build, please use the following commands:
    gradle --stop
    lxbuild.sh gradlew build --no-daemon
  2. One of the most common reasons for lxbuild to not pick up the files that are compiled is because the compiler name is not recognized you can update the lxbuild.config file to specify a different compiler name. You can download the lxbuild.config file, add a compiler name, update matching patterns (if necessary), and run lxbuild.