Received: by 10.213.65.68 with SMTP id h4csp1824909imn; Thu, 29 Mar 2018 11:43:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx48RPMJ1ibsXhkYHjFzU5DKMazncp+iGxbtYalt1d5JWli0n4Nag0exCyseVPo7Arsk2ikOu X-Received: by 2002:a17:902:5205:: with SMTP id z5-v6mr9379430plh.268.1522349021484; Thu, 29 Mar 2018 11:43:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522349021; cv=none; d=google.com; s=arc-20160816; b=QHkDUoaTFAU9THTZpTTeBP34ajgqgvyP2OAqW05mPZpMbo/DDTFsKL//cRibaimzWY e80YI8bSGxk5iKIqvUtGWzauhmxZaYNeXf1dCG/oMGrMrakivG2SgqrfdMnbRyVSDS5f I9s2nHAZYt+H6LJSqLHg/qEjoaec0xrgSb7OwVhp14a2resfcPc/QlHkD76K8cUDAudm FNnT/bLofgf0RQpgWbso2pyXgfr4wK0Nj6GXvIG+we/IfdYuJX+ECWg6FbtxeNHzuZ3d mWhPYp+i1sjEEySI491Z7qyekLCSpeQL4WAa9HxxDvTrlHt3WBQMt3Lp/bDjRfY13ZNP 2YgA== 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:arc-authentication-results; bh=smmb7RwKyA+/aK6G+crBgh7k6ZtbPl+PPwDG0PelQEY=; b=Wxc8X7dOCJExBaRZhNU0MwvUQgQG3ytPMKgdg+cQKJbQmEKxSel9W+nesO1G23BjpZ d2aYhfkmKDaI8wQPAtV0FnNCyC5rbqMFLgDCPUhqpIdT67PRv50JXUVZ/5rudTx9tmab 0keJhHm0cZn70FKz6473xySXREIIFmZeLn6T3XJ+8u0sj1VrdV9F9U1diSePG04xMdOs m4NC+XiFBSdO5CZgkItdWmatipG7i3+dpPOGwy/+bvhF4SyatlMfH60rpTIW757S2aPC Wd6BY/Rh2RXPDgaUnGozrlBnmBheyn0i+h7uv+CQKwKg3NjIuBa0AKlYqYQR1G3SVZUW tcZA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t2-v6si6829032plj.651.2018.03.29.11.43.27; Thu, 29 Mar 2018 11:43:41 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752105AbeC2SBW (ORCPT + 99 others); Thu, 29 Mar 2018 14:01:22 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:32833 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751398AbeC2SBT (ORCPT ); Thu, 29 Mar 2018 14:01:19 -0400 Received: by mail-pf0-f194.google.com with SMTP id f15so3762217pfn.0 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=jHFKxPBWYks0Nl7BQIsoMZvswiX3M14BA/X4vfYaIo2Zky0tdIXsCSKph5X7Xhy4CS dZ56rvNUluIRIyNaS8W/txZPBJwrn+iZMpHS0Dr4YoOXt3TtxPtFGd/hdUayQ1eZUvAc SMSKAh+DQxSYW7SwdeIazA/X8fpM/ZTE8zI9E1sA26Q5pUIhY+4rJiBBgANezc5xM9B0 7umgu5+GwCCkj1t3hC8Voblc4YnbohqCyTyDnRl8Y13tNLFxvqOr4MyGZ81r8pGn69nF 4Cf4CHgXANIPRW4ESui3ELIgOoO57elR/8iWtPDmexyQbcNa+ds/KHN0Dz4gviFcXzXl ywAg== X-Gm-Message-State: AElRT7G0NmfBZrS1dKcbqhI0qAmLZXxnFUg8mMkuQY4ONY7xceocJgNd 4Mg9bhQgnsviOEeQk78HLN2rLQ== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 " } " -- 2.16.2