diff options
Diffstat (limited to 'packages/intel-vtune.patch')
-rw-r--r-- | packages/intel-vtune.patch | 514 |
1 files changed, 514 insertions, 0 deletions
diff --git a/packages/intel-vtune.patch b/packages/intel-vtune.patch new file mode 100644 index 0000000..54f2518 --- /dev/null +++ b/packages/intel-vtune.patch @@ -0,0 +1,514 @@ +From 9ee4876f0e0c7ba153ccaf69b42310ee8c25dca0 Mon Sep 17 00:00:00 2001 +From: Albert Safin <xzfcpw@gmail.com> +Date: Fri, 26 Apr 2024 18:47:53 +0000 +Subject: [PATCH 1/4] libsafec: init at 3.3.0 + +--- + pkgs/by-name/li/libsafec/package.nix | 46 ++++++++++++++++++++++++++++ + 1 file changed, 46 insertions(+) + create mode 100644 pkgs/by-name/li/libsafec/package.nix + +diff --git a/pkgs/by-name/li/libsafec/package.nix b/pkgs/by-name/li/libsafec/package.nix +new file mode 100644 +index 00000000000000..7d65d84f695ef6 +--- /dev/null ++++ b/pkgs/by-name/li/libsafec/package.nix +@@ -0,0 +1,46 @@ ++{ ++ stdenv, ++ lib, ++ fetchFromGitHub, ++ fetchpatch, ++ autoreconfHook, ++ perl, ++}: ++ ++stdenv.mkDerivation (finalAttrs: { ++ pname = "safeclib"; ++ version = "3.3.0"; ++ ++ src = fetchFromGitHub { ++ owner = "rurban"; ++ repo = "safeclib"; ++ rev = "refs/tags/v${finalAttrs.version}"; ++ hash = "sha256-vwMyxGgJvvv2Nlo14HKZtq8YnmAVqAHDvBL6CUmbaYQ="; ++ }; ++ ++ patches = [ ++ # Fix linking error. ++ # Upstreamed in v3.4.0, but intel-opeapi-vtune wants libsafec-3.3.so.3. ++ (fetchpatch { ++ name = "0001-add-pic_flag-to-RETPOLINE-cflags-and-ldflags.patch"; ++ url = "https://github.com/rurban/safeclib/commit/23ae79fe84a3fa5d995b8c6b9be70587e37a6cd8.patch"; ++ hash = "sha256-iv9OZJT9WILug1vVmUgIh8RxGAx8accwR1R0LOxYqYQ="; ++ }) ++ ]; ++ ++ nativeBuildInputs = [ autoreconfHook ]; ++ ++ buildInputs = [ perl ]; ++ ++ env = { ++ CFLAGS = "-Wno-error=dangling-pointer"; ++ }; ++ ++ meta = { ++ description = "Libc extension with all C11 Annex K functions"; ++ homepage = "https://github.com/rurban/safeclib"; ++ license = lib.licenses.mit; ++ maintainers = [ lib.maintainers.xzfc ]; ++ platforms = lib.platforms.all; ++ }; ++}) + +From e85bff2164b9e9058dff94c11cd93b73d3efb43b Mon Sep 17 00:00:00 2001 +From: Albert Safin <xzfcpw@gmail.com> +Date: Fri, 26 Apr 2024 20:03:57 +0000 +Subject: [PATCH 2/4] intel-oneapi-vtune: init at 2025.0.1 + +--- + .../by-name/in/intel-oneapi-vtune/package.nix | 142 ++++++++++++++++++ + pkgs/by-name/in/intel-oneapi-vtune/update.sh | 42 ++++++ + 2 files changed, 184 insertions(+) + create mode 100644 pkgs/by-name/in/intel-oneapi-vtune/package.nix + create mode 100755 pkgs/by-name/in/intel-oneapi-vtune/update.sh + +diff --git a/pkgs/by-name/in/intel-oneapi-vtune/package.nix b/pkgs/by-name/in/intel-oneapi-vtune/package.nix +new file mode 100644 +index 00000000000000..2de5be57e8446c +--- /dev/null ++++ b/pkgs/by-name/in/intel-oneapi-vtune/package.nix +@@ -0,0 +1,142 @@ ++{ ++ alsa-lib, ++ atk, ++ autoPatchelfHook, ++ cairo, ++ cups, ++ dbus, ++ elfutils, ++ expat, ++ fetchurl, ++ file-rename, ++ glib, ++ gtk3, ++ kmod, ++ lib, ++ libdrm, ++ libndctl, ++ libsafec, ++ libxcrypt-legacy, ++ libxkbcommon, ++ mesa, ++ ncurses5, ++ nspr, ++ nss, ++ opencl-clang, ++ p7zip, ++ pango, ++ stdenv, ++ systemd, ++ wrapGAppsHook3, ++ xorg, ++}: ++ ++stdenv.mkDerivation ( ++ finalAttrs: ++ let ++ versionMajorMinor = lib.versions.majorMinor finalAttrs.version; ++ in ++ { ++ pname = "intel-oneapi-vtune"; ++ version = "2025.0.1"; ++ ++ src = fetchurl { ++ url = "https://installer.repos.intel.com/oneapi/vtune/lin/intel.oneapi.lin.vtune,v=2025.0.1%2B14/cupPayload.cup"; ++ sha256 = "1pzh0kx7wxwr48rbv7wfkpkixqxsaass3xkpwhvvkdm09v5fhm7h"; ++ }; ++ ++ nativeBuildInputs = [ ++ autoPatchelfHook ++ file-rename ++ p7zip ++ wrapGAppsHook3 ++ ]; ++ ++ buildInputs = [ ++ alsa-lib ++ atk ++ cairo ++ cups ++ dbus ++ elfutils ++ expat ++ glib ++ gtk3 ++ kmod ++ libdrm ++ libndctl ++ libsafec ++ libxcrypt-legacy ++ libxkbcommon ++ mesa ++ ncurses5 ++ nspr ++ nss ++ opencl-clang ++ pango ++ stdenv.cc.cc.lib ++ xorg.libX11 ++ xorg.libXcomposite ++ xorg.libXdamage ++ xorg.libXext ++ xorg.libXfixes ++ xorg.libXrandr ++ xorg.libxcb ++ ]; ++ ++ unpackPhase = '' ++ runHook preUnpack ++ ++ 7za x $src _installdir/vtune/${versionMajorMinor} ++ ++ # Fix percent-encoded filenames, e.g. "libstdc%2B%2B.so.6" -> "libstdc++.so.6" ++ find -depth -name '*%*' -execdir rename 's/%2B/+/g; s/%5B/[/g; s/%5D/]/g' {} \; ++ ++ runHook postUnpack ++ ''; ++ ++ installPhase = '' ++ runHook preInstall ++ ++ mkdir -p $out/opt/intel/oneapi ++ mv _installdir/vtune $out/opt/intel/oneapi ++ ln -s $out/opt/intel/oneapi/vtune/{${versionMajorMinor},latest} ++ ++ mkdir -p $out/bin ++ for bin in vtune vtune-backend vtune-gui; do ++ ln -s $out/opt/intel/oneapi/vtune/${versionMajorMinor}/bin64/$bin $out/bin/ ++ done ++ ++ mkdir -p $out/share/applications ++ cp $out/opt/intel/oneapi/vtune/${versionMajorMinor}/bin64/vtune-gui.desktop $out/share/applications/ ++ sed -i $out/share/applications/vtune-gui.desktop -e " ++ s|^Exec=.*|Exec=vtune-gui|g; ++ s|^Icon=./|Icon=$out/opt/intel/oneapi/vtune/${versionMajorMinor}/bin64/|g; ++ " ++ ++ runHook postInstall ++ ''; ++ ++ autoPatchelfIgnoreMissingDeps = [ ++ "libffi.so.6" # Used in vendored python ++ "libgdbm.so.4" # Used in vendored python ++ "libgdbm_compat.so.4" # Used in vendored python ++ "libsycl.so.8" # Used in bin64/self_check_apps/matrix.dpcpp/matrix.dpcpp ++ ]; ++ ++ runtimeDependencies = [ ++ systemd # for zygote (vtune-gui) ++ ]; ++ ++ passthru.updateScript = ./update.sh; ++ ++ meta = { ++ changelog = "https://www.intel.com/content/www/us/en/developer/articles/release-notes/vtune-profiler-release-notes.html"; ++ description = "Performance analysis tool for x86-based machines"; ++ homepage = "https://www.intel.com/content/www/us/en/developer/tools/oneapi/vtune-profiler.html"; ++ license = lib.licenses.unfree; ++ maintainers = [ lib.maintainers.xzfc ]; ++ platforms = [ "x86_64-linux" ]; ++ }; ++ } ++) +diff --git a/pkgs/by-name/in/intel-oneapi-vtune/update.sh b/pkgs/by-name/in/intel-oneapi-vtune/update.sh +new file mode 100755 +index 00000000000000..5536c846f8e844 +--- /dev/null ++++ b/pkgs/by-name/in/intel-oneapi-vtune/update.sh +@@ -0,0 +1,42 @@ ++#!/usr/bin/env nix-shell ++#!nix-shell -i bash -p curl jq common-updater-scripts ++ ++set -e ++ ++# Check on https://www.intel.com/content/www/us/en/developer/tools/oneapi/vtune-profiler-download.html ++DOWNLOAD_ID=bef05a56-52f3-40ad-a91a-040a98316680 ++ ++INSTALLER_URL=$( ++ curl --silent "https://www.intel.com/libs/apps/intel/idz/productsinfo?downloadId=$DOWNLOAD_ID" | ++ jq -r ' ++ .downloads.downloads.productVersionsBuilds[0].files[] ++ | select (.operatingSystem == "Linux" and .fileType == "Custom Package") ++ .url ++ ' | ++ uniq ++) ++echo "INSTALLER_URL=$INSTALLER_URL" ++[ "$INSTALLER_URL" ] || exit 1 ++ ++{ ++ read -r CUP_URL ++ read -r VERSION ++} < <( ++ curl --silent "$INSTALLER_URL" | ++ sed '0,/^__CONTENT__$/d' | ++ tar -zx -O --wildcards './packages/intel.oneapi.lin.vtune,v=*/manifest.json' | ++ jq -r ' ++ [(.payloads[] | select (.fileName == "cupPayload.cup") | .url), ++ (.version | split("+")[0]) ++ ][] ++ ' ++) ++echo "CUP_URL=$CUP_URL" ++echo "VERSION=$VERSION" ++[ "$CUP_URL" ] || exit 1 ++[ "$VERSION" ] || exit 1 ++ ++CUP_HASH=$(nix-prefetch-url "$CUP_URL") ++echo "CUP_HASH=$CUP_HASH" ++ ++update-source-version intel-oneapi-vtune "$VERSION" "$CUP_HASH" "$CUP_URL" + +From 26dc08626bcef7802e58d4e1d50b99ab71f1a60d Mon Sep 17 00:00:00 2001 +From: Albert Safin <xzfcpw@gmail.com> +Date: Fri, 26 Apr 2024 20:05:57 +0000 +Subject: [PATCH 3/4] intel-vtune-sepdk: init + +--- + .../linux/intel-vtune-sepdk/default.nix | 106 ++++++++++++++++++ + pkgs/top-level/linux-kernels.nix | 2 + + 2 files changed, 108 insertions(+) + create mode 100644 pkgs/os-specific/linux/intel-vtune-sepdk/default.nix + +diff --git a/pkgs/os-specific/linux/intel-vtune-sepdk/default.nix b/pkgs/os-specific/linux/intel-vtune-sepdk/default.nix +new file mode 100644 +index 00000000000000..bd69321476c538 +--- /dev/null ++++ b/pkgs/os-specific/linux/intel-vtune-sepdk/default.nix +@@ -0,0 +1,106 @@ ++{ ++ bash, ++ coreutils, ++ gnugrep, ++ gnused, ++ intel-oneapi-vtune, ++ kernel, ++ kmod, ++ lib, ++ makeWrapper, ++ p7zip, ++ procps, ++ python3, ++ shadow, ++ stdenv, ++ which, ++}: ++ ++let ++ binPath = lib.makeBinPath [ ++ bash ++ coreutils ++ gnugrep ++ gnused ++ kmod ++ procps ++ python3 ++ shadow ++ which ++ ]; ++ libexecDir = "\${out}/libexec/intel-vtune-sepdk"; ++ modDestDir = "$out/lib/modules/${kernel.modDirVersion}/kernel/drivers/platform/x86"; ++ versionMajorMinor = lib.versions.majorMinor intel-oneapi-vtune.version; ++in ++stdenv.mkDerivation { ++ pname = "intel-vtune-sepdk"; ++ version = "${intel-oneapi-vtune.version}-${kernel.version}"; ++ ++ inherit (intel-oneapi-vtune) src; ++ ++ hardeningDisable = [ "pic" ]; ++ ++ nativeBuildInputs = [ ++ makeWrapper ++ p7zip ++ ] ++ kernel.moduleBuildDependencies; ++ ++ makeFlags = [ ++ "KERNEL_SRC_DIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" ++ "KERNEL_VERSION=${kernel.modDirVersion}" # Output of `uname -r` ++ "MACH=x86_64" # Output of `uname -m` ++ "SMP=1" ++ "VERBOSE=1" ++ "INSTALL=${libexecDir}" ++ ]; ++ ++ unpackPhase = '' ++ runHook preUnpack ++ 7za x $src _installdir/vtune/${versionMajorMinor}/sepdk ++ cd _installdir/vtune/${versionMajorMinor}/sepdk/src ++ runHook postUnpack ++ ''; ++ ++ prePatch = '' ++ # Allow using --load-in-tree-driver option ++ substituteInPlace insmod-sep pax/insmod-pax socperf/src/insmod-socperf \ ++ --replace-fail IS_INTREE_DRIVER_OS=0 IS_INTREE_DRIVER_OS=1 ++ ''; ++ ++ preBuild = '' ++ makeFlags="$makeFlags KBUILD_EXTRA_SYMBOLS=$PWD/socperf/src/Module.symvers" ++ ''; ++ ++ preInstall = "mkdir -p ${libexecDir}"; ++ ++ postInstall = '' ++ # Install wrappers to bin ++ for i in insmod-sep pax/insmod-pax socperf/src/insmod-socperf \ ++ rmmod-sep pax/rmmod-pax socperf/src/rmmod-socperf; do ++ sed -i ' ++ s/^PATH=/# &/; ++ # Do not check for su to make it usable with clean PATH (e.g. as systemd service) ++ s/\(\bCOMMANDS_TO_CHECK="[^"]*\)''${SU}\([^"]*"\)/\1\2/; ++ ' ${libexecDir}/$i ++ makeWrapper ${libexecDir}/$i $out/bin/''${i##*/} --prefix PATH : "${binPath}" ++ done ++ ++ # Install kernel modules ++ mkdir -p ${modDestDir}/{socperf,sepdk/sep,sepdk/pax} ++ ln -s ${libexecDir}/sep5-*.ko ${modDestDir}/sepdk/sep/sep5.ko ++ ln -s ${libexecDir}/pax/pax-*.ko ${modDestDir}/sepdk/pax/pax.ko ++ ln -s ${libexecDir}/socperf/src/socperf3-*.ko ${modDestDir}/socperf/socperf3.ko ++ ''; ++ ++ meta = { ++ description = "Kernel module for Intel VTune Profiler"; ++ homepage = "https://www.intel.com/content/www/us/en/docs/vtune-profiler/user-guide/2024-0/sep-driver.html"; ++ license = [ ++ lib.licenses.bsd3 ++ lib.licenses.gpl2Only ++ lib.licenses.unfree ++ ]; ++ maintainers = [ lib.maintainers.xzfc ]; ++ platforms = [ "x86_64-linux" ]; ++ }; ++} +diff --git a/pkgs/top-level/linux-kernels.nix b/pkgs/top-level/linux-kernels.nix +index 3cabaec2c7b14f..9b07bbcd7189bc 100644 +--- a/pkgs/top-level/linux-kernels.nix ++++ b/pkgs/top-level/linux-kernels.nix +@@ -392,6 +392,8 @@ in { + + intel-speed-select = if lib.versionAtLeast kernel.version "5.3" then callPackage ../os-specific/linux/intel-speed-select { } else null; + ++ intel-vtune-sepdk = callPackage ../os-specific/linux/intel-vtune-sepdk { }; ++ + ipu6-drivers = callPackage ../os-specific/linux/ipu6-drivers {}; + + ivsc-driver = callPackage ../os-specific/linux/ivsc-driver {}; + +From 4a32ac7311f23d4a17f6f294d19e1df5afc4f90d Mon Sep 17 00:00:00 2001 +From: Albert Safin <xzfcpw@gmail.com> +Date: Fri, 26 Apr 2024 20:07:19 +0000 +Subject: [PATCH 4/4] nixos/vtune: init module + +--- + .../manual/release-notes/rl-2505.section.md | 2 + + nixos/modules/module-list.nix | 1 + + nixos/modules/programs/vtune.nix | 74 +++++++++++++++++++ + 3 files changed, 77 insertions(+) + create mode 100644 nixos/modules/programs/vtune.nix + +diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix +index 2367ba3ba7d7ec..eb0224fa18c195 100644 +--- a/nixos/modules/module-list.nix ++++ b/nixos/modules/module-list.nix +@@ -313,6 +313,7 @@ + ./programs/vim.nix + ./programs/virt-manager.nix + ./programs/wavemon.nix ++ ./programs/vtune.nix + ./programs/wayland/cardboard.nix + ./programs/wayland/hyprlock.nix + ./programs/wayland/hyprland.nix +diff --git a/nixos/modules/programs/vtune.nix b/nixos/modules/programs/vtune.nix +new file mode 100644 +index 00000000000000..9ace5cbc338fbc +--- /dev/null ++++ b/nixos/modules/programs/vtune.nix +@@ -0,0 +1,74 @@ ++{ ++ config, ++ lib, ++ pkgs, ++ ... ++}: ++ ++let ++ inherit (lib) ++ mkEnableOption ++ mkIf ++ mkMerge ++ mkOption ++ mkPackageOption ++ types ++ ; ++ ++ cfg = config.programs.vtune; ++in ++{ ++ options.programs.vtune = { ++ enable = mkEnableOption "VTune Profiler"; ++ ++ package = mkPackageOption pkgs "intel-oneapi-vtune" { ++ nullable = true; ++ extraDescription = '' ++ Set to `null` to install only the kernel module. ++ ''; ++ }; ++ ++ modulePackage = mkOption { ++ type = types.nullOr types.package; ++ default = config.boot.kernelPackages.intel-vtune-sepdk.override { ++ intel-oneapi-vtune = config.programs.package or pkgs.intel-oneapi-vtune; ++ }; ++ defaultText = '' ++ config.boot.kernelPackages.intel-vtune-sepdk.override { ++ intel-oneapi-vtune = config.programs.vtune.package or pkgs.intel-oneapi-vtune; ++ } ++ ''; ++ example = "config.boot.kernelPackages.intel-vtune-sepdk"; ++ description = '' ++ The package to use for the VTune Profiler kernel module. ++ Set to `null` to disable the kernel module. ++ An user should be in the `vtune` group to use the module. ++ ''; ++ }; ++ }; ++ ++ config = mkIf cfg.enable (mkMerge [ ++ (mkIf (cfg.package != null) { environment.systemPackages = [ cfg.package ]; }) ++ ++ (mkIf (cfg.modulePackage != null) { ++ boot.extraModulePackages = [ cfg.modulePackage ]; ++ ++ environment.systemPackages = [ cfg.modulePackage ]; ++ ++ users.groups.vtune = { }; ++ ++ systemd.services.vtune-sep5 = { ++ description = "Load VTune SEP5 driver"; ++ wantedBy = [ "multi-user.target" ]; ++ serviceConfig = { ++ Type = "oneshot"; ++ ExecStart = "${cfg.modulePackage}/bin/insmod-sep --load-in-tree-driver"; ++ ExecStop = "${cfg.modulePackage}/bin/rmmod-sep"; ++ RemainAfterExit = true; ++ }; ++ }; ++ }) ++ ]); ++ ++ meta.maintainers = [ lib.maintainers.xzfc ]; ++} + |