nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 rocmUpdateScript,
6 cmake,
7 clr,
8 rocm-device-libs,
9 libxml2,
10 doxygen,
11 graphviz,
12 gcc-unwrapped,
13 libbacktrace,
14 rocm-runtime,
15 python3Packages,
16 buildDocs ? false, # Nothing seems to be generated, so not making the output
17 buildTests ? false,
18}:
19
20stdenv.mkDerivation (finalAttrs: {
21 pname = "roctracer";
22 version = "6.3.3";
23
24 outputs = [
25 "out"
26 ]
27 ++ lib.optionals buildDocs [
28 "doc"
29 ]
30 ++ lib.optionals buildTests [
31 "test"
32 ];
33
34 src = fetchFromGitHub {
35 owner = "ROCm";
36 repo = "roctracer";
37 rev = "rocm-${finalAttrs.version}";
38 hash = "sha256-GhnF7rqNLQLLB7nzIp0xNqyqBOwj9ZJ+hzzj1EAaXWU=";
39 };
40
41 nativeBuildInputs = [
42 cmake
43 clr
44 ]
45 ++ lib.optionals buildDocs [
46 doxygen
47 graphviz
48 ];
49
50 buildInputs = [
51 libxml2
52 libbacktrace
53 python3Packages.python
54 python3Packages.cppheaderparser
55 ];
56
57 cmakeFlags = [
58 "-DCMAKE_MODULE_PATH=${clr}/hip/cmake"
59 # Manually define CMAKE_INSTALL_<DIR>
60 # See: https://github.com/NixOS/nixpkgs/pull/197838
61 "-DCMAKE_INSTALL_BINDIR=bin"
62 "-DCMAKE_INSTALL_LIBDIR=lib"
63 "-DCMAKE_INSTALL_INCLUDEDIR=include"
64 ];
65
66 env.NIX_CFLAGS_COMPILE = toString [
67 # Needed with GCC 12
68 "-Wno-error=array-bounds"
69 ];
70
71 postPatch = ''
72 export HIP_DEVICE_LIB_PATH=${rocm-device-libs}/amdgcn/bitcode
73 ''
74 + lib.optionalString (!buildTests) ''
75 substituteInPlace CMakeLists.txt \
76 --replace "add_subdirectory(test)" ""
77 '';
78
79 # Tests always fail, probably need GPU
80 # doCheck = buildTests;
81
82 postInstall =
83 lib.optionalString buildDocs ''
84 mkdir -p $doc
85 ''
86 + lib.optionalString buildTests ''
87 mkdir -p $test/bin
88 # Not sure why this is an install target
89 find $out/test -executable -type f -exec mv {} $test/bin \;
90 rm $test/bin/{*.sh,*.py}
91 patchelf --set-rpath $out/lib:${
92 lib.makeLibraryPath (
93 finalAttrs.buildInputs
94 ++ [
95 clr
96 gcc-unwrapped.lib
97 rocm-runtime
98 ]
99 )
100 } $test/bin/*
101 rm -rf $out/test
102 '';
103
104 passthru.updateScript = rocmUpdateScript {
105 name = finalAttrs.pname;
106 inherit (finalAttrs.src) owner;
107 inherit (finalAttrs.src) repo;
108 };
109
110 meta = with lib; {
111 description = "Tracer callback/activity library";
112 homepage = "https://github.com/ROCm/roctracer";
113 license = with licenses; [ mit ]; # mitx11
114 teams = [ teams.rocm ];
115 platforms = platforms.linux;
116 };
117})