Skip to content

Commit 4d0831e

Browse files
committed
kconfig: unify cc-option and as-option
cc-option and as-option are almost the same; both pass the flag to $(CC). The main difference is the cc-option stops before the assemble stage (-S option) whereas as-option stops after (-c option). I chose -S because it is slightly faster, but $(cc-option,-gz=zlib) returns a wrong result (https://lkml.org/lkml/2020/6/9/1529). It has been fixed by commit 7b16994 ("Makefile: Improve compressed debug info support detection"), but the assembler should always be invoked for more reliable compiler option tests. However, you cannot simply replace -S with -c because the following code in lib/Kconfig.debug would break: depends on $(cc-option,-gsplit-dwarf) The combination of -c and -gsplit-dwarf does not accept /dev/null as output. $ cat /dev/null | gcc -gsplit-dwarf -S -x c - -o /dev/null $ echo $? 0 $ cat /dev/null | gcc -gsplit-dwarf -c -x c - -o /dev/null objcopy: Warning: '/dev/null' is not an ordinary file $ echo $? 1 $ cat /dev/null | gcc -gsplit-dwarf -c -x c - -o tmp.o $ echo $? 0 There is another flag that creates an separate file based on the object file path: $ cat /dev/null | gcc -ftest-coverage -c -x c - -o /dev/null <stdin>:1: error: cannot open /dev/null.gcno So, we cannot use /dev/null to sink the output. Align the cc-option implementation with scripts/Kbuild.include. With -c option used in cc-option, as-option is unneeded. Signed-off-by: Masahiro Yamada <[email protected]> Acked-by: Will Deacon <[email protected]>
1 parent f2f02eb commit 4d0831e

File tree

3 files changed

+2
-9
lines changed

3 files changed

+2
-9
lines changed

arch/arm64/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@ config CC_HAS_SIGN_RETURN_ADDRESS
15641564
def_bool $(cc-option,-msign-return-address=all)
15651565

15661566
config AS_HAS_PAC
1567-
def_bool $(as-option,-Wa$(comma)-march=armv8.3-a)
1567+
def_bool $(cc-option,-Wa$(comma)-march=armv8.3-a)
15681568

15691569
config AS_HAS_CFI_NEGATE_RA_STATE
15701570
def_bool $(as-instr,.cfi_startproc\n.cfi_negate_ra_state\n.cfi_endproc\n)

lib/Kconfig.debug

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ config DEBUG_INFO_COMPRESSED
229229
bool "Compressed debugging information"
230230
depends on DEBUG_INFO
231231
depends on $(cc-option,-gz=zlib)
232-
depends on $(as-option,-gz=zlib)
233232
depends on $(ld-option,--compress-debug-sections=zlib)
234233
help
235234
Compress the debug information using zlib. Requires GCC 5.0+ or Clang

scripts/Kconfig.include

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,12 @@ failure = $(if-success,$(1),n,y)
2525

2626
# $(cc-option,<flag>)
2727
# Return y if the compiler supports <flag>, n otherwise
28-
cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -S -x c /dev/null -o /dev/null)
28+
cc-option = $(success,mkdir .tmp_$$$$; trap "rm -rf .tmp_$$$$" EXIT; $(CC) -Werror $(CLANG_FLAGS) $(1) -c -x c /dev/null -o .tmp_$$$$/tmp.o)
2929

3030
# $(ld-option,<flag>)
3131
# Return y if the linker supports <flag>, n otherwise
3232
ld-option = $(success,$(LD) -v $(1))
3333

34-
# $(as-option,<flag>)
35-
# /dev/zero is used as output instead of /dev/null as some assembler cribs when
36-
# both input and output are same. Also both of them have same write behaviour so
37-
# can be easily substituted.
38-
as-option = $(success, $(CC) $(CLANG_FLAGS) $(1) -c -x assembler /dev/null -o /dev/zero)
39-
4034
# $(as-instr,<instr>)
4135
# Return y if the assembler supports <instr>, n otherwise
4236
as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -c -x assembler -o /dev/null -)

0 commit comments

Comments
 (0)