FWIW, the attached patch enables compatibility with 4.0. Same modification to genorig.py as in Luca Boccassi's patch, tools-perf-version.patch has changed once again and Makefile.kasan needs to be included, that's all.
The perf-fix-building-error-in-x86_64.patch necessary for 3.19 is not needed with 4.0, this was fixed upstream. Probably not worth opening a separate bug, so tacking on to this one. Tested with rc6, rc5, rc4.
Index: debian/bin/genorig.py =================================================================== --- debian/bin/genorig.py (revision 22457) +++ debian/bin/genorig.py (working copy) @@ -145,6 +145,7 @@ 'arch/x86/lib/memcpy_64.S', 'arch/x86/lib/memset_64.S', 'include/', + 'lib/hweight.c', 'lib/rbtree.c', 'scripts/', 'tools/', Index: debian/build/scripts/Makefile =================================================================== --- debian/build/scripts/Makefile (revision 22457) +++ debian/build/scripts/Makefile (working copy) @@ -10,6 +10,7 @@ Makefile.clean \ Makefile.extrawarn \ Makefile.host \ + Makefile.kasan \ Makefile.lib \ Makefile.modinst \ Makefile.modpost \ Index: debian/patches/tools-perf-version.patch =================================================================== --- debian/patches/tools-perf-version.patch (revision 22457) +++ debian/patches/tools-perf-version.patch (working copy) @@ -17,9 +17,9 @@ - $(LN) '$(DESTDIR_SQ)$(bindir_SQ)/perf' '$(DESTDIR_SQ)$(bindir_SQ)/trace' + $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)/perf_$(VERSION)'; \ + $(LN) '$(DESTDIR_SQ)$(bindir_SQ)/perf_$(VERSION)' '$(DESTDIR_SQ)$(bindir_SQ)/trace_$(VERSION)' - $(call QUIET_INSTALL, libexec) \ - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)' - $(call QUIET_INSTALL, perf-archive) \ + ifndef NO_PERF_READ_VDSO32 + $(call QUIET_INSTALL, perf-read-vdso32) \ + $(INSTALL) $(OUTPUT)perf-read-vdso32 '$(DESTDIR_SQ)$(bindir_SQ)'; @@ -857,7 +857,7 @@ ifndef NO_LIBPYTHON endif $(call QUIET_INSTALL, perf_completion-script) \