Message ID | 20231114-arm-build-bug-v1-1-458745fe32a4@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1529430vqg; Mon, 13 Nov 2023 15:09:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHK2J5Npi6SudJm1mADpbQc9i4Tnl/jsH9e1P7927n9w98l2PVWcIDMc0jGUd4VrlGAUEtE X-Received: by 2002:a05:6808:14c:b0:3b6:c4dd:be83 with SMTP id h12-20020a056808014c00b003b6c4ddbe83mr9623638oie.52.1699916951886; Mon, 13 Nov 2023 15:09:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699916951; cv=none; d=google.com; s=arc-20160816; b=cpF3U3UHVQGHkua/dj+f8yRPdyRT0dyI/juEud3fAdXjID9CFWInRB8e49G980bQTV E8jb8cWFkrkcwVGRUbmJngTfQqf4vSYHWcQ1P2+lupa7evpCcbBpOJft3WUgdIELShk4 1/KnP+/NkCayvASZoR2lJbVs1Dl0qipwr+TxgGw5zAtmtuQXF1xoOJsZPOMNrzqVSJMh iwcanw8O+LgdSeJJj3gYlIrQNCzcYHqroIiXi8bMNANvNIPO+kTdeuRZrOUsiukiAF6S f5dlzrznD+csJGPGc7lqp3ZoAweL/7rTBMBtYOQIjsCesZ8Mi2GTAbmzcecTO0HAQDbb ghoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=ACmx3TNz3KrSPf31LlnpB3IxofbprNijom9dYNvkSxs=; fh=CImX+tKSQ38Ax8+C0xC+uwfkZ+Ou/Wt+RACk9xWlhkE=; b=xz/5rm3SS7V+kEJMHJC9PWTG5SeoBrttE1cwc1YjA3M4jlU8gurLUlfnUwXXMGbYq+ 3GRZMRUNxON37yksJvEi6FXufd3Rf8sh3aihXzn+EoQ7g95jub33PKG6QmUdwHyTp9/f YpNHeqcsfYNueLaO20p+rT3ZkglNeUtYXBtV+SJojDhP+42WkbO9cjuvmmJdum7jZVAS nHJxCpUsn0aSpssurwArYT+lXDlB3z0Qhiu3dTfBb8+pz1liKnZn8+bkHPQltR5TicKF cg7WGmqAoOJNkjgqwbovVe5QaraisJHW8RRamaVYOfAZEPbasL03mYHVBAG4f9qa3BUu wznw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QFerk8wX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id u10-20020a655c0a000000b005c1b30caebasi774218pgr.654.2023.11.13.15.09.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 15:09:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QFerk8wX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C5BE88026DCE; Mon, 13 Nov 2023 15:09:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230223AbjKMXJB (ORCPT <rfc822;lhua1029@gmail.com> + 30 others); Mon, 13 Nov 2023 18:09:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbjKMXI6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 13 Nov 2023 18:08:58 -0500 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E287D48 for <linux-kernel@vger.kernel.org>; Mon, 13 Nov 2023 15:08:55 -0800 (PST) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-507a0907896so6972263e87.2 for <linux-kernel@vger.kernel.org>; Mon, 13 Nov 2023 15:08:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699916934; x=1700521734; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=ACmx3TNz3KrSPf31LlnpB3IxofbprNijom9dYNvkSxs=; b=QFerk8wXy69JkWtiT+9/uJFQWJp29vYvZW8IcP4rKjX0BZp1NgmEYbTQrQJ5Ms50nE pM1Pae2eNbYnxO3frMsRctKmb+up6NkUnXaGWWUHY6kxeQqPdHE+vXU7DG/UbatRpB5K rlGomcLOaQhz0T6EsEtqSUzoYlhy0Fuml+S2zY9PIRpsCT/HECn011fRg4fUan+f7Fze zv6dRIdW4E1qcdulOBGEoD6obA5D4u+3qGWwlC45FkeCqYdrDT4tcrth5+2VbVDcZfnX W3zbUBOw8yYW58ujyZWBTX7xyvPBmSxRiTS+Rxg1mKzO5F8fRGR0uf0EUa/hikuQ4+uF rZrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699916934; x=1700521734; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ACmx3TNz3KrSPf31LlnpB3IxofbprNijom9dYNvkSxs=; b=OvQN9UrRJiSlk2kwt6ZZagtFAsnz1qL8K3byHVfCuL7WhOZXRjI4OE8VUTxPq3wjum f5cTEQJik3RGySVZDC+iI25/TT0JMywMEmTc8Z8DP1Bs+KihSsQYdNay35ZUtyeSFPb6 1K+U6cEUIhqubNQ/3dGjldw1ALshiFIQL7VhhLLcOcQmh3BXypO2I74Tpy8St3n5B/j3 LMdN8dpN82LizEJirKAYZeRTFG1hA6+Y3Ae3RvfGe28M6u9MpKZUudG3dPglOzlUsqJB 2YO6Kym8y9IahJBdfMoCh0YzTqKsBPYqqXrLi7OWPwWxAxWLnP62pOPXFWmfusPYECfe joeA== X-Gm-Message-State: AOJu0YxyExRiV7i7C7PpQTp+SDLXC389euHxMkpXGJEQQPzgobXugxH0 sN64qD2ViEqfOGC2jk7YUHBAKg== X-Received: by 2002:ac2:43a6:0:b0:509:38de:9917 with SMTP id t6-20020ac243a6000000b0050938de9917mr5282007lfl.21.1699916933673; Mon, 13 Nov 2023 15:08:53 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id m9-20020ac24ac9000000b0050307bf2bcdsm1114292lfp.247.2023.11.13.15.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 15:08:53 -0800 (PST) From: Linus Walleij <linus.walleij@linaro.org> Date: Tue, 14 Nov 2023 00:08:47 +0100 Subject: [PATCH] ACPI: acenv: Permit compilation from within the kernel MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231114-arm-build-bug-v1-1-458745fe32a4@linaro.org> X-B4-Tracking: v=1; b=H4sIAH6sUmUC/x2MQQqAIBAAvxJ7Tmi1DvaV6GC52kJZKEUg/j3pM jCHmQyJIlOCsckQ6eHEZ6iCbQPrZoInwbY6yE4qRFTCxEMsN++20gtDQ6+clYhaQ22uSI7f/zf NpXyuNDVMXwAAAA== To: "Rafael J. Wysocki" <rafael@kernel.org>, Len Brown <lenb@kernel.org>, Robert Moore <robert.moore@intel.com>, Dave Jiang <dave.jiang@intel.com>, Jonathan Cameron <Jonathan.Cameron@huawei.com>, Dan Williams <dan.j.williams@intel.com>, Hanjun Guo <guohanjun@huawei.com>, Arnd Bergmann <arnd@arndb.de> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Linus Walleij <linus.walleij@linaro.org> X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 13 Nov 2023 15:09:10 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782492117889786747 X-GMAIL-MSGID: 1782492117889786747 |
Series |
ACPI: acenv: Permit compilation from within the kernel
|
|
Commit Message
Linus Walleij
Nov. 13, 2023, 11:08 p.m. UTC
After commit a103f46633fd the kernel stopped compiling for
several ARM32 platforms that I am building with a bare metal
compiler. Bare metal compilers (arm-none-eabi-) don't
define __linux__.
This is because the header <acpi/platform/acenv.h> is now
in the include path for <linux/irq.h>:
CC arch/arm/kernel/irq.o
CC kernel/sysctl.o
CC crypto/api.o
In file included from ../include/acpi/acpi.h:22,
from ../include/linux/fw_table.h:29,
from ../include/linux/acpi.h:18,
from ../include/linux/irqchip.h:14,
from ../arch/arm/kernel/irq.c:25:
../include/acpi/platform/acenv.h:218:2: error: #error Unknown target environment
218 | #error Unknown target environment
| ^~~~~
One solution to make compilation with a bare metal compiler
work again is to say the file is used with Linux from within
the kernel if __KERNEL__ is defined so I did that.
Fixes: a103f46633fd ("acpi: Move common tables helper functions to common lib")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
include/acpi/platform/acenv.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
base-commit: 9bacdd8996c77c42ca004440be610692275ff9d0
change-id: 20231113-arm-build-bug-ae543fd21199
Best regards,
Comments
On 11/13/23 16:08, Linus Walleij wrote: > After commit a103f46633fd the kernel stopped compiling for > several ARM32 platforms that I am building with a bare metal > compiler. Bare metal compilers (arm-none-eabi-) don't > define __linux__. Hi Linus, I saw the same baremetal-compiler error here on the ARM64 side of the fence, and narrowed the problem to the same commit as you. > > This is because the header <acpi/platform/acenv.h> is now > in the include path for <linux/irq.h>: More generally, I think it's because of this addition to linux/acpi.h: +#include <linux/fw_table.h> linux/acpi.h is supposed to ensure _LINUX is defined (if it isn't already done by a non-baremetal compiler) before we start pulling in ACPICA includes, so that ACPICA knows the platform. But because fw_table.h contains: #include <linux/acpi.h> #include <acpi/acpi.h> ...the circular include does nothing (linux/acpi.h's include guard stops the include before _LINUX is defined) and we end up pulling in acpi/acpi.h before we're ready. > > CC arch/arm/kernel/irq.o > CC kernel/sysctl.o > CC crypto/api.o > In file included from ../include/acpi/acpi.h:22, > from ../include/linux/fw_table.h:29, > from ../include/linux/acpi.h:18, > from ../include/linux/irqchip.h:14, > from ../arch/arm/kernel/irq.c:25: > ../include/acpi/platform/acenv.h:218:2: error: #error Unknown target environment > 218 | #error Unknown target environment > | ^~~~~ > > One solution to make compilation with a bare metal compiler > work again is to say the file is used with Linux from within > the kernel if __KERNEL__ is defined so I did that. I am not an ACPI subsystem maintainer, but my understanding is that the files in include/acpi/ are copied verbatim from ACPICA, so any change to those files will have to be sent to the ACPICA project and wouldn't be accepted here. More likely, we'd want to do something about the circular-include situation between linux/fw_table.h<->linux/acpi.h. That may have further consequences down the road than just our problem here. Perhaps just dropping both #includes from fw_table.h, and lowering the fw_table.h include from within linux/acpi.h to be below <acpi/acpi.h>, is the way to go? Kind regards, Sam
On Tue, Nov 14, 2023 at 7:09 PM Sam Edwards <cfsworks@gmail.com> wrote: > I am not an ACPI subsystem maintainer, but my understanding is that the > files in include/acpi/ are copied verbatim from ACPICA, so any change to > those files will have to be sent to the ACPICA project and wouldn't be > accepted here. > > More likely, we'd want to do something about the circular-include > situation between linux/fw_table.h<->linux/acpi.h. I agree but I have no idea how to fix that really, should I just send a revert instead so the authors can get some time to figure it out? Yours, Linus Walleij
Hi Linus, On Tue, Nov 14, 2023 at 2:20 PM Linus Walleij <linus.walleij@linaro.org> wrote: > > On Tue, Nov 14, 2023 at 7:09 PM Sam Edwards <cfsworks@gmail.com> wrote: > > > I am not an ACPI subsystem maintainer, but my understanding is that the > > files in include/acpi/ are copied verbatim from ACPICA, so any change to > > those files will have to be sent to the ACPICA project and wouldn't be > > accepted here. > > > > More likely, we'd want to do something about the circular-include > > situation between linux/fw_table.h<->linux/acpi.h. > > I agree but I have no idea how to fix that really, should I just send > a revert instead so the authors can get some time to figure it out? > Just want to confirm that linux-mainline and linux-next builds are broken for my ARM64 board as well, because of the commit you pin-pointed. I vote for reverting it and letting the author rework it properly. On a side note: I'm surprised there are no bots or automatic CI builds out there testing the kernel builds with baremetal toolchains. Can't believe everyone's using Linux toolchain, the kernel is supposed to be baremetal project. > Yours, > Linus Walleij
On Tue, Nov 14, 2023 at 7:09 PM Sam Edwards <cfsworks@gmail.com> wrote: > > On 11/13/23 16:08, Linus Walleij wrote: > > After commit a103f46633fd the kernel stopped compiling for > > several ARM32 platforms that I am building with a bare metal > > compiler. Bare metal compilers (arm-none-eabi-) don't > > define __linux__. > > Hi Linus, > > I saw the same baremetal-compiler error here on the ARM64 side of the > fence, and narrowed the problem to the same commit as you. > > > > > This is because the header <acpi/platform/acenv.h> is now > > in the include path for <linux/irq.h>: > > More generally, I think it's because of this addition to linux/acpi.h: > +#include <linux/fw_table.h> > > linux/acpi.h is supposed to ensure _LINUX is defined (if it isn't > already done by a non-baremetal compiler) before we start pulling in > ACPICA includes, so that ACPICA knows the platform. But because > fw_table.h contains: > #include <linux/acpi.h> > #include <acpi/acpi.h> > > ...the circular include does nothing (linux/acpi.h's include guard stops > the include before _LINUX is defined) and we end up pulling in > acpi/acpi.h before we're ready. Yes, that's the problem AFAICS. Dave? What about moving the fw_table.h include in linux/acpi.h below the mutex.h one, along with the EXPORT_SYMBOL_ACPI_LIB-related definitions? BTW, I'm not really sure why fw_table.h needs to include both linux/acpi.h and acpi/acpi.h, because it should get the latter through the former anyway. > > > > CC arch/arm/kernel/irq.o > > CC kernel/sysctl.o > > CC crypto/api.o > > In file included from ../include/acpi/acpi.h:22, > > from ../include/linux/fw_table.h:29, > > from ../include/linux/acpi.h:18, > > from ../include/linux/irqchip.h:14, > > from ../arch/arm/kernel/irq.c:25: > > ../include/acpi/platform/acenv.h:218:2: error: #error Unknown target environment > > 218 | #error Unknown target environment > > | ^~~~~ > > > > One solution to make compilation with a bare metal compiler > > work again is to say the file is used with Linux from within > > the kernel if __KERNEL__ is defined so I did that. > > I am not an ACPI subsystem maintainer, but my understanding is that the > files in include/acpi/ are copied verbatim from ACPICA, so any change to > those files will have to be sent to the ACPICA project and wouldn't be > accepted here. There are exceptions, but generally you are right. > More likely, we'd want to do something about the circular-include > situation between linux/fw_table.h<->linux/acpi.h. That may have further > consequences down the road than just our problem here. Perhaps just > dropping both #includes from fw_table.h, and lowering the fw_table.h > include from within linux/acpi.h to be below <acpi/acpi.h>, is the way > to go? Something like that.
On 11/20/23 08:46, Rafael J. Wysocki wrote: > On Tue, Nov 14, 2023 at 7:09 PM Sam Edwards <cfsworks@gmail.com> wrote: >> >> On 11/13/23 16:08, Linus Walleij wrote: >>> After commit a103f46633fd the kernel stopped compiling for >>> several ARM32 platforms that I am building with a bare metal >>> compiler. Bare metal compilers (arm-none-eabi-) don't >>> define __linux__. >> >> Hi Linus, >> >> I saw the same baremetal-compiler error here on the ARM64 side of the >> fence, and narrowed the problem to the same commit as you. >> >>> >>> This is because the header <acpi/platform/acenv.h> is now >>> in the include path for <linux/irq.h>: >> >> More generally, I think it's because of this addition to linux/acpi.h: >> +#include <linux/fw_table.h> >> >> linux/acpi.h is supposed to ensure _LINUX is defined (if it isn't >> already done by a non-baremetal compiler) before we start pulling in >> ACPICA includes, so that ACPICA knows the platform. But because >> fw_table.h contains: >> #include <linux/acpi.h> >> #include <acpi/acpi.h> >> >> ...the circular include does nothing (linux/acpi.h's include guard stops >> the include before _LINUX is defined) and we end up pulling in >> acpi/acpi.h before we're ready. Not including either causes compile errors for me. And directly including acpi/acpi.h w/o linux/acpi.h causes triggering the #error and some other stuff: ./include/acpi/platform/aclinux.h:18:2: error: #error "Please don't include <acpi/acpi.h> directly, include <linux/acpi.h> instead." 18 | #error "Please don't include <acpi/acpi.h> directly, include <linux/acpi.h> instead." | ^~~~~ Only including linux/acpi.h: In file included from ./include/linux/acpi.h:18, from init/main.c:30: ./include/linux/fw_table.h:32:37: error: field ‘common’ has incomplete type 32 | struct acpi_subtable_header common; | ^~~~~~ ./include/linux/fw_table.h:33:36: error: field ‘hmat’ has incomplete type 33 | struct acpi_hmat_structure hmat; | ^~~~ ./include/linux/fw_table.h:34:40: error: field ‘prmt’ has incomplete type 34 | struct acpi_prmt_module_header prmt; | ^~~~ ./include/linux/fw_table.h:35:33: error: field ‘cedt’ has incomplete type 35 | struct acpi_cedt_header cedt; | ^~~~ > > Yes, that's the problem AFAICS. Dave? > > What about moving the fw_table.h include in linux/acpi.h below the > mutex.h one, along with the EXPORT_SYMBOL_ACPI_LIB-related > definitions? This builds cleanly for me. > > BTW, I'm not really sure why fw_table.h needs to include both > linux/acpi.h and acpi/acpi.h, because it should get the latter through > the former anyway. > >>> >>> CC arch/arm/kernel/irq.o >>> CC kernel/sysctl.o >>> CC crypto/api.o >>> In file included from ../include/acpi/acpi.h:22, >>> from ../include/linux/fw_table.h:29, >>> from ../include/linux/acpi.h:18, >>> from ../include/linux/irqchip.h:14, >>> from ../arch/arm/kernel/irq.c:25: >>> ../include/acpi/platform/acenv.h:218:2: error: #error Unknown target environment >>> 218 | #error Unknown target environment >>> | ^~~~~ >>> >>> One solution to make compilation with a bare metal compiler >>> work again is to say the file is used with Linux from within >>> the kernel if __KERNEL__ is defined so I did that. >> >> I am not an ACPI subsystem maintainer, but my understanding is that the >> files in include/acpi/ are copied verbatim from ACPICA, so any change to >> those files will have to be sent to the ACPICA project and wouldn't be >> accepted here. > > There are exceptions, but generally you are right. > >> More likely, we'd want to do something about the circular-include >> situation between linux/fw_table.h<->linux/acpi.h. That may have further >> consequences down the road than just our problem here. Perhaps just >> dropping both #includes from fw_table.h, and lowering the fw_table.h >> include from within linux/acpi.h to be below <acpi/acpi.h>, is the way >> to go? > > Something like that.
On Mon, Nov 20, 2023 at 5:19 PM Dave Jiang <dave.jiang@intel.com> wrote: > > > > On 11/20/23 08:46, Rafael J. Wysocki wrote: > > On Tue, Nov 14, 2023 at 7:09 PM Sam Edwards <cfsworks@gmail.com> wrote: > >> > >> On 11/13/23 16:08, Linus Walleij wrote: > >>> After commit a103f46633fd the kernel stopped compiling for > >>> several ARM32 platforms that I am building with a bare metal > >>> compiler. Bare metal compilers (arm-none-eabi-) don't > >>> define __linux__. > >> > >> Hi Linus, > >> > >> I saw the same baremetal-compiler error here on the ARM64 side of the > >> fence, and narrowed the problem to the same commit as you. > >> > >>> > >>> This is because the header <acpi/platform/acenv.h> is now > >>> in the include path for <linux/irq.h>: > >> > >> More generally, I think it's because of this addition to linux/acpi.h: > >> +#include <linux/fw_table.h> > >> > >> linux/acpi.h is supposed to ensure _LINUX is defined (if it isn't > >> already done by a non-baremetal compiler) before we start pulling in > >> ACPICA includes, so that ACPICA knows the platform. But because > >> fw_table.h contains: > >> #include <linux/acpi.h> > >> #include <acpi/acpi.h> > >> > >> ...the circular include does nothing (linux/acpi.h's include guard stops > >> the include before _LINUX is defined) and we end up pulling in > >> acpi/acpi.h before we're ready. > > Not including either causes compile errors for me. Interesting. What errors do you get if you include linux/acpi.h only? It should not be necessary to include acpi/acpi.h in addition to linux/acpi.h, because the latter is expected to include the former. If it doesn't do that, something is amiss. > And directly including acpi/acpi.h w/o linux/acpi.h causes triggering the #error and some other stuff: > > ./include/acpi/platform/aclinux.h:18:2: error: #error "Please don't include <acpi/acpi.h> directly, include <linux/acpi.h> instead." > 18 | #error "Please don't include <acpi/acpi.h> directly, include <linux/acpi.h> instead." > | ^~~~~ > > > Only including linux/acpi.h: > In file included from ./include/linux/acpi.h:18, > from init/main.c:30: > ./include/linux/fw_table.h:32:37: error: field ‘common’ has incomplete type > 32 | struct acpi_subtable_header common; > | ^~~~~~ > ./include/linux/fw_table.h:33:36: error: field ‘hmat’ has incomplete type > 33 | struct acpi_hmat_structure hmat; > | ^~~~ > ./include/linux/fw_table.h:34:40: error: field ‘prmt’ has incomplete type > 34 | struct acpi_prmt_module_header prmt; > | ^~~~ > ./include/linux/fw_table.h:35:33: error: field ‘cedt’ has incomplete type > 35 | struct acpi_cedt_header cedt; > | ^~~~ > > > > > > Yes, that's the problem AFAICS. Dave? > > > > What about moving the fw_table.h include in linux/acpi.h below the > > mutex.h one, along with the EXPORT_SYMBOL_ACPI_LIB-related > > definitions? > > This builds cleanly for me. OK, so I'm wondering if this also helps the other people in this thread.
On 11/20/23 09:38, Rafael J. Wysocki wrote: > On Mon, Nov 20, 2023 at 5:19 PM Dave Jiang <dave.jiang@intel.com> wrote: >> >> >> >> On 11/20/23 08:46, Rafael J. Wysocki wrote: >>> On Tue, Nov 14, 2023 at 7:09 PM Sam Edwards <cfsworks@gmail.com> wrote: >>>> >>>> On 11/13/23 16:08, Linus Walleij wrote: >>>>> After commit a103f46633fd the kernel stopped compiling for >>>>> several ARM32 platforms that I am building with a bare metal >>>>> compiler. Bare metal compilers (arm-none-eabi-) don't >>>>> define __linux__. >>>> >>>> Hi Linus, >>>> >>>> I saw the same baremetal-compiler error here on the ARM64 side of the >>>> fence, and narrowed the problem to the same commit as you. >>>> >>>>> >>>>> This is because the header <acpi/platform/acenv.h> is now >>>>> in the include path for <linux/irq.h>: >>>> >>>> More generally, I think it's because of this addition to linux/acpi.h: >>>> +#include <linux/fw_table.h> >>>> >>>> linux/acpi.h is supposed to ensure _LINUX is defined (if it isn't >>>> already done by a non-baremetal compiler) before we start pulling in >>>> ACPICA includes, so that ACPICA knows the platform. But because >>>> fw_table.h contains: >>>> #include <linux/acpi.h> >>>> #include <acpi/acpi.h> >>>> >>>> ...the circular include does nothing (linux/acpi.h's include guard stops >>>> the include before _LINUX is defined) and we end up pulling in >>>> acpi/acpi.h before we're ready. >> >> Not including either causes compile errors for me. > > Interesting. What errors do you get if you include linux/acpi.h only? > > It should not be necessary to include acpi/acpi.h in addition to > linux/acpi.h, because the latter is expected to include the former. > If it doesn't do that, something is amiss. > CC arch/x86/video/fbdev.o In file included from ./include/linux/acpi.h:18, from ./include/linux/tpm.h:21, from ./include/keys/trusted-type.h:12, from security/keys/encrypted-keys/encrypted.c:22: ./include/linux/fw_table.h:32:37: error: field ‘common’ has incomplete type 32 | struct acpi_subtable_header common; | ^~~~~~ ./include/linux/fw_table.h:33:36: error: field ‘hmat’ has incomplete type 33 | struct acpi_hmat_structure hmat; | ^~~~ ./include/linux/fw_table.h:34:40: error: field ‘prmt’ has incomplete type 34 | struct acpi_prmt_module_header prmt; | ^~~~ ./include/linux/fw_table.h:35:33: error: field ‘cedt’ has incomplete type 35 | struct acpi_cedt_header cedt; | ^~~~ However, if I move fw_table.h in linux/acpi.h below include of asm/acpi.h, then we can build successfully w/o including acpi/acpi.h in fw_table.h. diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 54189e0e5f41..2789beb26138 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -15,7 +15,6 @@ #include <linux/mod_devicetable.h> #include <linux/property.h> #include <linux/uuid.h> -#include <linux/fw_table.h> struct irq_domain; struct irq_domain_ops; @@ -25,16 +24,6 @@ struct irq_domain_ops; #endif #include <acpi/acpi.h> -#ifdef CONFIG_ACPI_TABLE_LIB -#define EXPORT_SYMBOL_ACPI_LIB(x) EXPORT_SYMBOL_NS_GPL(x, ACPI) -#define __init_or_acpilib -#define __initdata_or_acpilib -#else -#define EXPORT_SYMBOL_ACPI_LIB(x) -#define __init_or_acpilib __init -#define __initdata_or_acpilib __initdata -#endif - #ifdef CONFIG_ACPI #include <linux/list.h> @@ -48,6 +37,18 @@ struct irq_domain_ops; #include <acpi/acpi_io.h> #include <asm/acpi.h> +#include <linux/fw_table.h> + +#ifdef CONFIG_ACPI_TABLE_LIB +#define EXPORT_SYMBOL_ACPI_LIB(x) EXPORT_SYMBOL_NS_GPL(x, ACPI) +#define __init_or_acpilib +#define __initdata_or_acpilib +#else +#define EXPORT_SYMBOL_ACPI_LIB(x) +#define __init_or_acpilib __init +#define __initdata_or_acpilib __initdata +#endif + static inline acpi_handle acpi_device_handle(struct acpi_device *adev) { return adev ? adev->handle : NULL; diff --git a/include/linux/fw_table.h b/include/linux/fw_table.h index ff8fa58d5818..a722300c215b 100644 --- a/include/linux/fw_table.h +++ b/include/linux/fw_table.h @@ -26,7 +26,6 @@ struct acpi_subtable_proc { }; #include <linux/acpi.h> -#include <acpi/acpi.h> union acpi_subtable_headers { struct acpi_subtable_header common; >> And directly including acpi/acpi.h w/o linux/acpi.h causes triggering the #error and some other stuff: >> >> ./include/acpi/platform/aclinux.h:18:2: error: #error "Please don't include <acpi/acpi.h> directly, include <linux/acpi.h> instead." >> 18 | #error "Please don't include <acpi/acpi.h> directly, include <linux/acpi.h> instead." >> | ^~~~~ >> >> >> Only including linux/acpi.h: >> In file included from ./include/linux/acpi.h:18, >> from init/main.c:30: >> ./include/linux/fw_table.h:32:37: error: field ‘common’ has incomplete type >> 32 | struct acpi_subtable_header common; >> | ^~~~~~ >> ./include/linux/fw_table.h:33:36: error: field ‘hmat’ has incomplete type >> 33 | struct acpi_hmat_structure hmat; >> | ^~~~ >> ./include/linux/fw_table.h:34:40: error: field ‘prmt’ has incomplete type >> 34 | struct acpi_prmt_module_header prmt; >> | ^~~~ >> ./include/linux/fw_table.h:35:33: error: field ‘cedt’ has incomplete type >> 35 | struct acpi_cedt_header cedt; >> | ^~~~ >> >> >>> >>> Yes, that's the problem AFAICS. Dave? >>> >>> What about moving the fw_table.h include in linux/acpi.h below the >>> mutex.h one, along with the EXPORT_SYMBOL_ACPI_LIB-related >>> definitions? >> >> This builds cleanly for me. > > OK, so I'm wondering if this also helps the other people in this thread.
On Mon, Nov 20, 2023 at 5:53 PM Dave Jiang <dave.jiang@intel.com> wrote: > However, if I move fw_table.h in linux/acpi.h below include of asm/acpi.h, then we > can build successfully w/o including acpi/acpi.h in fw_table.h. This looks reasonable to me, can you send a formal patch so I can test? Yours, Linus Walleij
On 11/21/23 06:32, Linus Walleij wrote: > On Mon, Nov 20, 2023 at 5:53 PM Dave Jiang <dave.jiang@intel.com> wrote: > >> However, if I move fw_table.h in linux/acpi.h below include of asm/acpi.h, then we >> can build successfully w/o including acpi/acpi.h in fw_table.h. > > This looks reasonable to me, can you send a formal patch so I can test? https://lore.kernel.org/linux-acpi/170058229266.2356592.11579977558324549374.stgit@djiang5-mobl3/ Thanks! > > Yours, > Linus Walleij
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h index 337ffa931ee8..76444ffdc549 100644 --- a/include/acpi/platform/acenv.h +++ b/include/acpi/platform/acenv.h @@ -156,7 +156,7 @@ #endif -#if defined(_LINUX) || defined(__linux__) +#if defined(_LINUX) || defined(__linux__) || defined(__KERNEL__) #include <acpi/platform/aclinux.h> #elif defined(_APPLE) || defined(__APPLE__)