Skip to content

Commit d996496

Browse files
committed
mirror: Fix flags usage for static build
The flag we've been using and documenting for static builds does the work, but is not correct: - It should be "-static" (compiler option, as expected by gcc for example) and not "--static" (linker option, gcc translates the former into the latter when invoking the linker). - It should not be passed with the CFLAGS (or in our case, EXTRA_CFLAGS), but instead with the LDFLAGS (or EXTRA_LDFLAGS), because it is a flag that will be passed to the linker. Fix it in the README.md and in CI/release workflows. Signed-off-by: Quentin Monnet <qmo@kernel.org>
1 parent 81b1c1c commit d996496

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
- name: Build bpftool, with libbfd, static build
7676
run: |
7777
make -C src clean
78-
EXTRA_CFLAGS=--static make -j -C src V=1
78+
EXTRA_LDFLAGS=-static make -j -C src V=1
7979
./src/bpftool 2>&1 | grep -q Usage
8080
./src/bpftool -p version | \
8181
tee /dev/stderr | \

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
env:
8888
LLVM_PATH: ${{ env[format('LLVM_{0}', matrix.arch)] }}
8989
run: |
90-
EXTRA_CFLAGS=--static \
90+
EXTRA_LDFLAGS=-static \
9191
LLVM_CONFIG="${GITHUB_WORKSPACE}/${{ env.LLVM_PATH }}/bin/llvm-config" \
9292
LLVM_STRIP="${GITHUB_WORKSPACE}/${{ env.LLVM_PATH }}/bin/llvm-strip" \
9393
HOSTAR="${GITHUB_WORKSPACE}/${{ env.LLVM_PATH }}/bin/llvm-ar" \
@@ -112,7 +112,7 @@ jobs:
112112
apt-get install -y make pkg-config gcc \
113113
libelf-dev libcap-dev libstdc++-11-dev zlib1g-dev && \
114114
cd /build/bpftool && \
115-
EXTRA_CFLAGS=--static \
115+
EXTRA_LDFLAGS=-static \
116116
LLVM_CONFIG='/build/${{ env.LLVM_PATH }}/bin/llvm-config' \
117117
LLVM_STRIP='/build/${{ env.LLVM_PATH }}/bin/llvm-strip' \
118118
CLANG='/build/${{ env.LLVM_PATH }}/bin/clang' \

.github/workflows/static-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Build bpftool (static build, default LLVM disassembler)
4444
working-directory: 'bpftool'
4545
run: |
46-
EXTRA_CFLAGS=--static \
46+
EXTRA_LDFLAGS=-static \
4747
LLVM_CONFIG="${GITHUB_WORKSPACE}/${LLVM_PATH}/bin/llvm-config" \
4848
LLVM_STRIP="${GITHUB_WORKSPACE}/${LLVM_PATH}/bin/llvm-strip" \
4949
make -j -C src V=1

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ example, we can create a static build with the following commands:
123123

124124
```console
125125
$ cd src
126-
$ EXTRA_CFLAGS=--static make
126+
$ EXTRA_LDFLAGS=-static make
127127
```
128128

129129
Note that to use the LLVM disassembler with static builds, we need a static
@@ -150,12 +150,12 @@ version of the LLVM library installed on the system:
150150
$ make -j -C llvm_build llvm-config llvm-libraries
151151
```
152152

153-
2. Build bpftool with `EXTRA_CFLAGS` set to `--static`, and by passing the
153+
2. Build bpftool with `EXTRA_LDFLAGS` set to `-static`, and by passing the
154154
path to the relevant `llvm-config`.
155155

156156
```console
157157
$ cd bpftool
158-
$ LLVM_CONFIG=../../llvm_build/bin/llvm-config EXTRA_CFLAGS=--static make -j -C src
158+
$ LLVM_CONFIG=../../llvm_build/bin/llvm-config EXTRA_LDFLAGS=-static make -j -C src
159159
```
160160

161161
### Build bpftool's man pages

0 commit comments

Comments
 (0)