Commit ac109604 authored by Alastair Robertson's avatar Alastair Robertson

Make dynamic linking the default

Static linking can be selected with -DSTATIC_LINKING:BOOL=ON
parent 2776c852
......@@ -55,7 +55,7 @@ find_package(LLVM REQUIRED CONFIG)
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
set(DYNAMIC_LINKING OFF CACHE BOOL "Build bpftrace as a dynamically linked executable")
set(STATIC_LINKING OFF CACHE BOOL "Build bpftrace as a statically linked executable")
add_subdirectory(src/arch)
add_subdirectory(src/ast)
......
......@@ -27,7 +27,7 @@ To use some BPFtrace features, minimum kernel versions are required:
- CMake
- Flex
- Bison
- LLVM 5.0 development packages
- LLVM & Clang 5.0 development packages
- LibElf
For example, installing the requirements on Ubuntu:
......@@ -49,13 +49,13 @@ cmake -DCMAKE_BUILD_TYPE=Debug ../
make
```
By default bpftrace will be built as a static binary to ease deployments. If a dynamically linked executable would be preferred, the CMake option `-DDYNAMIC_LINKING:BOOL=ON` can be used.
By default bpftrace will be built as a dynamically linked executable. If a statically linked executable would be preferred and your system has the required libraries installed, the CMake option `-DSTATIC_LINKING:BOOL=ON` can be used. Building bpftrace using the Docker method below will always result in a statically linked executable.
The latest versions of BCC and Google Test will be downloaded on each build. To speed up builds and only download their sources on the first run, use the CMake option `-DOFFLINE_BUILDS:BOOL=ON`.
## Using Docker
Building BPFtrace inside a Docker container is the recommended method:
Building inside a Docker container will produce a statically linked bpftrace executable.
`./build.sh`
......
set -e
mkdir -p "$1"
cd "$1"
cmake -DCMAKE_BUILD_TYPE="$2" ../
cmake -DCMAKE_BUILD_TYPE="$2" -DSTATIC_LINKING:BOOL=ON ../
shift 2
make "$@"
if (NOT DYNAMIC_LINKING)
if (STATIC_LINKING)
set(CMAKE_EXE_LINKER_FLAGS "-static")
endif()
......
if (NOT DYNAMIC_LINKING)
if (STATIC_LINKING)
set(CMAKE_EXE_LINKER_FLAGS "-static")
endif()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment