Skip to contentSkip to conversation

next-20190826 - objtool fails to build.

DISCUSSION Valdis Klētnieks 2 participants 5 messages Aug 28, 2019 objtool

lore
Share & tools
lore
#0 lore raw

OK. I'm mystified. next-20190806 built fine. -0818 and -0826 died a glorious death indeed. All 3 were build using the same Fedora Rawhide 9.1.1 compiler (installed on July 30). 'git log -- tools/objtool' comes up empty.

Local hack-around was to remove the -Werror from tools/objtool/Makefile

Am particularly mystified by the errors on lines 808/809 - the same compiler that was happy with the same code in next-0806 is now upset. The others could possibly be a stray typedef in an include someplace, but those two errors have me stumped.

For that matter, I'm not even seeing how -Wsign-compare was even getting set, given a command 'make' and not W=1 or W=2....

(cue twilight zone theme)

CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh

  DESCEND  objtool
  HOSTCC   /usr/src/linux-next/tools/objtool/fixdep.o
  HOSTLD   /usr/src/linux-next/tools/objtool/fixdep-in.o
  LINK     /usr/src/linux-next/tools/objtool/fixdep
  CC       /usr/src/linux-next/tools/objtool/exec-cmd.o
  CC       /usr/src/linux-next/tools/objtool/help.o
  CC       /usr/src/linux-next/tools/objtool/pager.o
  CC       /usr/src/linux-next/tools/objtool/parse-options.o
  CC       /usr/src/linux-next/tools/objtool/run-command.o
  CC       /usr/src/linux-next/tools/objtool/sigchain.o
  CC       /usr/src/linux-next/tools/objtool/subcmd-config.o
  LD       /usr/src/linux-next/tools/objtool/libsubcmd-in.o
  AR       /usr/src/linux-next/tools/objtool/libsubcmd.a
  CC       /usr/src/linux-next/tools/objtool/builtin-check.o
  CC       /usr/src/linux-next/tools/objtool/builtin-orc.o
  CC       /usr/src/linux-next/tools/objtool/check.o

