Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2790404ybz; Mon, 27 Apr 2020 04:40:40 -0700 (PDT) X-Google-Smtp-Source: APiQypL0TBEpFu1yEG4m0SiYPmy3EowVo3mJ/AE8xZgyGpLiJpgAKCZ988gKZOzvzfEGFwgnJ5dw X-Received: by 2002:aa7:c983:: with SMTP id c3mr18888002edt.343.1587987640574; Mon, 27 Apr 2020 04:40:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587987640; cv=none; d=google.com; s=arc-20160816; b=xkqPV43Fu0H2jo37enIIhZ1bz8bNBrKJWCBg6tF59xI01wKxfUwvZjAE4HLZ4deodS zyd2YXTrmSbQ5mhWcs2DuZ/Y3iGVhmveGyzKs920lmWP0jn7gshXMuGqKTexU0nUYXeL 2vdF+CdyAaye+TbLsZcF6zQw5oGQhr+fsuZyI7xYGbVaDikaJsjoD+uTbLPelaMQ+k3O saY5V9kTolA5dE5dUFZdCYAtY3y929iKyiZFeeuQzUhsVxbQGPfrvTD4iBP/QfDcDAJT P1f/SDqumgvJLk5wSKTJJzAwuKFo05AWDiax7fqksSWzepg/182n9OEX3quUd4pUfBit mKjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=LZCkUD5pE73K4jVhj+vKst0mUBSHapxVX6KOAWT3kls=; b=Cg7txRoB3Ys2KMeSSdmgFHcbBZrzhY9Hv2jHL9OffpHY+EB7LgtEgQ1LVoT6edccYV l9LL7d5lzUw2aEm3+mM992HmaQC+F+pGkAWmhd7g6j2u6oTJlYz6FJRUCMvzn6BHiFnL c1c7H3+W41487bBzCoLu9KMB7pWYycZkeuy1o8P+U1h9WBIe97YfMgLbYXm2Dxwc1lqr U7/7CrvG9uw8aAi+Bq4cC6nokNkt4DdQyq61fPcjRRbY2Lvb5b9z9x4eE8UFJvcHsFVr OuOwWEy0aTE6do9IKhiPaETt8inWFI96kmjCXzS6HZTiynXW22TdlR8pcRMmfcQtqjOG 11Rg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp4si8594285ejc.399.2020.04.27.04.40.16; Mon, 27 Apr 2020 04:40:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727060AbgD0Lhx convert rfc822-to-8bit (ORCPT + 99 others); Mon, 27 Apr 2020 07:37:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726260AbgD0Lhx (ORCPT ); Mon, 27 Apr 2020 07:37:53 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C175C0610D5; Mon, 27 Apr 2020 04:37:53 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jT257-0001BZ-KW; Mon, 27 Apr 2020 13:37:49 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 4715D1C0451; Mon, 27 Apr 2020 13:37:49 +0200 (CEST) Date: Mon, 27 Apr 2020 11:37:48 -0000 From: "tip-bot2 for Borislav Petkov" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/build] x86/build: Check whether the compiler is sane Cc: mliska@suse.cz, Borislav Petkov , Nick Desaulniers , x86 , LKML In-Reply-To: <20200423173058.GE26021@zn.tnic> References: <20200423173058.GE26021@zn.tnic> MIME-Version: 1.0 Message-ID: <158798746887.28353.12553648261169854767.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8BIT X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/build branch of tip: Commit-ID: 73da86741e7f75c9f1b5c8a2660c90aa41840972 Gitweb: https://git.kernel.org/tip/73da86741e7f75c9f1b5c8a2660c90aa41840972 Author: Borislav Petkov AuthorDate: Thu, 23 Apr 2020 19:28:28 +02:00 Committer: Borislav Petkov CommitterDate: Mon, 27 Apr 2020 13:31:57 +02:00 x86/build: Check whether the compiler is sane Add a check script to verify whether the compiler is sane. This is x86-only for now and checks one thing only but should be useful for more checks in the future. Suggested-by: Martin Liška Signed-off-by: Borislav Petkov Reviewed-by: Nick Desaulniers Tested-by: Nick Desaulniers Link: https://lkml.kernel.org/r/20200423173058.GE26021@zn.tnic --- arch/x86/Makefile | 4 ++++ scripts/x86-check-compiler.sh | 9 +++++++++ 2 files changed, 13 insertions(+) create mode 100755 scripts/x86-check-compiler.sh diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 00e378d..38d3eec 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -1,6 +1,10 @@ # SPDX-License-Identifier: GPL-2.0 # Unified Makefile for i386 and x86_64 +# Check the compiler +sane_compiler := $(shell $(srctree)/scripts/x86-check-compiler.sh $(CC)) +$(if $(sane_compiler),$(error $(CC) check failed. Aborting),) + # select defconfig based on actual architecture ifeq ($(ARCH),x86) ifeq ($(shell uname -m),x86_64) diff --git a/scripts/x86-check-compiler.sh b/scripts/x86-check-compiler.sh new file mode 100755 index 0000000..b2b5b54 --- /dev/null +++ b/scripts/x86-check-compiler.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +# Check whether the compiler tail-call optimizes across an asm() statement. +# Fail the build if it does. + +echo "int foo(int a); int bar(int a) { int r = foo(a); asm(\"\"); return r; }" |\ + $* -O2 -x c -c -S - -o - 2>/dev/null |\ + grep -E "^[[:blank:]]+jmp[[:blank:]]+.*"