Skip to content

Commit

Permalink
kbuild: Add -Wa,--fatal-warnings to as-instr invocation
Browse files Browse the repository at this point in the history
Certain assembler instruction tests may only induce warnings from the
assembler on an unsupported instruction or option, which causes as-instr
to succeed when it was expected to fail. Some tests workaround this
limitation by additionally testing that invalid input fails as expected.
However, this is fragile if the assembler is changed to accept the
invalid input, as it will cause the instruction/option to be unavailable
like it was unsupported even when it is.

Use '-Wa,--fatal-warnings' in the as-instr macro to turn these warnings
into hard errors, which avoids this fragility and makes tests more
robust and well formed.

Cc: [email protected]
Suggested-by: Eric Biggers <[email protected]>
Signed-off-by: Nathan Chancellor <[email protected]>
Tested-by: Eric Biggers <[email protected]>
Tested-by: Andy Chiu <[email protected]>
Reviewed-by: Andy Chiu <[email protected]>
Tested-by: Conor Dooley <[email protected]>
Reviewed-by: Conor Dooley <[email protected]>
Acked-by: Masahiro Yamada <[email protected]>
Link: https://lore.kernel.org/r/20240125-fix-riscv-option-arch-llvm-18-v1-1-390ac9cc3cd0@kernel.org
Signed-off-by: Palmer Dabbelt <[email protected]>
  • Loading branch information
nathanchance authored and palmer-dabbelt committed Feb 17, 2024
1 parent 6613476 commit 0ee695a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/Kconfig.include
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ld-option = $(success,$(LD) -v $(1))

# $(as-instr,<instr>)
# Return y if the assembler supports <instr>, n otherwise
as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -c -x assembler-with-cpp -o /dev/null -)
as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -Wa$(comma)--fatal-warnings -c -x assembler-with-cpp -o /dev/null -)

# check if $(CC) and $(LD) exist
$(error-if,$(failure,command -v $(CC)),C compiler '$(CC)' not found)
Expand Down
2 changes: 1 addition & 1 deletion scripts/Makefile.compiler
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ as-option = $(call try-run,\
# Usage: aflags-y += $(call as-instr,instr,option1,option2)

as-instr = $(call try-run,\
printf "%b\n" "$(1)" | $(CC) -Werror $(CLANG_FLAGS) $(KBUILD_AFLAGS) -c -x assembler-with-cpp -o "$$TMP" -,$(2),$(3))
printf "%b\n" "$(1)" | $(CC) -Werror $(CLANG_FLAGS) $(KBUILD_AFLAGS) -Wa$(comma)--fatal-warnings -c -x assembler-with-cpp -o "$$TMP" -,$(2),$(3))

# __cc-option
# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
Expand Down

0 comments on commit 0ee695a

Please sign in to comment.