Re: [PATCH 4.19 18/56] hv: utils: add PTP_1588_CLOCK to Kconfig to fix build

From: Arnd Bergmann
Date: Mon Dec 20 2021 - 15:49:56 EST


On Mon, Dec 20, 2021 at 9:31 PM Pavel Machek <pavel@xxxxxx> wrote:
> > From: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
> >
> > [ Upstream commit 1dc2f2b81a6a9895da59f3915760f6c0c3074492 ]
> >
> > The hyperv utilities use PTP clock interfaces and should depend a
> > a kconfig symbol such that they will be built as a loadable module or
> > builtin so that linker errors do not happen.
> >
> > Prevents these build errors:
> >
> > ld: drivers/hv/hv_util.o: in function `hv_timesync_deinit':
> > hv_util.c:(.text+0x37d): undefined reference to `ptp_clock_unregister'
> > ld: drivers/hv/hv_util.o: in function `hv_timesync_init':
> > hv_util.c:(.text+0x738): undefined reference to `ptp_clock_register'
>
> This is bad idea for 4.19:
>
> > +++ b/drivers/hv/Kconfig
> > @@ -16,6 +16,7 @@ config HYPERV_TSCPAGE
> > config HYPERV_UTILS
> > tristate "Microsoft Hyper-V Utilities driver"
> > depends on HYPERV && CONNECTOR && NLS
> > + depends on PTP_1588_CLOCK_OPTIONAL
> > help
> > Select this option to enable the Hyper-V Utilities.
>
> grep -ri PTP_1588_CLOCK_OPTIONAL .
>
> Results in no result in 4.19. So this will break hyperv. No results in
> 5.10, either, so it is bad idea there, too.

Right, this doesn't work, but the bug does exist anyway, and could be
fixed by listing the dependency explicitly as

depends on PTP_1588_CLOCK || PTP_1588_CLOCK=n

The PTP_1588_CLOCK_OPTIONAL was added as a shortcut to
avoid the odd Kconfig syntax that most developers struggle with understanding
at first.

Arnd