Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp716470ybz; Wed, 15 Apr 2020 17:22:57 -0700 (PDT) X-Google-Smtp-Source: APiQypLdmwEz6oXL9GKUgRkkS4vRMNzxj5ccUaISws3z3Yc/yqqO3wmb2FFN3GZKsmS86d187JgS X-Received: by 2002:aa7:c152:: with SMTP id r18mr26993081edp.378.1586996577400; Wed, 15 Apr 2020 17:22:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586996577; cv=none; d=google.com; s=arc-20160816; b=cHwKvUf7m5q3RxLZWoJKVsfS4fh5Ai87QWjRN+Z7O9k/jEyv0EvLuVphzsqtJDw6qv FofHOWtMswftuNaqxh9s/hNydUheLgLT80uHnPYjB3aEAhdtCK0kq/yGwgazSkcyAAYy 93/UDKAEQXHokDMRBFH7u5ipO1+7Sl53RoTfw+DrCVqzixkiMs4rZdg08K6yhiW9jZ3q 22tduf1yRJVb3Ns7h7p1V7W1U9NDgrAkqkqS1izB8+oq5h3aNKgAbMyR0Uo8pf0gL2jF FM49lG4aAIWNx3y/92gifT+Kd+rFECYzb9VqbXYpm0Cf/oziNHBRwKUKuCFaD5l40K+l 2ocA== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S3oemkCGpHfhIY4QOTvElDkQ0PpgcotZJIO7wmLHtAU=; b=RQUSFi7SN08YPC41Ui1wNOJ40vhzH5vROPtS/4ETDmnwWfmdWojkELSonTTTm/khRq 1OFrbW+R+d5BvuKM4KkyeY3WbOCGWAGaTGw/UBUfFgberyFbD5rBIXvc2o/bZYORrP4u hrDzeNTvVp3b4ayiQ2Ymtipqpa9gtmaFGlOblWwD8AtxKFR5e6/2xrSeY43c5qPzs7hW J+iGDHX4jXyWplvq86NSXW/v2oU/naYygY7ADjQ3177LHP5zidExNUoLBcwsWv9hVVlJ pZwPpiT5ael9aoYsLF85G90ima55DRjYXVQCsm74FMj+rcjnihONN4sD9qiYujxsYwN8 RHVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oTxe5nW1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w1si11760741edj.107.2020.04.15.17.22.34; Wed, 15 Apr 2020 17:22:57 -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; dkim=pass header.i=@kernel.org header.s=default header.b=oTxe5nW1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2410500AbgDOQxB (ORCPT + 99 others); Wed, 15 Apr 2020 12:53:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:54698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2410484AbgDOQwv (ORCPT ); Wed, 15 Apr 2020 12:52:51 -0400 Received: from localhost.localdomain (unknown [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DABAC208FE; Wed, 15 Apr 2020 16:52:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586969571; bh=Fl4LMr8tfhnu5I5/m4JsWq9kVGAsJCZEwYG3/7yjBSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oTxe5nW1LeD77zlUfP+9luRCQxFWUlOaAVLtZGWWqYFy/PWSNFw1GAjaVghaa6iWP Kd6pnTiHfK3q6clheUTPN1AqMfxMCEi1LgwKYMigxiUla/83wxyVC8uogCffafC24o 0J2f4RyJnvmSX3Vn/1MLbw71j95IpyvYe6zk6nLE= From: Will Deacon To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, kernel-team@android.com, Will Deacon , Michael Ellerman , Peter Zijlstra , Linus Torvalds , Segher Boessenkool , Christian Borntraeger , Luc Van Oostenryck , Arnd Bergmann , Peter Oberparleiter , Masahiro Yamada , Nick Desaulniers Subject: [PATCH v3 01/12] compiler/gcc: Emit build-time warning for GCC prior to version 4.8 Date: Wed, 15 Apr 2020 17:52:07 +0100 Message-Id: <20200415165218.20251-2-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200415165218.20251-1-will@kernel.org> References: <20200415165218.20251-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Prior to version 4.8, GCC may miscompile READ_ONCE() by erroneously discarding the 'volatile' qualifier: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 We've been working around this using some nasty hacks which make READ_ONCE() both horribly complicated and also prevent us from enforcing that it is only used on scalar types. Since GCC 4.8 is pretty old for kernel builds now, emit a warning if we detect it during the build. Suggested-by: Linus Torvalds Cc: Peter Zijlstra Cc: Michael Ellerman Cc: Arnd Bergmann Cc: Christian Borntraeger Cc: Masahiro Yamada Signed-off-by: Will Deacon --- init/Kconfig | 4 ++-- scripts/Kconfig.include | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index 9e22ee8fbd75..816b8b4a5e9e 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -9,11 +9,11 @@ config DEFCONFIG_LIST default "arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)" config CC_IS_GCC - def_bool $(success,$(CC) --version | head -n 1 | grep -q gcc) + def_bool $(cc-is-gcc) config GCC_VERSION int - default $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) if CC_IS_GCC + default $(gcc-version) if CC_IS_GCC default 0 config LD_VERSION diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include index c264da2b9b30..5261e9d6b50b 100644 --- a/scripts/Kconfig.include +++ b/scripts/Kconfig.include @@ -54,3 +54,12 @@ $(error-if,$(success, $(LD) -v | grep -q gold), gold linker '$(LD)' not supporte cc-option-bit = $(if-success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null,$(1)) m32-flag := $(cc-option-bit,-m32) m64-flag := $(cc-option-bit,-m64) + +# gcc version including patch level +gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) + +# Return y if the compiler is GCC, n otherwise +cc-is-gcc := $(success,$(CC) --version | head -n 1 | grep -q gcc) + +# Warn if the compiler is GCC prior to 4.8 +$(warning-if,$(if-success,[ $(gcc-version) -lt 40800 ],$(cc-is-gcc),n),"Your compiler is old and may miscompile the kernel due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 - please upgrade it.") -- 2.26.0.110.g2183baf09c-goog