I’m attempting to package Vivado 2022.2. I believe I’ve gotten pretty far in the process, but I’m running an issue. When I run the vivado binary (./result/opt/vivado/Vivado/2022.2/bin/vivado), I see the error unexpected PLT reloc type 0x00. From a quick search, this appears to be an issue with the linker tables.
The current build expression for this is:
{ stdenv
, pkgs
, lib
, requireFile
, bash
, zlib
, glibc
# TODO do I need this?
, xorg
}:
stdenv.mkDerivation rec {
pname = "vivado";
version = "2022.2";
subversion = "1014_8888";
src = requireFile {
name = "Xilinx_Unified_${version}_${subversion}.tar.gz";
url = "https://www.xilinx.com/member/forms/download/xef.html?filename=Xilinx_Unified_${version}_${subversion}.tar.gz";
sha256 = "1s28fwhnjqkng9imqbd89cm8xaf33lq4f511i3irf127lhnav1v0";
};
buildInputs = [
bash
zlib
glibc
] ++ (with xorg; [
libXext
libX11
libXrender
libXtst
libXi
]);
doConfigure = false;
doBuild = false;
patchPhase = ''
patchShebangs .
# /bin/rm... seriously...?
sed -i 's/\/bin\/rm/rm/g' xsetup
# change references to $HOME and $USER
sed -i 's/\$HOME/"_home"/g' xsetup
sed -i 's/\$USER/"_home"/g' xsetup
# fix interpreter paths
for exe in $(find bin tps/lnx64/jre11.0.11_9/bin -executable -type f); do
isELF "$exe" || continue
if [[ "$(basename $exe)" == "rlwrap" ]]; then continue; fi
echo "patching $exe..."
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$exe"
done
# add missing libraries to java RPATH directory
ln -s ${zlib}/lib/libz.so.1 lib/lnx64.o/
# add missing libraries to tps/lnx64/jre11.0.11_9/lib/libawt_xawt.so
basePath="tps/lnx64/jre11.0.11_9/lib"
ln -s $basePath/server/libjvm.so $basePath/
'';
installPhase = ''
mkdir -p $out/opt/vivado
./xsetup --agree 3rdPartyEULA,XilinxEULA \
--batch Install \
--product "Vitis" \
--edition "Vitis Unified Software Platform" \
--location $out/opt/vivado
'';
preFixup = ''
# For all tool main binaries, set interpreter and add requisite runpaths.
dynamicLinker="$(cat $NIX_CC/nix-support/dynamic-linker)"
tools=("Model_Composer" "Vitis" "Vitis_HLS" "Vivado")
for tool in ''${tools[*]}; do
for exe in $(find $out/opt/vivado/$tool/${version}/bin/unwrapped/lnx64.o -maxdepth 1 -type f); do
isELF $exe || continue
if [[ "$(basename $exe)" == "rlwrap" ]]; then continue; fi
# Apparently, patchelf cannot accept multiple options at once.
patchelf --set-interpreter $dynamicLinker $exe
patchelf --add-rpath $out/opt/vivado/$tool/${version}/lib/lnx64.o $exe
patchelf \
--add-rpath $out/opt/vivado/$tool/${version}/lib/lnx64.o/Default $exe
done
done
# Add runpaths to libraries.
for tool in ''${tools[*]}; do
for lib in $(find $out/opt/vivado/$tool/${version}/lib/lnx64.o -maxdepth 1 -type f); do
isELF $lib || continue
if [[ "$(basename $lib)" == "rlwrap" ]]; then continue; fi
patchelf --add-rpath $out/opt/vivado/$tool/${version}/lib/lnx64.o $lib
patchelf \
--add-rpath $out/opt/vivado/$tool/${version}/lib/lnx64.o/Default $lib
done
done
'';
}
Any ideas about what might be going wrong here? Or, at least, any hints about the right direction to proceed?
Thanks for the note. Yeah, I tried this - they’re all there. FYI bin/vivado is a shell script that invokes bin/unwrapped/lnx64.o/vivado, hence why I’ve used ldd on the latter.
You could try LD_DEBUG=reloc or LD_DEBUG=all to debug relocation processing & combine with readelf to investigate further.
But Vivado is extremely huge/complicated - this is going to be a long ride. I do hope you’re aware of that and have already seen Fhs env for installing xilinx - #2 by Mic92 for hints on getting it to ‘just work’ in a FHSEnv.
I was not aware of FHSEnv - thanks for pointing that out. I’d eventually like a proper build expression for the Xilinx tools, but that seems like a good intermediate solution.