I was able to get rid of the error when trying to load the wlan.ko module by adding the option CONFIG_MODVERSIONS=n. But now I get another error:
<3>[ 21.083079] wlan: version magic '3.4.0-perf SMP preempt mod_unload modversions ARMv7 ' should be '3.4.0-perf SMP preempt mod_unload ARMv7 '
Trying to disable the checking on the kernel code made everything crash horribly. On a real Linux, I'd be able to try modprobe --force, but Android doesn't have modprobe. Sigh.
Edit: looks like the wlan.ko source code is on a separate repo after all. Not much much luck with it yet, though:
<6>[ 1601.775384] wlan: loading driver v184.108.40.206
<3>[ 1601.854994] wlan: driver load failure
Edit 2: after looking at the error messages displayed when the module is compiled with BUILD_DEBUG_VERSION and peeking around the code I could sort of guess that the configuration was incorrect and replaced the config files under /system/etc/firmware/wlan with the ones generated during the build. Now the module is loaded correctly with insmod, but for some reason is not loaded during boot. Still no wifi.
Edit 3: it works.