Fix AMDuProfPcm so it finds libnuma.so
We change the search procedure so it detects NixOS from /etc/os-release and uses "libnuma.so" when calling dlopen, instead of harcoding a full path to /usr. The full patch of libnuma is stored in the runpath, so dlopen can find it. Reviewed-by: Aleix Boné <abonerib@bsc.es> Tested-by: Vincent Arcila <vincent.arcila@bsc.es>
This commit is contained in:
		
							parent
							
								
									4da7780472
								
							
						
					
					
						commit
						94cbfd38a6
					
				| @ -17,12 +17,15 @@ | |||||||
| , dbus | , dbus | ||||||
| , rocmPackages | , rocmPackages | ||||||
| , libxcrypt-legacy | , libxcrypt-legacy | ||||||
|  | , numactl | ||||||
|  | , radare2 | ||||||
| }: | }: | ||||||
| 
 | 
 | ||||||
| let | let | ||||||
|   version = "5.1.701"; |   version = "5.1.701"; | ||||||
|   tarball = "AMDuProf_Linux_x64_${version}.tar.bz2"; |   tarball = "AMDuProf_Linux_x64_${version}.tar.bz2"; | ||||||
| 
 | 
 | ||||||
|  |   # NOTE: Remember to update the radare2 patch below if AMDuProfPcm changes. | ||||||
|   uprofSrc = runCommandLocal tarball { |   uprofSrc = runCommandLocal tarball { | ||||||
|     nativeBuildInputs = [ curl ]; |     nativeBuildInputs = [ curl ]; | ||||||
|     outputHash = "sha256-j9gxcBcIg6Zhc5FglUXf/VV9bKSo+PAKeootbN7ggYk="; |     outputHash = "sha256-j9gxcBcIg6Zhc5FglUXf/VV9bKSo+PAKeootbN7ggYk="; | ||||||
| @ -45,7 +48,7 @@ in | |||||||
|     src = uprofSrc; |     src = uprofSrc; | ||||||
|     dontStrip = true; |     dontStrip = true; | ||||||
|     phases = [ "installPhase" "fixupPhase" ]; |     phases = [ "installPhase" "fixupPhase" ]; | ||||||
|     nativeBuildInputs = [ autoPatchelfHook ]; |     nativeBuildInputs = [ autoPatchelfHook radare2 ]; | ||||||
|     buildInputs = [ |     buildInputs = [ | ||||||
|       stdenv.cc.cc.lib |       stdenv.cc.cc.lib | ||||||
|       ncurses5 |       ncurses5 | ||||||
| @ -69,6 +72,7 @@ in | |||||||
|       freetype |       freetype | ||||||
|       dbus |       dbus | ||||||
|       rocmPackages.rocprofiler |       rocmPackages.rocprofiler | ||||||
|  |       numactl | ||||||
|     ]; |     ]; | ||||||
|     installPhase = '' |     installPhase = '' | ||||||
|       set -x |       set -x | ||||||
| @ -77,6 +81,9 @@ in | |||||||
|       rm $out/bin/AMDPowerProfilerDriverSource.tar.gz |       rm $out/bin/AMDPowerProfilerDriverSource.tar.gz | ||||||
|       patchelf --replace-needed libroctracer64.so.1 libroctracer64.so $out/bin/ProfileAgents/x64/libAMDGpuAgent.so |       patchelf --replace-needed libroctracer64.so.1 libroctracer64.so $out/bin/ProfileAgents/x64/libAMDGpuAgent.so | ||||||
|       patchelf --add-needed libcrypt.so.1 --add-needed libstdc++.so.6 $out/bin/AMDuProfSys |       patchelf --add-needed libcrypt.so.1 --add-needed libstdc++.so.6 $out/bin/AMDuProfSys | ||||||
|  |       echo "16334a51fcc48668307ad94e20482ca4  $out/bin/AMDuProfPcm" | md5sum -c - | ||||||
|  |       radare2 -w -q -i ${./libnuma.r2} $out/bin/AMDuProfPcm | ||||||
|  |       patchelf --add-needed libnuma.so $out/bin/AMDuProfPcm | ||||||
|       set +x |       set +x | ||||||
|     ''; |     ''; | ||||||
|   } |   } | ||||||
|  | |||||||
							
								
								
									
										10
									
								
								pkgs/amd-uprof/libnuma.r2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								pkgs/amd-uprof/libnuma.r2
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | |||||||
|  | # Patch arguments to call sym std::string::find(char const*, unsigned long, unsigned long) | ||||||
|  | # so it matches NixOS: | ||||||
|  | # | ||||||
|  | # Change OS name to NixOS | ||||||
|  | wz NixOS @ 0x00550a43 | ||||||
|  | # And set the length to 5 characters | ||||||
|  | wa mov ecx, 5 @0x00517930 | ||||||
|  | # | ||||||
|  | # Then change the argument to dlopen() so it only uses libnuma.so | ||||||
|  | wz libnuma.so @ 0x00562940 | ||||||
		Reference in New Issue
	
	Block a user