vmware-modules failed with too many arguments to function smp_call_function and smp_call_function_single

vmware-modules is really tough to compile on a bleeding edge kernel like last versions from kernel.org When a new kernel is out the chances you cannot vmware modules are really big and if you look at the patches a gentoo build applies at present 40 (at the end you can see a log from Gentoo) an almost all begin with

kernel_version-[why_is_needed].patch

But apparently not only the patches are needed the CFLAGS are also important. And if you include

-fomit-frame-pointer in CFLAGS/CXXFLAGS

you’ll get into troubles! And this is not specific to Gentoo and probably not to specific kernel version, because there are reports from 2012 and before 2012! So if you have the following error:

In file included from /var/tmp/portage/app-emulation/vmware-modules-308.5.9/work/vmmon-only/linux/driver.c:69:0:
/var/tmp/portage/app-emulation/vmware-modules-308.5.9/work/vmmon-only/linux/driver.c: In function ‘LinuxDriverEstimateTSCkHz’:
/var/tmp/portage/app-emulation/vmware-modules-308.5.9/work/vmmon-only/linux/vmmonInt.h:88:15: error: too many arguments to function ‘smp_call_function_single’
               smp_call_function_single(cpu, fn, info, 1, wait)
               ^
/var/tmp/portage/app-emulation/vmware-modules-308.5.9/work/vmmon-only/linux/driver.c:208:10: note: in expansion of macro ‘compat_smp_call_function_single’
    err = compat_smp_call_function_single(0, LinuxDriverEstimateTSCkHzWork,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/src/linux-4.16.3-gentoo/include/linux/percpu.h:7:0,
                 from /usr/src/linux-4.16.3-gentoo/include/linux/percpu-rwsem.h:7,
                 from /usr/src/linux-4.16.3-gentoo/include/linux/fs.h:33,
                 from /usr/src/linux-4.16.3-gentoo/include/linux/highmem.h:5,
                 from /var/tmp/portage/app-emulation/vmware-modules-308.5.9/work/vmmon-only/linux/driver.c:25:
/usr/src/linux-4.16.3-gentoo/include/linux/smp.h:32:5: note: declared here
 int smp_call_function_single(int cpuid, smp_call_func_t func, void *info,
     ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /var/tmp/portage/app-emulation/vmware-modules-308.5.9/work/vmmon-only/linux/driver.c:69:0:
/var/tmp/portage/app-emulation/vmware-modules-308.5.9/work/vmmon-only/linux/driver.c: In function ‘LinuxDriverSyncCallOnEachCPU’:
/var/tmp/portage/app-emulation/vmware-modules-308.5.9/work/vmmon-only/linux/vmmonInt.h:34:50: error: too many arguments to function ‘smp_call_function’
 #define compat_smp_call_function(fn, info, wait) smp_call_function(fn, info, 1, wait)
                                                  ^
/var/tmp/portage/app-emulation/vmware-modules-308.5.9/work/vmmon-only/linux/driver.c:1224:4: note: in expansion of macro ‘compat_smp_call_function’
    compat_smp_call_function(LinuxDriverSyncCallHook, &args, 0);
    ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/src/linux-4.16.3-gentoo/include/linux/percpu.h:7:0,
                 from /usr/src/linux-4.16.3-gentoo/include/linux/percpu-rwsem.h:7,
                 from /usr/src/linux-4.16.3-gentoo/include/linux/fs.h:33,
                 from /usr/src/linux-4.16.3-gentoo/include/linux/highmem.h:5,
                 from /var/tmp/portage/app-emulation/vmware-modules-308.5.9/work/vmmon-only/linux/driver.c:25:
/usr/src/linux-4.16.3-gentoo/include/linux/smp.h:100:5: note: declared here
 int smp_call_function(smp_call_func_t func, void *info, int wait);
     ^~~~~~~~~~~~~~~~~
distcc[32709] ERROR: compile /var/tmp/portage/app-emulation/vmware-modules-308.5.9/work/vmmon-only/linux/driver.c on localhost failed
make[3]: *** [/usr/src/linux-4.16.3-gentoo/scripts/Makefile.build:325: /var/tmp/portage/app-emulation/vmware-modules-308.5.9/work/vmmon-only/linux/driver.o] Error 1
make[3]: *** Waiting for unfinished jobs....

Revise your CFLAGS/CXXFLAGS environment variables and remove “-fomit-frame-pointer”.

In our system we used (manual compile/install):

export CFLAGS="-O2 -msse -msse2 -mssse3 -march=core2 -pipe"
export CXXFLAGS="${CFLAGS}"
export LDFLAGS="-Wl,-O1"

or for Gentoo configuration file /etc/portage/make.conf

CFLAGS="-O2 -msse -msse2 -mssse3 -march=core2 -pipe"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,-O1"

* All needed patches in Gentoo for compiling vmware-modules 308.5.9 ( with vmware-player-12.5.9.7535481 ) successfully in a modern kernel

>>> Preparing source in /var/tmp/portage/app-emulation/vmware-modules-308.5.9/work ...
 * Applying 308-makefile-kernel-dir.patch ...                [ ok ]
 * Applying 308-makefile-include.patch ...                   [ ok ]
 * Applying 308-netdevice.patch ...                          [ ok ]
 * Applying 308-apic.patch ...                               [ ok ]
 * Applying 308-3.10-00-dentry.patch ...                     [ ok ]
 * Applying 308-3.10-01-inode.patch ...                      [ ok ]
 * Applying 308-3.10-02-control.patch ...                    [ ok ]
 * Applying 308-3.10-03-inline.patch ...                     [ ok ]
 * Applying 308-3.11-00-readdir.patch ...                    [ ok ]
 * Applying 308-3.11-01-filldir.patch ...                    [ ok ]
 * Applying 308-3.15-00-vsock.patch ...                      [ ok ]
 * Applying 308-3.18-00-version-redefined.patch ...          [ ok ]
 * Applying 308-3.19-00-compat-namei.patch ...               [ ok ]
 * Applying 308-3.19-02-vmblock-path.patch ...               [ ok ]
 * Applying 308-3.19-04-iovec.patch ...                      [ ok ]
 * Applying 308-3.19-05-vmci_qpair.patch ...                 [ ok ]
 * Applying 308-3.19-06-vsock.patch ...                      [ ok ]
 * Applying 308-3.19-07-vsock.patch ...                      [ ok ]
 * Applying 308-4.01-00-vsock.patch ...                      [ ok ]
 * Applying 308-4.02-00-nd_set_link.patch ...                [ ok ]
 * Applying 308-4.02-01-sk_alloc.patch ...                   [ ok ]
 * Applying 308-4.03-00-vmci-misc_deregister.patch ...       [ ok ]
 * Applying 308-4.05-00-vmblock-follow_link.patch ...        [ ok ]
 * Applying 308-4.06-00-user-pages.patch ...                 [ ok ]
 * Applying 308-4.07-01-readlink_copy.patch ...              [ ok ]
 * Applying 308-4.08-00-vmmon-fix-page-accounting.patch ...  [ ok ]
 * Applying 308-4.09-00-user-pages.patch ...                 [ ok ]
 * Applying 308-4.10-00-generic_readlink.patch ...           [ ok ]
 * Applying 308-4.11-00-missing-headers.patch ...            [ ok ]
 * Applying 308-4.11-01-vsock-lockdep.patch ...              [ ok ]
 * Applying 308-4.12-00-vmblock-current_time.patch ...       [ ok ]
 * Applying 308-4.12-01-vmci-do_once.patch ...               [ ok ]
 * Applying 308-4.12-02-vmci-pci_enable_msix.patch ...       [ ok ]
 * Applying 308-4.13-00-vmnet-refcount.patch ...             [ ok ]
 * Applying 308-4.13-01-vmmon-fix-page-accounting.patch ...  [ ok ]
 * Applying 308-4.14-00-vmmon-global-page-state.patch ...    [ ok ]
 * Applying 308-4.14-01-deprecated-asm-uaccess.patch ...     [ ok ]
 * Applying 308-4.15-00-init_timer.patch ...                 [ ok ]
 * Applying 308-4.16-00-vmblock-iversion.patch ...           [ ok ]
>>> Source prepared.

In fact if you come from another linux distro and need some of the patches you could always download them if you need – just paste the name of the patch file in let’s say google and you’ll get the patch or you can always add vmware overlay, but you should have Gentoo.