From patchwork Thu Nov 15 08:27:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 151206 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6714025ljp; Thu, 15 Nov 2018 00:28:42 -0800 (PST) X-Google-Smtp-Source: AJdET5cI8nrG6+Qzui7ey9M5S+yIQfMjEsSpIpmvvN4vmUFSf1knTpZKql7NNTFsSvv7gKQ2nets X-Received: by 2002:a65:48c4:: with SMTP id o4mr4782476pgs.371.1542270522513; Thu, 15 Nov 2018 00:28:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542270522; cv=none; d=google.com; s=arc-20160816; b=fiYIbokvk5mgwkyr5KdDIk3P4jMHCLY8D6bRvR3VzyrT89MUvKfIeVwkth0I9cNe9W Vir+clAhgGI4xAiORl/cdhmR/Uwlt6huJcNJjH/APgv/UAlIBN0gECNMZakzruIJQ8dO a4Upyw9qZQ46D7zbfPxLiPtM3Sw/J9kaO4+4+3Ikt2N0LaCsa8UQsDZdV415QHdJjr/T OReHZuHvYIfrkPpw8Ku7ZJhcirGmaXhbBZSCT4f6F83uD/nogfFyjilYWND8ydR6b/GJ izrGpwtVieVhWlhMHhZrYNwO2OgdgMjDUvo+7e6r1aLYAI2n/jJ8LB2+9KlcRNX1IaYT 6OQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=PBijk1TstCcY2Qd0zD8K3u/nFfD9XogJ71hEHg31xVw=; b=MVJwmjrhr01fWdYARvIgcYbBpe0uGY1++kVGVT2S6Y+sBX9n3izJZpgGq6PsRYltJQ L4qsSD0Fch8uATZMzo43fsfSLSgQPDRXRbiwOMuZS8/oN0mQIv1JfCrh4oQLpFyRKBI+ f5Iw6YodrlktaJ1X2KB2IccpaNRgmACYg7rgjR9ZFFnHiYPHKcKNMUihhg7FqjBFHFeB 1Z1jSaM7fFnjWAd3f4i2D+rPaVIlRt+hlgINXmi6pGtR7EUCiVtF9AfPlqn472LT7VVV 54XD5dDt2zrwM81gjD8N/7+W+CSTn1+5kkplO19O69nRj5OxlByPVu7pSolyKhgzsCBt AbYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=U3nnIbei; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3si25804568pgk.405.2018.11.15.00.28.42; Thu, 15 Nov 2018 00:28:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=U3nnIbei; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732979AbeKOSfa (ORCPT + 32 others); Thu, 15 Nov 2018 13:35:30 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:50851 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728519AbeKOSf3 (ORCPT ); Thu, 15 Nov 2018 13:35:29 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id wAF8RHoa022794; Thu, 15 Nov 2018 17:27:21 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com wAF8RHoa022794 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1542270441; bh=PBijk1TstCcY2Qd0zD8K3u/nFfD9XogJ71hEHg31xVw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U3nnIbeiYG0AijrOiIzW3RG2IUid2ktDJz7b2m/0TIl0gyjg4s6rPleaOfI+IGRDZ w33zfwMon9Klr9VXt0UdZgkpBSqirwLpTk850/SMJ9c9mObvcG2L/LOIN5566n/x0C WbjrGMWNETRqoQF73OnD2hAom2csJMxAJ0svpSxAigGvPjVmH5ipCVUTo9loSim3Hp NHZm7XVKOOsPwAIOsNK+mtoKb/+/ejPeJ0U9i8gpGVmvmSDZ91wrO3HdzT64A08yLh VAUKQRvZJAZ1p3g/0SJw79o6Mj5U55rIyGLaavcn3bXlwMGQ5e5lgl64LZocZ/SSIP /idLQlyj41y3g== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Nicolas Pitre , Rasmus Villemoes , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 3/8] kbuild: refactor modversions build rules Date: Thu, 15 Nov 2018 17:27:10 +0900 Message-Id: <1542270435-11181-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542270435-11181-1-git-send-email-yamada.masahiro@socionext.com> References: <1542270435-11181-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let $(CC) compile objects into normal files *.o instead of .tmp_*.o whether CONFIG_MODVERSIONS is enabled or not. This will help simplify build rules a lot. I guess the reason of using .tmp_*.o for intermediate objects was to avoid leaving incomplete *.o file (, whose timestamp says it is up-to-date) when the genksyms tool failed for some reasons. It no longer matters because any targets are deleted on errors since commit 9c2af1c7377a ("kbuild: add .DELETE_ON_ERROR special target"). Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 54 ++++++++++++++++---------------------------------- 1 file changed, 17 insertions(+), 37 deletions(-) -- 2.7.4 diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 7af21a8..7f3ca6e 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -154,35 +154,30 @@ $(obj)/%.ll: $(src)/%.c FORCE # (See cmd_cc_o_c + relevant part of rule_cc_o_c) quiet_cmd_cc_o_c = CC $(quiet_modtag) $@ + cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< -ifndef CONFIG_MODVERSIONS -cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< - -else +ifdef CONFIG_MODVERSIONS # When module versioning is enabled the following steps are executed: -# o compile a .tmp_.o from .c -# o if .tmp_.o doesn't contain a __ksymtab version, i.e. does -# not export symbols, we just rename .tmp_.o to .o and -# are done. +# o compile a .o from .c +# o if .o doesn't contain a __ksymtab version, i.e. does +# not export symbols, it's done. # o otherwise, we calculate symbol versions using the good old # genksyms on the preprocessed source and postprocess them in a way # that they are usable as a linker script -# o generate .o from .tmp_.o using the linker to +# o generate .tmp_.o from .o using the linker to # replace the unresolved symbols __crc_exported_symbol with # the actual value of the checksum generated by genksyms - -cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< +# o remove .tmp_.o to .o cmd_modversions_c = \ - if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ + if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \ $(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ > $(@D)/.tmp_$(@F:.o=.ver); \ \ - $(LD) $(KBUILD_LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ + $(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \ -T $(@D)/.tmp_$(@F:.o=.ver); \ - rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ - else \ mv -f $(@D)/.tmp_$(@F) $@; \ + rm -f $(@D)/.tmp_$(@F:.o=.ver); \ fi; endif @@ -241,19 +236,12 @@ ifneq ($(RETPOLINE_CFLAGS),) endif endif - -ifdef CONFIG_MODVERSIONS -objtool_o = $(@D)/.tmp_$(@F) -else -objtool_o = $(@) -endif - # 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file cmd_objtool = $(if $(patsubst y%,, \ $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \ - $(__objtool_obj) $(objtool_args) "$(objtool_o)";) + $(__objtool_obj) $(objtool_args) $@;) objtool_obj = $(if $(patsubst y%,, \ $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \ $(__objtool_obj)) @@ -357,34 +345,26 @@ $(obj)/%.s: $(src)/%.S FORCE $(call if_changed_dep,cpp_s_S) quiet_cmd_as_o_S = AS $(quiet_modtag) $@ + cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< -ifndef CONFIG_MODVERSIONS -cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< - -else +ifdef CONFIG_MODVERSIONS ASM_PROTOTYPES := $(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h) -ifeq ($(ASM_PROTOTYPES),) -cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< - -else +ifneq ($(ASM_PROTOTYPES),) # versioning matches the C process described above, with difference that # we parse asm-prototypes.h C header to get function definitions. -cmd_as_o_S = $(CC) $(a_flags) -c -o $(@D)/.tmp_$(@F) $< - cmd_modversions_S = \ - if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ + if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \ $(call cmd_gensymtypes_S,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ > $(@D)/.tmp_$(@F:.o=.ver); \ \ - $(LD) $(KBUILD_LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ + $(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \ -T $(@D)/.tmp_$(@F:.o=.ver); \ - rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ - else \ mv -f $(@D)/.tmp_$(@F) $@; \ + rm -f $(@D)/.tmp_$(@F:.o=.ver); \ fi; endif endif