bpftool: Allow building statically
PATCH 1/1 bpftool: Allow building statically
Sometime it can be useful to haul around a statically built version of bpftool. Simply add support for passing STATIC=1 while building to build the tool statically.
---
Currently the bpftool being distributed as part of libbpf-tools under bcc project is dynamically built on a system using GLIBC 2.28, this makes the tool unusable on ubuntu 18.04 for example. Perhaps after this patch has landed the bpftool in bcc can be turned into a static binary.
tools/bpf/bpftool/Makefile | 4 ++++ 1 file changed, 4 insertions(+)
tools/bpf/bpftool/Makefile +4 -0
@@ -13,6 +13,10 @@ else Q = @ endif +ifeq ($(STATIC),1) + CFLAGS += --static +endif + BPF_DIR = $(srctree)/tools/lib/bpf ifneq ($(OUTPUT),)
--
2.25.1
2022-02-17 14:04 UTC+0200 ~ Nikolay Borisov <[email protected]>
Quoted 31 lines
Sometime it can be useful to haul around a statically built version of bpftool. Simply add support for passing STATIC=1 while building to build the tool statically.
Signed-off-by Nikolay Borisov <[email protected]>---
Currently the bpftool being distributed as part of libbpf-tools under bcc project is dynamically built on a system using GLIBC 2.28, this makes the tool unusable on ubuntu 18.04 for example. Perhaps after this patch has landed the bpftool in bcc can be turned into a static binary.
tools/bpf/bpftool/Makefile | 4 ++++ 1 file changed, 4 insertions(+)tools/bpf/bpftool/Makefile +4
-1@@ -13,6 +13,10 @@ else Q = @ endif +ifeq ($(STATIC),1) + CFLAGS += --static +endif + BPF_DIR = $(srctree)/tools/lib/bpf ifneq ($(OUTPUT),) --
Quoted 2 lines
2.25.1
Why not just pass the flag on the command line? I don't think the Makefile overwrites it:
$ CFLAGS=--static make
Quentin
Quoted 38 lines · Quentin Monnet
2022-02-17 14:04 UTC+0200 ~ Nikolay Borisov <[email protected]>
Quoted 31 lines
Sometime it can be useful to haul around a statically built version of bpftool. Simply add support for passing STATIC=1 while building to build the tool statically.
Signed-off-by Nikolay Borisov <[email protected]>---
Currently the bpftool being distributed as part of libbpf-tools under bcc project is dynamically built on a system using GLIBC 2.28, this makes the tool unusable on ubuntu 18.04 for example. Perhaps after this patch has landed the bpftool in bcc can be turned into a static binary.
tools/bpf/bpftool/Makefile | 4 ++++ 1 file changed, 4 insertions(+)tools/bpf/bpftool/Makefile +4
-1@@ -13,6 +13,10 @@ else Q = @ endif +ifeq ($(STATIC),1) + CFLAGS += --static +endif + BPF_DIR = $(srctree)/tools/lib/bpf ifneq ($(OUTPUT),) --Quoted 2 lines
2.25.1
Why not just pass the flag on the command line? I don't think the
Makefileoverwrites it:
Quoted 1 line
$ CFLAGS=--static make
Yeah, this also works, I initially thought that overriding a variable on the command line would require having the override directive in the makefile but apparently is not the case. I guess this patch can be scratched.
Quoted 3 lines
Quentin
2022-02-18 18:14 UTC+0200 ~ Nikolay Borisov <[email protected]>
Quoted 44 lines · Quentin Monnet
Quoted 41 lines
2022-02-17 14:04 UTC+0200 ~ Nikolay Borisov <[email protected]>
Quoted 32 lines
Sometime it can be useful to haul around a statically built version of bpftool. Simply add support for passing STATIC=1 while building to build the tool statically.
Signed-off-by Nikolay Borisov <[email protected]>---
Currently the bpftool being distributed as part of libbpf-tools under bcc project
is dynamically built on a system using GLIBC 2.28, this makes the tool unusable on
ubuntu 18.04 for example. Perhaps after this patch has landed the bpftool in bcc
can be turned into a static binary.
tools/bpf/bpftool/Makefile| 4 ++++1 file changed, 4 insertions(+)tools/bpf/bpftool/Makefile +0
-0@@ -13,6 +13,10 @@ elseQ = @
endiftools/bpf/bpftool/Makefile +4
-0+ifeq ($(STATIC),1) + CFLAGS += --static +endif +
BPF_DIR= $(srctree)/tools/lib/bpfQuoted 4 lines
ifneq ($(OUTPUT),)
Signature · 1 line
2.25.1Why not just pass the flag on the command line? I don't think the
Makefileoverwrites it:
Quoted 6 lines
Quoted 1 line
$ CFLAGS=--static makeYeah, this also works, I initially thought that overriding a variable on the command line would require having the override directive in the makefile but apparently is not the case. I guess this patch can be scratched.
You'd need something if the Makefile was initialising the variable, with something like "CFLAGS = -O2" or "CFLAGS := -O2". But bpftool's Makefile always uses "CFLAGS += ...", meaning it appends to the current value, so you can pass whatever you want from the command line, as long as it doesn't get overwritten by another flag (for example, passing "-O0" would not work I think, since we add "-O2" in the Makefile).
Daniel Borkmann
maintainerQuoted 47 lines · Quentin Monnet
2022-02-18 18:14 UTC+0200 ~ Nikolay Borisov <[email protected]>
Quoted 39 lines · Quentin Monnet
Quoted 38 lines
2022-02-17 14:04 UTC+0200 ~ Nikolay Borisov <[email protected]>
Quoted 23 lines
Sometime it can be useful to haul around a statically built version of bpftool. Simply add support for passing STATIC=1 while building to build the tool statically.
Signed-off-by Nikolay Borisov <[email protected]>---
Currently the bpftool being distributed as part of libbpf-tools under bcc project
is dynamically built on a system using GLIBC 2.28, this makes the tool unusable on
ubuntu 18.04 for example. Perhaps after this patch has landed the bpftool in bcc
can be turned into a static binary.tools/bpf/bpftool/Makefile | 4 ++++ 1 file changed, 4 insertions(+)tools/bpf/bpftool/Makefile +0
-0tools/bpf/bpftool/Makefile else · line 22
Quoted 10 lines
tools/bpf/bpftool/Makefile +4
-0@@ -13,6 +13,10 @@ else Q = @ endif +ifeq ($(STATIC),1) + CFLAGS += --static +endif + BPF_DIR = $(srctree)/tools/lib/bpf ifneq ($(OUTPUT),)Why not just pass the flag on the command line? I don't think the
Makefileoverwrites it:Quoted 6 lines
Quoted 1 line
$ CFLAGS=--static makeYeah, this also works, I initially thought that overriding a variable on the command line would require having the override directive in the makefile but apparently is not the case. I guess this patch can be scratched.
Quoted 6 lines
You'd need something if the
Makefilewas initialising the variable, with something like "CFLAGS = -O2" or "CFLAGS := -O2". But bpftool'sMakefilealways uses "CFLAGS += ...", meaning it appends to the current value, so you can pass whatever you want from the command line, as long as it doesn't get overwritten by another flag (for example, passing "-O0" would not work I think, since we add "-O2" in theMakefile).
We don't have an in-tree readme, but the CFLAGS=--static make use case could probably be documented in [0] at minimum.
Cheers,
Daniel
2022-02-18 20:58 UTC+0100 ~ Daniel Borkmann <[email protected]>
Quoted 56 lines · Quentin Monnet
Quoted 48 lines
2022-02-18 18:14 UTC+0200 ~ Nikolay Borisov <[email protected]>
Quoted 40 lines · Quentin Monnet
Quoted 39 lines
2022-02-17 14:04 UTC+0200 ~ Nikolay Borisov <[email protected]>
Quoted 33 lines
Sometime it can be useful to haul around a statically built version of bpftool. Simply add support for passing STATIC=1 while building to build
the tool statically.Signed-off-by Nikolay Borisov <[email protected]>---
Currently the bpftool being distributed as part of libbpf-tools under bcc project
is dynamically built on a system using GLIBC 2.28, this makes the tool unusable on
ubuntu 18.04 for example. Perhaps after this patch has landed the bpftool in bcc
can be turned into a static binary.
tools/bpf/bpftool/Makefile| 4 ++++1 file changed, 4 insertions(+)tools/bpf/bpftool/Makefile +0
-0@@ -13,6 +13,10 @@ elseQ = @
endiftools/bpf/bpftool/Makefile +4
-0+ifeq ($(STATIC),1) + CFLAGS += --static +endif +
BPF_DIR= $(srctree)/tools/lib/bpfQuoted 1 line
ifneq ($(OUTPUT),)
Why not just pass the flag on the command line? I don't think the
Makefileoverwrites it:Quoted 6 lines
Quoted 1 line
$ CFLAGS=--static makeYeah, this also works, I initially thought that overriding a variable on the command line would require having the override directive in the makefile but apparently is not the case. I guess this patch can be scratched.
Quoted 6 lines
You'd need something if the
Makefilewas initialising the variable, with something like "CFLAGS = -O2" or "CFLAGS := -O2". But bpftool'sMakefilealways uses "CFLAGS += ...", meaning it appends to the current value, so you can pass whatever you want from the command line, as long as it doesn't get overwritten by another flag (for example, passing "-O0" would not work I think, since we add "-O2" in theMakefile).
Quoted 7 lines
We don't have an in-tree readme, but the
CFLAGS=--static makeuse case could probably be documented in [0] at minimum.Cheers,
Daniel
Makes sense, I'll do this. Thanks Daniel!
Quentin