On Thu, Jan 30, 2020 at 11:34:26AM -0400, Jason Gunthorpe wrote: > On Thu, Jan 30, 2020 at 01:29:57PM +0200, Leon Romanovsky wrote: > > From: Leon Romanovsky <leonro@xxxxxxxxxxxx> > > > > Compilation of mlx5 driver without CONFIG_INFINIBAND_USER_ACCESS generates > > the following error. > > > > on x86_64: > > > > ld: drivers/infiniband/hw/mlx5/main.o: in function `mlx5_ib_handler_MLX5_IB_METHOD_VAR_OBJ_ALLOC': > > main.c:(.text+0x186d): undefined reference to `ib_uverbs_get_ucontext_file' > > ld: drivers/infiniband/hw/mlx5/main.o:(.rodata+0x2480): undefined reference to `uverbs_idr_class' > > ld: drivers/infiniband/hw/mlx5/main.o:(.rodata+0x24d8): undefined reference to `uverbs_destroy_def_handler' > > > > Guard the problematic code, so VAR objects API won't be compiled without CONFIG_INFINIBAND_USER_ACCESS. > > > > Fixes: 7be76bef320b ("IB/mlx5: Introduce VAR object and its alloc/destroy methods") > > Reported-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx> > > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> > > drivers/infiniband/hw/mlx5/main.c | 22 +++++++++++++--------- > > 1 file changed, 13 insertions(+), 9 deletions(-) > > Hurm. This is actually a side effect of some other code that needs to > be deleted.. We can now make all the generated structs static and rely > on compiler pruning to sort this out. > > So this: > > if (IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)) > dev->ib_dev.driver_def = mlx5_ib_defs; > > Will cause the compiler to drop the entire tree of stuff, above > references inclded. It is viable solution too, more cryptic than previous one, but cleaner for sure. Thanks