From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.avm.de (mail.avm.de [212.42.244.119]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24E6F35CBDF for ; Thu, 13 Nov 2025 20:41:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.42.244.119 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763066496; cv=none; b=uyLvhMyFsWbZSb4Qt9dMPt2FgybEtcx7ZlcA56o25BO9NhKJ/LFKPzxt3ph5UNAnHAVZULHMQbUNsE3wYenIDC2AHYMALhOCMgAhwxQBnaI8MNBxcsTNjjTbh/mLyxFNaUMBCspWvgSnAEQ3f4hb2REnuNxX1olsMjKC7vfwsqs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763066496; c=relaxed/simple; bh=jgXgoSzQymBKCdr07O/MG8j7OoW1eOkaRkwUC/jQXnE=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=MEWyZwFIUHN1Dvi+wD0WY6CZW0YMrVqzU55nH57zOExjbjsiALEfJ7865xxBHZHTXMBCo+dUmgqID+UdZCZU1WbtFe2A+iWHrfS+qvIfaij/bZEUAQTrb4UjEktCUxwzyzGaSdJ5PP5UYZ5U9GrXo4YynQdYm/CztkJf5lmmdtI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=avm.de; spf=pass smtp.mailfrom=avm.de; arc=none smtp.client-ip=212.42.244.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=avm.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=avm.de Received: from [2001:bf0:244:244::71] (helo=mail.avm.de) by mail.avm.de with ESMTP (eXpurgate 4.53.4) (envelope-from ) id 6916422f-2186-7f0000032729-7f000001bf3a-1 for ; Thu, 13 Nov 2025 21:40:15 +0100 Received: from mail-auth.avm.de (dovecot-mx-01.avm.de [IPv6:2001:bf0:244:244::71]) by mail.avm.de (Postfix) with ESMTPS; Thu, 13 Nov 2025 21:40:15 +0100 (CET) Date: Thu, 13 Nov 2025 21:40:11 +0100 From: Philipp Hahn To: Masahiro Yamada , Nicolas Schier Cc: linux-kernel@vger.kernel.org Subject: genksyms vs. opaque struct * Message-ID: Mail-Followup-To: Masahiro Yamada , Nicolas Schier , linux-kernel@vger.kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-purgate-ID: 149429::1763066415-105F4CF8-4354BFA5/0/0 X-purgate-type: clean X-purgate-size: 2129 X-purgate-Ad: Categorized by eleven eXpurgate (R) https://www.eleven.de X-purgate: This mail is considered clean (visit https://www.eleven.de for further information) X-purgate: clean Hello, while building a Linux kernel module I stumbled over an issue with 'genksyms': Basically my modules uses an "opaque struct" and only gets a pointer to such an object. The header file declaring that struct did *not* #include all needed header files recursively, so some types remained unresolved. For compiling the module this was not an issue as the compiler only needs to allocate space for an pointer to that nested struct and does not need more details. Another module exists which uses that symbol and recorded the calculated CRC. Then I changed my module and added some more #includes, which resulted into `genksyms` getting *more* details on the next run while the implementation actually did not change. I only found out root cause of my problem after digging into the genksyms-machinery myself, where I found the option `--warnings`, which actually prints out such a warning in my case: > /home/pmhahn/prog/my-modver/my-modver.c:8: expand undefined struct bar In my example below it makes a difference if `-DDETAIL` is given or not: > cpp -E -D__GENKSYMS__ …my-modver.c -DDETAIL | scripts/genksyms/genksyms -r /dev/null -w > #SYMVER my_function 0x0cdb4509 > cpp -E -D__GENKSYMS__ …my-modver.c | scripts/genksyms/genksyms -r /dev/null -w > #SYMVER my_function 0x87675506 I wonder, why that option is not enabled by default or if there is another solution to prevent such breaking changed by including more/less #includes? Are there any good/recommended practices? Below is my simplified example with my two source files. Attached is the full output from running `genksyms`. $ cat my-modver.c #################### #include #include #include "my-modver.h" void my_function(struct foo *arg) { printk(KERN_INFO "Hello %d", arg->value); } EXPORT_SYMBOL(my_function); MODULE_LICENSE("MIT"); $ cat my-modver.h #################### struct bar; #ifdef DETAIL struct bar { int nested; }; #endif struct foo { int value; struct bar *nested; }; void my_function(struct foo *arg); Thanks in advance for your answer. Philipp Hahn