From: Boqun Feng <boqun.feng@gmail.com>
To: FUJITA Tomonori <fujita.tomonori@gmail.com>
Cc: netdev@vger.kernel.org, rust-for-linux@vger.kernel.org,
andrew@lunn.ch, tmgross@umich.edu,
miguel.ojeda.sandonis@gmail.com, benno.lossin@proton.me,
wedsonaf@gmail.com
Subject: Re: [PATCH net-next v7 2/5] rust: net::phy add module_phy_driver macro
Date: Fri, 17 Nov 2023 14:21:38 -0800 [thread overview]
Message-ID: <ZVfncj5R9-8aU7vB@boqun-archlinux> (raw)
In-Reply-To: <20231026001050.1720612-3-fujita.tomonori@gmail.com>
On Thu, Oct 26, 2023 at 09:10:47AM +0900, FUJITA Tomonori wrote:
[...]
> +
> +/// Declares a kernel module for PHYs drivers.
> +///
> +/// This creates a static array of kernel's `struct phy_driver` and registers it.
> +/// This also corresponds to the kernel's `MODULE_DEVICE_TABLE` macro, which embeds the information
> +/// for module loading into the module binary file. Every driver needs an entry in `device_table`.
> +///
> +/// # Examples
> +///
> +/// ```
> +/// # mod module_phy_driver_sample {
> +/// use kernel::c_str;
> +/// use kernel::net::phy::{self, DeviceId};
> +/// use kernel::prelude::*;
> +///
> +/// kernel::module_phy_driver! {
> +/// drivers: [PhyAX88772A],
> +/// device_table: [
> +/// DeviceId::new_with_driver::<PhyAX88772A>()
> +/// ],
> +/// name: "rust_asix_phy",
> +/// author: "Rust for Linux Contributors",
> +/// description: "Rust Asix PHYs driver",
> +/// license: "GPL",
> +/// }
> +///
> +/// struct PhyAX88772A;
> +///
> +/// #[vtable]
> +/// impl phy::Driver for PhyAX88772A {
> +/// const NAME: &'static CStr = c_str!("Asix Electronics AX88772A");
> +/// const PHY_DEVICE_ID: phy::DeviceId = phy::DeviceId::new_with_exact_mask(0x003b1861);
> +/// }
> +/// # }
> +/// ```
When run the following kunit command:
./tools/testing/kunit/kunit.py run --make_options LLVM=1 --arch x86_64 \
--kconfig_add CONFIG_RUST=y \
--kconfig_add CONFIG_RUST_PHYLIB_ABSTRACTIONS=y \
--kconfig_add CONFIG_PHYLIB=y \
--kconfig_add CONFIG_NETDEVICES=y \
--kconfig_add CONFIG_NET=y \
--kconfig_add CONFIG_AX88796B_RUST_PHY=y \
--kconfig_add CONFIG_AX88796B_PHY=y
I got the following errors:
ERROR:root:ld.lld: error: duplicate symbol: __rust_asix_phy_init
>>> defined at doctests_kernel_generated.5ed8fd29a53cf22f-cgu.0
>>> rust/doctests_kernel_generated.o:(__rust_asix_phy_init) in archive vmlinux.a
>>> defined at ax88796b_rust.37fb93aefca595fa-cgu.0
>>> drivers/net/phy/ax88796b_rust.o:(.text+0x160) in archive vmlinux.a
ld.lld: error: duplicate symbol: __rust_asix_phy_exit
>>> defined at doctests_kernel_generated.5ed8fd29a53cf22f-cgu.0
>>> rust/doctests_kernel_generated.o:(__rust_asix_phy_exit) in archive vmlinux.a
>>> defined at ax88796b_rust.37fb93aefca595fa-cgu.0
>>> drivers/net/phy/ax88796b_rust.o:(.text+0x1E0) in archive vmlinux.a
ld.lld: error: duplicate symbol: __mod_mdio__phydev_device_table
>>> defined at doctests_kernel_generated.5ed8fd29a53cf22f-cgu.0
>>> rust/doctests_kernel_generated.o:(__mod_mdio__phydev_device_table) in archive vmlinux.a
>>> defined at ax88796b_rust.37fb93aefca595fa-cgu.0
>>> drivers/net/phy/ax88796b_rust.o:(.rodata+0x58) in archive vmlinux.a
Because kunit will use the above doc test to generate test, and since
CONFIG_AX88796B_RUST_PHY is also selected, the `module_phy_driver!` has
been called twice, and causes duplicate symbols.
For "rust_asix_phy_*" symbols, it's easy to fix: just rename the usage
in the example. But for __mod_mdio__phydev_device_table, it's hard-coded
in `module_phy_driver!`, I don't have a quick fix right now. Also, does
it mean `module_phy_driver!` is only supposed to be "called" once for
the entire kernel?
Regards,
Boqun
next prev parent reply other threads:[~2023-11-17 22:21 UTC|newest]
Thread overview: 108+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 0:10 [PATCH net-next v7 0/5] Rust abstractions for network PHY drivers FUJITA Tomonori
2023-10-26 0:10 ` [PATCH net-next v7 1/5] rust: core " FUJITA Tomonori
2023-10-27 19:09 ` Boqun Feng
2023-10-28 10:00 ` FUJITA Tomonori
2023-10-27 19:59 ` Boqun Feng
2023-10-27 21:19 ` Benno Lossin
2023-10-27 22:21 ` Boqun Feng
2023-10-27 22:36 ` Andrew Lunn
2023-10-27 22:50 ` Benno Lossin
2023-10-27 23:26 ` Boqun Feng
2023-10-27 23:52 ` Boqun Feng
2023-10-28 8:35 ` Benno Lossin
2023-10-27 22:40 ` Andrew Lunn
2023-10-28 15:16 ` Miguel Ojeda
2023-10-28 18:18 ` Andrew Lunn
2023-10-28 9:27 ` FUJITA Tomonori
2023-10-28 14:53 ` Andrew Lunn
2023-10-28 16:09 ` FUJITA Tomonori
2023-10-28 16:39 ` Benno Lossin
2023-10-28 19:06 ` Boqun Feng
2023-10-28 19:23 ` Andrew Lunn
2023-10-28 23:26 ` Boqun Feng
2023-10-28 16:37 ` Benno Lossin
2023-10-28 18:23 ` Andrew Lunn
2023-10-28 18:45 ` Benno Lossin
2023-10-29 4:21 ` FUJITA Tomonori
2023-10-29 16:48 ` Boqun Feng
2023-10-29 18:09 ` Boqun Feng
2023-10-29 18:26 ` Boqun Feng
2023-10-29 19:39 ` Andrew Lunn
2023-10-30 12:07 ` Miguel Ojeda
2023-10-30 12:32 ` Andrew Lunn
2023-10-29 22:58 ` FUJITA Tomonori
2023-10-30 0:19 ` Boqun Feng
2023-10-30 8:34 ` Benno Lossin
2023-10-30 12:49 ` FUJITA Tomonori
2023-10-30 16:45 ` Benno Lossin
2023-11-08 10:46 ` FUJITA Tomonori
2023-11-10 13:26 ` Andrew Lunn
2023-10-29 17:32 ` Andrew Lunn
2023-10-30 8:37 ` Benno Lossin
2023-10-30 11:22 ` Miguel Ojeda
2023-11-17 9:39 ` Alice Ryhl
2023-11-17 13:34 ` Andrew Lunn
2023-11-17 15:42 ` Alice Ryhl
2023-11-17 16:28 ` Andrew Lunn
2023-11-17 18:27 ` Alice Ryhl
2023-11-21 12:47 ` FUJITA Tomonori
2023-11-17 9:39 ` Alice Ryhl
2023-11-17 13:53 ` Andrew Lunn
2023-11-17 19:50 ` Greg KH
2023-11-17 23:28 ` Boqun Feng
2023-11-18 15:32 ` Andrew Lunn
2023-11-18 15:54 ` Boqun Feng
2023-11-19 11:06 ` Trevor Gross
2023-11-21 2:13 ` FUJITA Tomonori
2023-11-22 18:16 ` Boqun Feng
2023-11-19 13:51 ` FUJITA Tomonori
2023-11-19 16:08 ` Andrew Lunn
2023-10-26 0:10 ` [PATCH net-next v7 2/5] rust: net::phy add module_phy_driver macro FUJITA Tomonori
2023-11-17 9:39 ` Alice Ryhl
2023-11-19 10:50 ` FUJITA Tomonori
2023-11-19 10:54 ` Benno Lossin
2023-11-17 22:21 ` Boqun Feng [this message]
2023-11-17 22:54 ` Andrew Lunn
2023-11-17 23:01 ` Benno Lossin
2023-11-17 23:18 ` Andrew Lunn
2023-11-19 9:41 ` FUJITA Tomonori
2023-11-19 9:25 ` FUJITA Tomonori
2023-11-19 15:50 ` Andrew Lunn
2023-11-20 13:54 ` FUJITA Tomonori
2023-11-20 14:13 ` Andrew Lunn
2023-11-21 0:49 ` FUJITA Tomonori
2023-11-19 9:44 ` FUJITA Tomonori
2023-10-26 0:10 ` [PATCH net-next v7 3/5] rust: add second `bindgen` pass for enum exhaustiveness checking FUJITA Tomonori
2023-10-26 11:02 ` Miguel Ojeda
2023-10-26 11:54 ` FUJITA Tomonori
2023-10-26 12:22 ` Miguel Ojeda
2023-10-27 0:07 ` Andrew Lunn
2023-10-27 10:50 ` Miguel Ojeda
2023-10-26 0:10 ` [PATCH net-next v7 4/5] MAINTAINERS: add Rust PHY abstractions for ETHERNET PHY LIBRARY FUJITA Tomonori
2023-10-26 23:53 ` Andrew Lunn
2023-10-26 0:10 ` [PATCH net-next v7 5/5] net: phy: add Rust Asix PHY driver FUJITA Tomonori
2023-11-17 9:39 ` Alice Ryhl
2023-11-19 9:57 ` FUJITA Tomonori
2023-11-19 16:03 ` Andrew Lunn
2023-11-21 6:19 ` FUJITA Tomonori
2023-11-21 7:12 ` Greg KH
2023-10-26 10:39 ` [PATCH net-next v7 0/5] Rust abstractions for network PHY drivers Miguel Ojeda
2023-10-26 23:48 ` Andrew Lunn
2023-10-27 2:06 ` Boqun Feng
2023-10-27 2:47 ` Andrew Lunn
2023-10-27 3:11 ` Boqun Feng
2023-10-27 4:26 ` Boqun Feng
2023-10-27 14:26 ` Andrew Lunn
2023-10-27 16:41 ` Miguel Ojeda
2023-10-27 13:00 ` Andrew Lunn
2023-10-27 10:22 ` Miguel Ojeda
2023-10-27 13:09 ` Andrew Lunn
2023-10-27 10:21 ` Miguel Ojeda
2023-10-27 14:26 ` Jakub Kicinski
2023-10-27 16:36 ` Miguel Ojeda
2023-10-27 22:55 ` Andrew Lunn
2023-10-28 11:07 ` Miguel Ojeda
2023-10-28 11:41 ` Benno Lossin
2023-10-28 15:11 ` Miguel Ojeda
2023-10-28 15:00 ` Andrew Lunn
2023-10-28 15:11 ` Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZVfncj5R9-8aU7vB@boqun-archlinux \
--to=boqun.feng@gmail.com \
--cc=andrew@lunn.ch \
--cc=benno.lossin@proton.me \
--cc=fujita.tomonori@gmail.com \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=wedsonaf@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.