check.c: In function '__dead_end_function':
check.c:158:17: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
158 | for (i = 0; i < ARRAY_SIZE(global_noreturns); i++)
| ^
check.c: In function 'add_dead_ends':
check.c:330:25: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
330 | else if (rela->addend == rela->sym->sec->len) {
| ^~
check.c:372:25: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
372 | else if (rela->addend == rela->sym->sec->len) {
| ^~
check.c: In function 'add_jump_destinations':
check.c:560:36: warning: comparison of integer expressions of different signedness: 'long unsigned int' and 'int' [-Wsign-compare]
560 | if (insn->ignore || insn->offset == FAKE_JUMP_OFFSET)
| ^~
check.c: In function 'handle_jump_alt':
check.c:808:49: warning: unused parameter 'file' [-Wunused-parameter]
808 | static int handle_jump_alt(struct objtool_file *file,

      |                            ~~~~~~~~~~~~~~~~~~~~~^~~~
check.c:809:27: warning: unused parameter 'special_alt' [-Wunused-parameter]
  809 |       struct special_alt *special_alt,
      |       ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~

check.c: In function 'add_jump_table':
check.c:925:20: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
925 | rela->addend == pfunc->offset)
| ^~
check.c: In function 'read_unwind_hints':
check.c:1187:16: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
1187 | for (i = 0; i < sec->len / sizeof(struct unwind_hint); i++) {
| ^
CC /usr/src/linux-next/tools/objtool/orc_gen.o
CC /usr/src/linux-next/tools/objtool/orc_dump.o
orc_dump.c: In function 'orc_dump':
orc_dump.c:104:16: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare]
104 | for (i = 0; i < nr_sections; i++) {
| ^
CC /usr/src/linux-next/tools/objtool/elf.o
elf.c: In function 'find_section_by_index':
elf.c:41:16: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
41 | if (sec->idx == idx)
| ^~
elf.c: In function 'read_sections':
elf.c:148:16: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare]
148 | for (i = 0; i < sections_nr; i++) {
| ^
elf.c: In function 'read_relas':
elf.c:370:17: warning: comparison of integer expressions of different signedness: 'int' and 'Elf64_Xword' {aka 'long unsigned int'} [-Wsign-compare]
370 | for (i = 0; i < sec->sh.sh_size / sec->sh.sh_entsize; i++) {
| ^
CC /usr/src/linux-next/tools/objtool/special.o
special.c: In function 'get_alt_entry':
special.c:71:38: warning: unused parameter 'elf' [-Wunused-parameter]
71 | static int get_alt_entry(struct elf *elf, struct special_entry *entry,

      |                          ~~~~~~~~~~~~^~~

special.c: In function 'special_get_alts':
special.c:182:21: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
182 | for (idx = 0; idx < nr_entries; idx++) {
| ^

  CC       /usr/src/linux-next/tools/objtool/objtool.o
  CC       /usr/src/linux-next/tools/objtool/libstring.o
  CC       /usr/src/linux-next/tools/objtool/libctype.o
  CC       /usr/src/linux-next/tools/objtool/str_error_r.o
  LD       /usr/src/linux-next/tools/objtool/objtool-in.o
  LINK     /usr/src/linux-next/tools/objtool/objtool
#1 lore raw
Quoted 6 lines · Valdis Klētnieks

OK. I'm mystified. next-20190806 built fine. -0818 and -0826 died a glorious death indeed. All 3 were build using the same Fedora Rawhide 9.1.1 compiler (installed on July 30). 'git log -- tools/objtool' comes up empty.

Local hack-around was to remove the -Werror from tools/objtool/Makefile

Quoted 8 lines

Am particularly mystified by the errors on lines 808/809 - the same compiler that was happy with the same code in next-0806 is now upset. The others could possibly be a stray typedef in an include someplace, but those two errors have me stumped.

For that matter, I'm not even seeing how -Wsign-compare was even getting set, given a command 'make' and not W=1 or W=2....

(cue twilight zone theme)

Weird. I don't have access to Rawhide at the moment so I can't recreate. It builds fine for me on Fedora 29.

But I don't see how those warnings could get enabled: -Wsign-compare -Wunused-parameter.

Can you "make clean" and do "make V=1 tools/objtool" to show the actual flags?

The reported warnings do seem reasonable though, maybe we should fix them regardless and explicitly enable the warnings.

Signature · 1 line
Josh
#2 lore raw
Quoted 5 lines · Josh Poimboeuf

But I don't see how those warnings could get enabled: -Wsign-compare -Wunused-parameter.

Can you "make clean" and do "make V=1 tools/objtool" to show the actual flags?

And that tells me those warnings in fact don't get specifically enabled. (I've added some line breaks for sanity)

gcc -Wp,-MD,/usr/src/linux-next/tools/objtool/.special.o.d -Wp,-MT,/usr/src/linux-next/tools/objtool/special.o -O2 -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wbad-function-cast

Found the cause of the mystery - I changed something in a bash profile, and as a result...

export CFLAGS="-O2 -D_FORTIFY_SOURCE=2 -Wall -Wextra"

And -Wextra pulls in the things that cause problems. So this is mostly self-inflicted.

The real question then becomes - should the Makefile sanitize CFLAGS or just append to whatever the user supplied as it does currently? The rest of the tree sanitizes CFLAG, because I don't get deluged in -Wsign-compare warnings all over the place...

#3 lore raw
Quoted 18 lines · Valdis Klētnieks
Quoted 5 lines · Josh Poimboeuf

But I don't see how those warnings could get enabled: -Wsign-compare -Wunused-parameter.

Can you "make clean" and do "make V=1 tools/objtool" to show the actual flags?

And that tells me those warnings in fact don't get specifically enabled. (I've added some line breaks for sanity)

gcc -Wp,-MD,/usr/src/linux-next/tools/objtool/.special.o.d -Wp,-MT,/usr/src/linux-next/tools/objtool/special.o -O2 -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wbad-function-cast

Found the cause of the mystery - I changed something in a bash profile, and as a result...

export CFLAGS="-O2 -D_FORTIFY_SOURCE=2 -Wall -Wextra"

Quoted 7 lines

And -Wextra pulls in the things that cause problems. So this is mostly self-inflicted.

The real question then becomes - should the Makefile sanitize CFLAGS or just append to whatever the user supplied as it does currently? The rest of the tree sanitizes CFLAG, because I don't get deluged in -Wsign-compare warnings all over the place...

Agreed. I assume this fixes it?

tools/objtool/Makefile +1 -1
index 88158239622b..20f67fcf378d 100644
@@ -35,7 +35,7 @@ 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
-CFLAGS   += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS)
+CFLAGS   := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS)
 LDFLAGS  += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS)
 
 # Allow old libelf to be used:
#4 lore raw

tools/objtool/Makefile INCLUDES := -I$(srctree)/tools/include \ · line 38

Quoted 12 lines · Josh Poimboeuf
Quoted 4 lines

The real question then becomes - should the Makefile sanitize CFLAGS or just append to whatever the user supplied as it does currently? The rest of the tree sanitizes CFLAG, because I don't get deluged in -Wsign-compare warnings all over the place...

Agreed. I assume this fixes it?

tools/objtool/Makefile +1 -1
index 88158239622b..20f67fcf378d 100644
 
-CFLAGS   += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS)
+CFLAGS   := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS)

Yep, thanks. Feel free to stick these on the final version: