[PATCH] kbuild: remove AS variable

11 views
Skip to first unread message

Masahiro Yamada

unread,
Mar 24, 2020, 12:15:38 PM3/24/20
to linux-...@vger.kernel.org, David S . Miller, net...@vger.kernel.org, linux-...@vger.kernel.org, Masahiro Yamada, Michal Marek, clang-bu...@googlegroups.com
As commit 5ef872636ca7 ("kbuild: get rid of misleading $(AS) from
documents") noted, we rarely use $(AS) in the kernel build.

Now that the only/last user of $(AS) in drivers/net/wan/Makefile was
converted to $(CC), $(AS) is no longer used in the build process.

You can still pass in AS=clang, which is just a switch to turn on
the LLVM integrated assembler.

Signed-off-by: Masahiro Yamada <masa...@kernel.org>
---

Makefile | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 16d8271192d1..339e8c51a10b 100644
--- a/Makefile
+++ b/Makefile
@@ -405,7 +405,6 @@ KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)

# Make variables (CC, etc...)
-AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
CPP = $(CC) -E
@@ -472,7 +471,7 @@ KBUILD_LDFLAGS :=
GCC_PLUGINS_CFLAGS :=
CLANG_FLAGS :=

-export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
+export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE LEX YACC AWK INSTALLKERNEL
export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
--
2.17.1

Masahiro Yamada

unread,
Mar 24, 2020, 12:16:08 PM3/24/20
to linux-...@vger.kernel.org, David S . Miller, net...@vger.kernel.org, linux-...@vger.kernel.org, Masahiro Yamada, Michal Marek, clang-bu...@googlegroups.com

Nick Desaulniers

unread,
Mar 24, 2020, 3:39:02 PM3/24/20
to Masahiro Yamada, Linux Kbuild mailing list, David S . Miller, Network Development, LKML, Michal Marek, clang-built-linux
On Tue, Mar 24, 2020 at 9:16 AM Masahiro Yamada <masa...@kernel.org> wrote:
>
> As commit 5ef872636ca7 ("kbuild: get rid of misleading $(AS) from
> documents") noted, we rarely use $(AS) in the kernel build.
>
> Now that the only/last user of $(AS) in drivers/net/wan/Makefile was
> converted to $(CC), $(AS) is no longer used in the build process.

TIL that we don't actually invoke the assembler at all for out of line
assembly files, but rather use the compiler as the "driver".
scripts/Makefile.build:
329 quiet_cmd_as_o_S = AS $(quiet_modtag) $@
330 cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<

Though I am personally conflicted, as
commit 055efab3120b ("kbuild: drop support for cc-ldoption")
since we do the opposite for the linker (we do not use the compiler as
the driver for the linker using -Wl,-foo flags). I wish we were
consistent in this regard (and not using the compiler as the driver),
but that is a yak-shave+bikeshed (I typed out yakshed without
thinking; maybe a new entry for Linux kernel urban dictionary or The
Jargon File) for another day.

$ grep -nR --include="Makefile" '(AS)' .
Turned up only this change and the above referenced wan driver.

Reviewed-by: Nick Desaulniers <ndesau...@google.com>
Tested-by: Nick Desaulniers <ndesau...@google.com>
--
Thanks,
~Nick Desaulniers

Nathan Chancellor

unread,
Mar 24, 2020, 3:43:39 PM3/24/20
to Masahiro Yamada, linux-...@vger.kernel.org, David S . Miller, net...@vger.kernel.org, linux-...@vger.kernel.org, Michal Marek, clang-bu...@googlegroups.com
On Wed, Mar 25, 2020 at 01:15:39AM +0900, Masahiro Yamada wrote:
> As commit 5ef872636ca7 ("kbuild: get rid of misleading $(AS) from
> documents") noted, we rarely use $(AS) in the kernel build.
>
> Now that the only/last user of $(AS) in drivers/net/wan/Makefile was
> converted to $(CC), $(AS) is no longer used in the build process.
>
> You can still pass in AS=clang, which is just a switch to turn on
> the LLVM integrated assembler.
>
> Signed-off-by: Masahiro Yamada <masa...@kernel.org>

Reviewed-by: Nathan Chancellor <natecha...@gmail.com>

Nick Desaulniers

unread,
Mar 24, 2020, 3:43:58 PM3/24/20
to Masahiro Yamada, Linux Kbuild mailing list, David S . Miller, Network Development, LKML, Michal Marek, clang-built-linux
Just noting that this got rolled up into a 3 patch series:
https://lore.kernel.org/lkml/CAKwvOdkjiyyt8Ju2j2O4cm1s...@mail.gmail.com/T/#u
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-li...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200324161507.7414-1-masahiroy%40kernel.org.



--
Thanks,
~Nick Desaulniers

Nick Desaulniers

unread,
Mar 24, 2020, 3:59:06 PM3/24/20
to Masahiro Yamada, Linux Kbuild mailing list, David S . Miller, Network Development, LKML, Michal Marek, clang-built-linux
On Tue, Mar 24, 2020 at 12:38 PM Nick Desaulniers
<ndesau...@google.com> wrote:
> consistent in this regard (and not using the compiler as the driver),

Ah, the preprocessor; we need to preprocess the .S files, .s files are
fine (though we have .lds.S files that are not `-x
assembler-with-cpp`)

--
Thanks,
~Nick Desaulniers

kbuild test robot

unread,
Mar 25, 2020, 6:00:24 PM3/25/20
to Masahiro Yamada, kbuil...@lists.01.org, clang-bu...@googlegroups.com, linux-...@vger.kernel.org, David S . Miller, net...@vger.kernel.org, linux-...@vger.kernel.org, Masahiro Yamada, Michal Marek
Hi Masahiro,

I love your patch! Yet something to improve:

[auto build test ERROR on kbuild/for-next]
[also build test ERROR on net-next/master net/master linus/master v5.6-rc7 next-20200325]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url: https://github.com/0day-ci/linux/commits/Masahiro-Yamada/net-wan-wanxl-use-CC68K-instead-of-AS68K-for-rebuilding-firmware/20200326-034145
base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
config: powerpc-defconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 2093fdd429d52348e08969180ac6b1e705fc4ff6)
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER=clang make.cross ARCH=powerpc

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <l...@intel.com>

All errors (new ones prefixed by >>):

>> /bin/sh: 0: Illegal option --
6 real 3 user 2 sys 107.14% cpu make distclean
--
>> /bin/sh: 0: Illegal option --
4 real 4 user 1 sys 114.93% cpu make olddefconfig
--
>> /bin/sh: 0: Illegal option --
/usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x58): first defined here
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [scripts/Makefile.host:116: scripts/dtc/dtc] Error 1
make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1270: scripts_dtc] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:180: sub-make] Error 2
17 real 6 user 11 sys 102.46% cpu make prepare

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuil...@lists.01.org
.config.gz

Masahiro Yamada

unread,
Mar 26, 2020, 1:58:03 AM3/26/20
to linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Geert Uytterhoeven, Masahiro Yamada, Michal Marek, linux-...@vger.kernel.org
As commit 5ef872636ca7 ("kbuild: get rid of misleading $(AS) from
documents") noted, we rarely use $(AS) directly in the kernel build.

Now that the only/last user of $(AS) in drivers/net/wan/Makefile was
converted to $(CC), $(AS) is no longer used in the build process.

You can still pass in AS=clang, which is just a switch to turn on
the LLVM integrated assembler.

Signed-off-by: Masahiro Yamada <masa...@kernel.org>
Reviewed-by: Nick Desaulniers <ndesau...@google.com>
Tested-by: Nick Desaulniers <ndesau...@google.com>
Reviewed-by: Nathan Chancellor <natecha...@gmail.com>
---

Changes in v2:
- Fix breakage of CC=clang build

Makefile | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index fcec84681e4e..2e12fa1cc8f3 100644
--- a/Makefile
+++ b/Makefile
@@ -405,7 +405,6 @@ KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)

# Make variables (CC, etc...)
-AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
CPP = $(CC) -E
@@ -535,7 +534,7 @@ endif
ifneq ($(GCC_TOOLCHAIN),)
CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN)
endif
-ifeq ($(shell $(AS) --version 2>&1 | head -n 1 | grep clang),)
+ifeq ($(if $(AS),$(shell $(AS) --version 2>&1 | head -n 1 | grep clang)),)
CLANG_FLAGS += -no-integrated-as
endif
CLANG_FLAGS += -Werror=unknown-warning-option
--
2.17.1

Masahiro Yamada

unread,
Mar 26, 2020, 2:14:55 AM3/26/20
to Nick Desaulniers, Linux Kbuild mailing list, David S . Miller, Network Development, LKML, Michal Marek, clang-built-linux
Hi Nick,
Right, there is no '*.s' source file in the kernel tree.

If we want to de-couple $(AS), we must the compilation
before the assemble stage ( $(CC) -S ), but
doing so does not buy us.

So, $(CC) always works as the front-end
for compiling both .c and .S files.


You can see the internal database by
'make --print-data-base'.

I see the following for *.S -> *.o rule.

# default
COMPILE.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c


So, using $(CC) is the right thing.


Even if we keep AS, we cannot do like AS=llvm-as
since llvm-as is a different kind of tool
that processes LLVM assembly (.ll) .


--
Best Regards
Masahiro Yamada

kbuild test robot

unread,
Mar 26, 2020, 7:36:04 AM3/26/20
to Masahiro Yamada, kbuil...@lists.01.org, clang-bu...@googlegroups.com, linux-kbuild@vger.kernel.org, David S . Miller, net...@vger.kernel.org, linux-...@vger.kernel.org, Masahiro Yamada, Michal Marek
Hi Masahiro,

I love your patch! Yet something to improve:

[auto build test ERROR on kbuild/for-next]
[also build test ERROR on v5.6-rc7 next-20200326]
[cannot apply to sparc-next/master ipvs/master]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url: https://github.com/0day-ci/linux/commits/Masahiro-Yamada/kbuild-remove-AS-variable/20200326-034016
base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
config: x86_64-randconfig-d002-20200326 (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 4b428e8f18c7006f69b3d4ef0fdf091d998d0941)
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER=clang make.cross ARCH=x86_64

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <l...@intel.com>

All errors (new ones prefixed by >>):

>> /bin/bash: --: invalid option
Usage: /bin/bash [GNU long option] [option] ...
/bin/bash [GNU long option] [option] script-file ...
GNU long options:
--debug
--debugger
--dump-po-strings
--dump-strings
--help
--init-file
--login
--noediting
--noprofile
--norc
--posix
--pretty-print
--rcfile
--restricted
--verbose
--version
Shell options:
-ilrsD or -c command or -O shopt_option (invocation only)
-abefhkmnptuvxBCHP or -o option
make[1]: *** [Makefile:1697: drivers] Error 2
make[1]: Target '_all' not remade because of errors.
--
>> /bin/sh: 0: Illegal option --
4 real 3 user 3 sys 164.71% cpu make distclean
--
>> /bin/sh: 0: Illegal option --
3 real 0 user 1 sys 50.21% cpu make INSTALL_HDR_PATH=/tmp/usr/src/linux-headers-x86_64-randconfig-d002-20200326-e8c8c8d0ca995e05ef88ce20decd1c1134cda401 headers_install
--
>> /bin/sh: 0: Illegal option --
14 real 3 user 9 sys 83.33% cpu make modules_prepare
--
>> /bin/sh: 0: Illegal option --
4 real 3 user 1 sys 122.16% cpu make olddefconfig
--
>> /bin/sh: 0: Illegal option --
21 real 21 user 11 sys 150.21% cpu make prepare
.config.gz

Masahiro Yamada

unread,
Mar 28, 2020, 1:52:32 AM3/28/20
to Linux Kbuild mailing list, clang-built-linux, Geert Uytterhoeven, Michal Marek, Linux Kernel Mailing List
On Thu, Mar 26, 2020 at 2:58 PM Masahiro Yamada <masa...@kernel.org> wrote:
>
> As commit 5ef872636ca7 ("kbuild: get rid of misleading $(AS) from
> documents") noted, we rarely use $(AS) directly in the kernel build.
>
> Now that the only/last user of $(AS) in drivers/net/wan/Makefile was
> converted to $(CC), $(AS) is no longer used in the build process.
>
> You can still pass in AS=clang, which is just a switch to turn on
> the LLVM integrated assembler.
>
> Signed-off-by: Masahiro Yamada <masa...@kernel.org>
> Reviewed-by: Nick Desaulniers <ndesau...@google.com>
> Tested-by: Nick Desaulniers <ndesau...@google.com>
> Reviewed-by: Nathan Chancellor <natecha...@gmail.com>


I forgot to remove the export.




@@ -472,7 +471,7 @@ KBUILD_LDFLAGS :=
GCC_PLUGINS_CFLAGS :=
CLANG_FLAGS :=

-export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS
CROSS_COMPILE AS LD CC
+export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS
CROSS_COMPILE LD CC
export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE LEX
YACC AWK INSTALLKERNEL
export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE





> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-li...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200326055719.16755-4-masahiroy%40kernel.org.
Reply all
Reply to author
Forward
0 new messages