Skip to content

perf: apply patch to fix 4.9 build when inheriting kernel make flags#34068

Merged
dezgeg merged 2 commits intoNixOS:masterfrom
lopsided98:perf-4.9-fix
Jan 21, 2018
Merged

perf: apply patch to fix 4.9 build when inheriting kernel make flags#34068
dezgeg merged 2 commits intoNixOS:masterfrom
lopsided98:perf-4.9-fix

Conversation

@lopsided98
Copy link
Contributor

Motivation for this change

This PR adds a patch for the 4.9 kernel which fixes the perf build when the ARCH=x86_64 flag is passed to make. This bug was introduced in 4.8 and fixed in 4.12. I backported the fix to 4.9 and conditionally applied it to 4.9 only.

This issue was triggered by my patch which inherited makeFlags from the kernel derivation (which includes ARCH). The reason I wanted to do this was because it reduces unnecessary code duplication and should help with cross compilation (although this cannot be tested yet because some dependencies fail).

IMO, applying this patch is the best way of fixing this bug, because it actually fixes the problem rather than working around it. Alternatively, we could exclude the ARCH flag from makeFlags for 4.9, or we could just forget about this issue until cross compilation actually becomes possible.

This patch could possibly be accepted to the 4.9 upstream stable branch, if someone were willing to submit it to the mailing list.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@GrahamcOfBorg GrahamcOfBorg added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Jan 20, 2018
@dezgeg
Copy link
Contributor

dezgeg commented Jan 20, 2018

Makes sense. I can mail the stable maintainer.

@dezgeg
Copy link
Contributor

dezgeg commented Jan 20, 2018

The patch has been applied to the 4.9.y queue.

@grahamc
Copy link
Member

grahamc commented Jan 20, 2018

@GrahamcOfBorg build linuxPackages_4_9.perf

Copy link

@GrahamcOfBorg GrahamcOfBorg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failure for system: x86_64-darwin

while evaluating 'makeOverridable' at /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/lib/customisation.nix:72:24, called from /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/lib/customisation.nix:117:8:
while evaluating anonymous function at /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/pkgs/os-specific/linux/kernel/perf.nix:1:1, called from /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/lib/customisation.nix:74:12:
while evaluating 'versionAtLeast' at /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/lib/strings.nix:371:24, called from /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/pkgs/os-specific/linux/kernel/perf.nix:9:8:
while evaluating 'versionOlder' at /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/lib/strings.nix:359:22, called from /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/lib/strings.nix:371:29:
while evaluating the attribute 'linux_4_9' at /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/pkgs/top-level/all-packages.nix:12853:3:
while evaluating 'callPackageWith' at /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/lib/customisation.nix:113:35, called from /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/pkgs/top-level/all-packages.nix:12853:15:
while evaluating 'makeOverridable' at /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/lib/customisation.nix:72:24, called from /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/lib/customisation.nix:117:8:
while evaluating anonymous function at /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/pkgs/os-specific/linux/kernel/linux-4.9.nix:1:1, called from /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/lib/customisation.nix:74:12:
while evaluating anonymous function at /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/pkgs/os-specific/linux/kernel/generic.nix:1:1, called from /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/pkgs/os-specific/linux/kernel/linux-4.9.nix:3:1:
assertion failed at /Users/graham/nix-borg/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-zoidberg/pkgs/os-specific/linux/kernel/generic.nix:33:1

Copy link

@GrahamcOfBorg GrahamcOfBorg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Success for system: x86_64-linux

