Thanks for helping :). After going back and forth and trying all sorts of stuff, the problem turned out to be the shell I used - it was setup to ros2-beta1 workspace, i.e. it had AMENT_PREFIX_PATH, LD_LIBRARY_PATH and all sorts of other variables pointing to the previously built beta1 workspace.
The way to fix it was very simple - just opened a fresh shell without any ROS2 setup and the build from there works just fine.
Thanks again for all your assistance, I’m back in the game