objtool: Be lenient about -Wundef
PATCH 1/1 objtool: Be lenient about -Wundef
Some libelf versions use undefined macros, which combined with newer GCC makes for errors from system headers. This isn't overly useful to fail compiling objtool for.
Error as seen:
cc1: all warnings being treated as errors
In file included from arch/x86/../../elf.h:10,
from arch/x86/decode.c:14:
/usr/include/libelf/gelf.h:25:5: error: "__LIBELF_INTERNAL__" is not defined, evaluates to 0 [-Werror=undef]
#if __LIBELF_INTERNAL__
^~~~~~~~~~~~~~~~~~~For this reason, skip -Wundef on objtool.
--- tools/objtool/Makefile | 2 ++ 1 file changed, 2 insertions(+)
tools/objtool/Makefile +2 -0
@@ -35,6 +35,8 @@ INCLUDES := -I$(srctree)/tools/include \ -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ -I$(srctree)/tools/objtool/arch/$(ARCH)/include WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed +# Some system libelf versions uses undefined "#if <var>", so skip the warning/error +WARNINGS += -Wno-undef CFLAGS += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS)
Signature · 1 line
2.11.0
Quoted 8 lines · Olof Johansson
Some libelf versions use undefined macros, which combined with newer GCC makes for errors from system headers. This isn't overly useful to fail compiling objtool for.
Error as seen:
cc1: all warnings being treated as errors
In file included fromarch/x86/../../elf.h:10,
Quoted 8 lines
from arch/x86/decode.c:14: /usr/include/libelf/gelf.h:25:5: error: "__LIBELF_INTERNAL__" is not defined, evaluates to 0 [-Werror=undef] #if __LIBELF_INTERNAL__ ^~~~~~~~~~~~~~~~~~~For this reason, skip -Wundef on objtool.
Signed-off-by Olof Johansson <[email protected]>
Sorry for the delay, I was out last week and I'm still getting caught up.
Which libelf was this? I'm guessing it's the old non-elfutils version which has been unmaintained for 10 years (and which doesn't work with objtool anyway).
It would be nice if we could figure out a way to detect that libelf and report a more useful error for it.
Signature · 1 line
Josh
Quoted 22 lines · Josh Poimboeuf
Quoted 8 lines · Olof Johansson
Some libelf versions use undefined macros, which combined with newer GCC makes for errors from system headers. This isn't overly useful to fail compiling objtool for.
Error as seen:
cc1: all warnings being treated as errors
In file included fromarch/x86/../../elf.h:10,Quoted 8 lines
from arch/x86/decode.c:14: /usr/include/libelf/gelf.h:25:5: error: "__LIBELF_INTERNAL__" is not defined, evaluates to 0 [-Werror=undef] #if __LIBELF_INTERNAL__ ^~~~~~~~~~~~~~~~~~~For this reason, skip -Wundef on objtool.
Signed-off-by Olof Johansson <[email protected]>Sorry for the delay, I was out last week and I'm still getting caught up.
Quoted 6 lines
Which libelf was this? I'm guessing it's the old non-elfutils version which has been unmaintained for 10 years (and which doesn't work with objtool anyway).
It would be nice if we could figure out a way to detect that libelf and report a more useful error for it.
Yeah, looks like my docker image pulled in the very old libelf 0.8.13, but has elfutils available. I'll switch it over locally to resolve this.
-Olof