/nix/store/a2cxjs1lklbpd87vh2a9mnc5kkkgzspm-perf-linux-4.9.77/libexec/perf-core/scripts/python/bin/syscall-counts-by-pid-record: interpreter directive changed from "/bin/bash" to "/nix/store/i0ay05pqkbnvpfijm52mmlrp6kmkl80c-bash-4.4-p12/bin/bash"
/nix/store/a2cxjs1lklbpd87vh2a9mnc5kkkgzspm-perf-linux-4.9.77/libexec/perf-core/scripts/python/bin/syscall-counts-by-pid-report: interpreter directive changed from "/bin/bash" to "/nix/store/i0ay05pqkbnvpfijm52mmlrp6kmkl80c-bash-4.4-p12/bin/bash"
/nix/store/a2cxjs1lklbpd87vh2a9mnc5kkkgzspm-perf-linux-4.9.77/libexec/perf-core/scripts/python/bin/syscall-counts-record: interpreter directive changed from "/bin/bash" to "/nix/store/i0ay05pqkbnvpfijm52mmlrp6kmkl80c-bash-4.4-p12/bin/bash"
/nix/store/a2cxjs1lklbpd87vh2a9mnc5kkkgzspm-perf-linux-4.9.77/libexec/perf-core/scripts/python/bin/syscall-counts-report: interpreter directive changed from "/bin/bash" to "/nix/store/i0ay05pqkbnvpfijm52mmlrp6kmkl80c-bash-4.4-p12/bin/bash"
/nix/store/a2cxjs1lklbpd87vh2a9mnc5kkkgzspm-perf-linux-4.9.77/libexec/perf-core/scripts/python/call-graph-from-postgresql.py: interpreter directive changed from "/usr/bin/python2" to "/nix/store/87l8l9w3x8saxqz9sfcfw2i3jiilmxfi-python-2.7.14/bin/python2"
/nix/store/a2cxjs1lklbpd87vh2a9mnc5kkkgzspm-perf-linux-4.9.77/libexec/perf-core/scripts/python/sched-migration.py: interpreter directive changed from "/usr/bin/python" to "/nix/store/87l8l9w3x8saxqz9sfcfw2i3jiilmxfi-python-2.7.14/bin/python"
/nix/store/a2cxjs1lklbpd87vh2a9mnc5kkkgzspm-perf-linux-4.9.77/libexec/perf-core/scripts/python/stat-cpi.py: interpreter directive changed from "/usr/bin/env python" to "/nix/store/87l8l9w3x8saxqz9sfcfw2i3jiilmxfi-python-2.7.14/bin/python"
checking for references to /tmp/nix-build-perf-linux-4.9.77.drv-0 in /nix/store/a2cxjs1lklbpd87vh2a9mnc5kkkgzspm-perf-linux-4.9.77...
moving /nix/store/a2cxjs1lklbpd87vh2a9mnc5kkkgzspm-perf-linux-4.9.77/lib64/* to /nix/store/a2cxjs1lklbpd87vh2a9mnc5kkkgzspm-perf-linux-4.9.77/lib
/nix/store/a2cxjs1lklbpd87vh2a9mnc5kkkgzspm-perf-linux-4.9.77

Copy link

@GrahamcOfBorg GrahamcOfBorg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Success for system: aarch64-linux

/nix/store/b142kba37smljipy21jjs1ln09lgipqs-perf-linux-4.9.77/libexec/perf-core/scripts/perl/bin/check-perf-trace-record: interpreter directive changed from "/bin/bash" to "/nix/store/rc78viijga8i0m4imrnqk8d1csyqr8yx-bash-4.4-p12/bin/bash"
/nix/store/b142kba37smljipy21jjs1ln09lgipqs-perf-linux-4.9.77/libexec/perf-core/scripts/perl/wakeup-latency.pl: interpreter directive changed from "/usr/bin/perl -w" to "/nix/store/vdz41jczh8p1gbb051drb9fwi6ym3gm4-perl-5.24.3/bin/perl -w"
/nix/store/b142kba37smljipy21jjs1ln09lgipqs-perf-linux-4.9.77/libexec/perf-core/scripts/perl/rwtop.pl: interpreter directive changed from "/usr/bin/perl -w" to "/nix/store/vdz41jczh8p1gbb051drb9fwi6ym3gm4-perl-5.24.3/bin/perl -w"
/nix/store/b142kba37smljipy21jjs1ln09lgipqs-perf-linux-4.9.77/libexec/perf-core/scripts/perl/rw-by-pid.pl: interpreter directive changed from "/usr/bin/perl -w" to "/nix/store/vdz41jczh8p1gbb051drb9fwi6ym3gm4-perl-5.24.3/bin/perl -w"
/nix/store/b142kba37smljipy21jjs1ln09lgipqs-perf-linux-4.9.77/libexec/perf-core/scripts/perl/rw-by-file.pl: interpreter directive changed from "/usr/bin/perl -w" to "/nix/store/vdz41jczh8p1gbb051drb9fwi6ym3gm4-perl-5.24.3/bin/perl -w"
/nix/store/b142kba37smljipy21jjs1ln09lgipqs-perf-linux-4.9.77/libexec/perf-core/perf-with-kcore: interpreter directive changed from "/bin/bash" to "/nix/store/rc78viijga8i0m4imrnqk8d1csyqr8yx-bash-4.4-p12/bin/bash"
/nix/store/b142kba37smljipy21jjs1ln09lgipqs-perf-linux-4.9.77/libexec/perf-core/perf-archive: interpreter directive changed from "/bin/bash" to "/nix/store/rc78viijga8i0m4imrnqk8d1csyqr8yx-bash-4.4-p12/bin/bash"
/nix/store/b142kba37smljipy21jjs1ln09lgipqs-perf-linux-4.9.77/libexec/perf-core/tests/attr.py: interpreter directive changed from " /usr/bin/python" to "/nix/store/dynp7j2rilfs54bq22i7ihv2647vrcrk-python-2.7.14/bin/python"
checking for references to /build in /nix/store/b142kba37smljipy21jjs1ln09lgipqs-perf-linux-4.9.77...
/nix/store/b142kba37smljipy21jjs1ln09lgipqs-perf-linux-4.9.77

@dezgeg dezgeg merged commit 94276da into NixOS:master Jan 21, 2018
@lopsided98 lopsided98 deleted the perf-4.9-fix branch January 27, 2018 01:46
alyssais added a commit to alyssais/nixpkgs that referenced this pull request Jul 31, 2025
This reverts commit 94276da.

Original justification[1] was:

> it reduces unnecessary code duplication and should help with cross
> compilation (although this cannot be tested yet because some
> dependencies fail).

However, as time as gone on its become increasingly clear that the
kernels make flags are going to be specific to building a kernel, not
a userspace program, hence them having been renamed to
kernelModuleMakeFlags in the meantime.  This has become even more
apparent now that we're using unwrapped compilers for the kernel,
which doesn't go at all well with building a userspace program like
perf, so we stop inheriting any make flags from the kernel, and
instead just set the two flags necessary for cross compilation to
work.

Link: NixOS#34068 [1]
Fixes: e9b2edb ("linux: un-simplify toolchain selection")
alyssais added a commit that referenced this pull request Aug 4, 2025
This reverts commit 94276da.

Original justification[1] was:

> it reduces unnecessary code duplication and should help with cross
> compilation (although this cannot be tested yet because some
> dependencies fail).

However, as time as gone on its become increasingly clear that the
kernels make flags are going to be specific to building a kernel, not
a userspace program, hence them having been renamed to
kernelModuleMakeFlags in the meantime.  This has become even more
apparent now that we're using unwrapped compilers for the kernel,
which doesn't go at all well with building a userspace program like
perf, so we stop inheriting any make flags from the kernel, and
instead just set the two flags necessary for cross compilation to
work.

Link: #34068 [1]
Fixes: e9b2edb ("linux: un-simplify toolchain selection")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants