From patchwork Mon Nov 14 23:08:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Stone X-Patchwork-Id: 9428661 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 1FF636047D for ; Mon, 14 Nov 2016 23:09:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 270C828654 for ; Mon, 14 Nov 2016 23:09:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B75028A49; Mon, 14 Nov 2016 23:09:03 +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=ham 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 8C29928654 for ; Mon, 14 Nov 2016 23:09:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937878AbcKNXJB (ORCPT ); Mon, 14 Nov 2016 18:09:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35118 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934108AbcKNXJA (ORCPT ); Mon, 14 Nov 2016 18:09:00 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B3BE061E64; Mon, 14 Nov 2016 23:08:59 +0000 (UTC) Received: from fidelio.net (ovpn-116-180.phx2.redhat.com [10.3.116.180]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAEN8wvu030517; Mon, 14 Nov 2016 18:08:58 -0500 From: Al Stone To: linux-acpi@vger.kernel.org, devel@acpica.org, linux-kernel@vger.kernel.org Cc: Al Stone , "Rafael J . Wysocki" , Len Brown , Robert Moore , Lv Zheng Subject: [PATCH] ACPI: allow compilation with bare metal compilers Date: Mon, 14 Nov 2016 16:08:46 -0700 Message-Id: <1479164926-1733-1-git-send-email-ahs3@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 14 Nov 2016 23:09:00 +0000 (UTC) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The ACPICA subsystem of the ACPI driver sets up a compilation environment for itself, adding in multiple typedefs unique to ACPICA that depend on where ACPICA will be used. The vast majority of such environments (Linux, QNX, ...) have an environment defined by the acenv.h header file. When using a Linaro compiler [1] specifically built to be used in an embedded environment with perhaps a kernel and an init process as the only things running, there is no environment defined for ACPICA so the typedefs it needs are not set up, causing compilation to fail badly unless ACPI is completely disabled. Since ACPI is enabled in the default config for the kernel, the compilation failure is fairly obvious. This may not be the optimal solution, but add in to the ACPI header file include/acpi/platform/acenv.h a default so that if GCC is being used, and all else fails, assume that we are going to be in a Linux-like environment and re-use the environment definition for Linux. This allows us to build a kernel using this compiler [1] with or without ACPI. [1] https://releases.linaro.org/components/toolchain/binaries/latest/aarch64-elff/gcc-linaro-6.1.1-2016-08-x86_64_aarch64-elf.tar.xz Signed-off-by: Al Stone Cc: Rafael J. Wysocki Cc: Len Brown Cc: Robert Moore Cc: Lv Zheng --- include/acpi/platform/acenv.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h index 34cce72..cdd1cd6 100644 --- a/include/acpi/platform/acenv.h +++ b/include/acpi/platform/acenv.h @@ -234,6 +234,21 @@ #elif defined(_AED_EFI) || defined(_GNU_EFI) || defined(_EDK2_EFI) #include "acefi.h" +/* + * Up to this point, we've been looking for specific environments. In + * some cases, there is no environment, and we're just working on bare + * metal. However, since we're compiling the Linux kernel, let's just + * pretend we're in a Linux environment. + */ +#elif defined(__GNUC__) && !defined(__INTEL_COMPILER) +#if !defined(_LINUX) +#define _LINUX +#endif +#if !defined(__linux__) +#define __linux__ +#endif +#include + #else /* Unknown environment */