From patchwork Thu Mar 29 18:01:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 10316055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6D6B76037E for ; Thu, 29 Mar 2018 18:42:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CC4F28D9E for ; Thu, 29 Mar 2018 18:42:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5046C290F0; Thu, 29 Mar 2018 18:42:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E83832A49A for ; Thu, 29 Mar 2018 18:42:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751980AbeC2SBV (ORCPT ); Thu, 29 Mar 2018 14:01:21 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:40361 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751341AbeC2SBT (ORCPT ); Thu, 29 Mar 2018 14:01:19 -0400 Received: by mail-pf0-f195.google.com with SMTP id y66so3724442pfi.7 for ; Thu, 29 Mar 2018 11:01:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=smmb7RwKyA+/aK6G+crBgh7k6ZtbPl+PPwDG0PelQEY=; b=B5Pe915nesqGfR9368HkH6JU63SFqiqgO/oj24eC3gU5AqnaitBBbjBvnPHe0/4Flc bec4pzPPGe4UyhIc6FKrX8AY4JTZFdJ8M3wCcXqZxNtHI/1ds8XPgXccyvOVTDPkZTvh hE3eSRYiB+G0dz0FOs8g0ZDA8GNBkUIjh0b7WOHfmzX8GtodffiGEUEMhe30TiDQcryq sKQmXZxH8hvmIzpu4cJaIV/gz8B2R/tvejVT1elZQ2QZVoNtXXc5LGg+5HshZSJYIMoa P+e43DNybpx3hiD8KTGJ5aFyejX0Enr7lGUO93T2lOjYVIENX4AYDCJS2axdB3Fe16V9 6FtA== X-Gm-Message-State: AElRT7FwGPUoxGJp4utjuNOQQZdoUS5vCjrxaDuDa7jCxFod3XE28hc6 jsrhAJe7hJA8Hb9XLDwhca0QWA== X-Google-Smtp-Source: AIpwx49BHJYJOvBFZF5OK9Ig9Q4K3PPbsQe22Wxu2sIagjycccMhos1nqDGDs2bvQeaS8nVGzJKA0g== X-Received: by 2002:a17:902:6b07:: with SMTP id o7-v6mr9433458plk.136.1522346479314; Thu, 29 Mar 2018 11:01:19 -0700 (PDT) Received: from localhost.localdomain.utopia.net ([2601:602:9802:a8dc::19fb]) by smtp.gmail.com with ESMTPSA id m21sm4762432pgn.0.2018.03.29.11.01.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 29 Mar 2018 11:01:17 -0700 (PDT) From: Laura Abbott To: Andy Lutomirski , mjw@fedoraproject.org, "H . J . Lu" , Masahiro Yamada Cc: Laura Abbott , Linus Torvalds , X86 ML , linux-kernel@vger.kernel.org, Nick Clifton , Cary Coutant , linux-kbuild@vger.kernel.org Subject: [RFCv2 PATCH 1/3] kbuild: Introduce build-salt generated header Date: Thu, 29 Mar 2018 11:01:10 -0700 Message-Id: <20180329180112.11055-2-labbott@redhat.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180329180112.11055-1-labbott@redhat.com> References: <20180329180112.11055-1-labbott@redhat.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The build id generated from --build-id can be generated in several different ways, with the default being the sha1 on the output of the linked file. For distributions, it can be useful to make sure this ID is unique, even if the actual file contents don't change. The easiest way to do this is to insert a comment section with some data. Introduce a header which is generated from a config setting. If this config is set, an appropriate .comment section is generated. If the config isn't set, the define is simply empty and there is no change to the build. Signed-off-by: Laura Abbott --- v2: Switched to Kconfig vs. environment variable per suggestion of Nick Clifton. Changed names to be consistent. --- Makefile | 9 ++++++++- init/Kconfig | 8 ++++++++ scripts/gensalt | 21 +++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100755 scripts/gensalt diff --git a/Makefile b/Makefile index 7ba478ab8c82..b80c2d6d0854 100644 --- a/Makefile +++ b/Makefile @@ -1096,7 +1096,7 @@ endif prepare2: prepare3 prepare-compiler-check outputmakefile asm-generic prepare1: prepare2 $(version_h) include/generated/utsrelease.h \ - include/config/auto.conf + include/config/auto.conf include/generated/build-salt.h $(cmd_crmodverdir) archprepare: archheaders archscripts prepare1 scripts_basic @@ -1184,6 +1184,13 @@ $(version_h): $(srctree)/Makefile FORCE include/generated/utsrelease.h: include/config/kernel.release FORCE $(call filechk,utsrelease.h) +define filechk_build-salt.h + ($(CONFIG_SHELL) $(srctree)/scripts/gensalt $(CONFIG_BUILD_ID_SALT)) +endef + +include/generated/build-salt.h: $(srctree)/Makefile FORCE + $(call filechk,build-salt.h) + PHONY += headerdep headerdep: $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \ diff --git a/init/Kconfig b/init/Kconfig index e37f4b2a6445..01e77aef3610 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1924,3 +1924,11 @@ source "kernel/Kconfig.locks" config ARCH_HAS_SYNC_CORE_BEFORE_USERMODE bool + +config BUILD_ID_SALT + string "Build ID Salt" + help + The build ID is used to link binaries and their debug info. Setting + this option will use the value in the calculation of the build id. + This is mostly useful for distributions which want to ensure the + build is unique between builds. It's safe to leave this empty. diff --git a/scripts/gensalt b/scripts/gensalt new file mode 100755 index 000000000000..355a3e799550 --- /dev/null +++ b/scripts/gensalt @@ -0,0 +1,21 @@ +#!/bin/sh + +if [[ $1 = "" ]]; then + echo "#define BUILD_ID_SALT" + exit 0 +fi + +BUILD_ID_SALT=$1 + +echo "#define BUILD_ID_SALT \\" +echo ".comment (INFO) : \\" +echo " { \\" + +_TAG=`echo $BUILD_ID_SALT | sed -e 's/\(.\)/\1 /g'` +for c in $_TAG; do + _HEX=`echo -n $c | od -A n -t x1 | tr -d ' ' ` + echo "BYTE(0x$_HEX); \\" +done +echo "BYTE(0x00); \\" + +echo " } "