Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp700476img; Wed, 20 Mar 2019 09:04:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfW/krCBCrehn4HrBLQeUgTZvCbYP3DW/dvSRgh6l7PYER4xBrdkbXGOtpD1cws6SESj8P X-Received: by 2002:a63:1f61:: with SMTP id q33mr8156188pgm.325.1553097848052; Wed, 20 Mar 2019 09:04:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553097848; cv=none; d=google.com; s=arc-20160816; b=C3BRKy9gIzYKKSLkO4fBPt2R+DEFucXeh5EhOxMb7yIxsyMGwGaVZnX8o4P5AI4ftI TAiWESX/KpTPWyM3h5ov1k6/tpMOf3BVE0YPKtXIxaWDN9cg32zQOGUgGIzNSb0ZK7M4 BHPTx1dI6RCVEty2V1xLgcdxYTfIIjBddu1YtrPTvo2VYZGBINKkIA96+q5goSc7Qg7k AiRH50dNKnCNOFq6EPMDAzJfZBZ2deqWkxjPDJQX0Kkxwdi7YmuzTvmSrhKT189ma55K FhAf9vlAY51S0e9S69VZG77IFAIiquCO4vUuFtdHIlNJyRwUlY/xPCMRFTjSYfdGBjBd d+zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=cWfP2D4LLl08D9JFpXzh4NxzX6I79yTEgnx5HKK8WP8=; b=M98L9Un4Sn+6ifDshlm2ivvhuZ12Lfa7PAmMb8fGZvmFnfIYVj4iPcHia3qBQKH0NC jncK7ePaJiqXqYp6gKGQvRJ6xKUmM5Y1S8yWnohgyQcmQxpQII9BSw57MBCkd3hX0O4h im8npM497RnY/eOoxXxzbeEWHp7kucTziJfRAXmeJxmahRlshnHvRQz3jwTFMWhw5e2N 6+1Qd44OOMEDqMvpU/xXM64luvV1EbfRP3lsAKniXQqBXxt4ufyZn6+XO7RvjBBSF1Zb OBtWmDGoYSM5zknwV1g+dngEnnlHAe6RDf2dNXS33nRSWTusHL8l8SjAvUE6MmA6G8mg QjaA== 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 b9si2133460plz.207.2019.03.20.09.03.50; Wed, 20 Mar 2019 09:04:08 -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 S1726767AbfCTQDM (ORCPT + 99 others); Wed, 20 Mar 2019 12:03:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41718 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726437AbfCTQDL (ORCPT ); Wed, 20 Mar 2019 12:03:11 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6020930BC66D; Wed, 20 Mar 2019 16:03:11 +0000 (UTC) Received: from treble (ovpn-124-13.rdu2.redhat.com [10.10.124.13]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5ACC35C260; Wed, 20 Mar 2019 16:03:10 +0000 (UTC) Date: Wed, 20 Mar 2019 11:03:08 -0500 From: Josh Poimboeuf To: Rolf Eike Beer Cc: Peter Zijlstra , Masahiro Yamada , Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] objtool: query pkg-config for libelf location Message-ID: <20190320160308.hdhd7ko4hquanmqc@treble> References: <3381642.TeJ1gWjbju@devpool35> <20190320153701.7wym7btpjshdujpz@treble> <13279932.E8cnC9vheV@devpool35> <13510794.yptIvAPcpm@devpool35> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <13510794.yptIvAPcpm@devpool35> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 20 Mar 2019 16:03:11 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 20, 2019 at 04:58:26PM +0100, Rolf Eike Beer wrote: > If it is not in the default location compilation would fail at several points. > > Signed-off-by: Rolf Eike Beer Looks fine to me. If the kbuild folks don't have any comments, I'll send it along to the -tip tree soonish. > --- > Changes in v2: > -also hide stderr when querying cflags > -use ":=" assignment as in other places in that file > > Makefile | 4 +++- > tools/objtool/Makefile | 7 +++++-- > 2 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/Makefile b/Makefile > index 99c0530489ef..32caf30e0d79 100644 > --- a/Makefile > +++ b/Makefile > @@ -950,9 +950,11 @@ mod_sign_cmd = true > endif > export mod_sign_cmd > > +HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) > + > ifdef CONFIG_STACK_VALIDATION > has_libelf := $(call try-run,\ > - echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0) > + echo "int main() {}" | $(HOSTCC) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0) > ifeq ($(has_libelf),1) > objtool_target := tools/objtool FORCE > else > diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile > index c9d038f91af6..53f8be0f4a1f 100644 > --- a/tools/objtool/Makefile > +++ b/tools/objtool/Makefile > @@ -25,14 +25,17 @@ LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a > OBJTOOL := $(OUTPUT)objtool > OBJTOOL_IN := $(OBJTOOL)-in.o > > +LIBELF_FLAGS := $(shell pkg-config libelf --cflags 2>/dev/null) > +LIBELF_LIBS := $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) > + > all: $(OBJTOOL) > > INCLUDES := -I$(srctree)/tools/include \ > -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ > -I$(srctree)/tools/objtool/arch/$(ARCH)/include > WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed > -CFLAGS += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) > -LDFLAGS += -lelf $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) > +CFLAGS += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) > +LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) > > # Allow old libelf to be used: > elfshdr := $(shell echo '$(pound)include ' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr) > -- > 2.21.0 > > -- > Rolf Eike Beer, emlix GmbH, http://www.emlix.com > Fon +49 551 30664-0, Fax +49 551 30664-11 > Gothaer Platz 3, 37083 Göttingen, Germany > Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160 > Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055 > > emlix - smart embedded open source -- Josh