Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mathematica: fix library paths #27440

Merged
merged 3 commits into from Aug 13, 2017
Merged

Conversation

mnacamura
Copy link
Contributor

@mnacamura mnacamura commented Jul 17, 2017

This PR may fix #27401.

I applied this patch to my local nix expression of Mathematica 11.1.1 Japanese version and the problem has been solved. As I have only this version, I am not sure about whether this patch can fix the problem in the other versions. Sorry.

@bennofs bennofs requested a review from aristidb July 17, 2017 06:30
@@ -93,6 +94,12 @@ stdenv.mkDerivation rec {

echo "=== Running MathInstaller ==="
./MathInstaller -auto -createdir=y -execdir=$out/bin -targetdir=$out/libexec/Mathematica -silent

# Fix library paths
Copy link
Member

Choose a reason for hiding this comment

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

In the preFixup the rpath is already being fixed. Adding zlib to buildInputs should be sufficient. Please test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested but adding zlib to buildInputs is not sufficient.

Copy link
Member

Choose a reason for hiding this comment

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

Can you use ldd on all executables and check which ones don't have a correct reference for zlib.
The rpath is fixed for executables in libexec, it may be that the executables you modify here need zlib instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

% pwd
/nix/store/zldjril1j51qy4zjz9442cgrhh3wvg4v-mathematica-11.1.1-ja/libexec/Mathematica/SystemFiles
% for dir in (find . -type d) 
      cd $dir
      for file in (find . -type f -perm -0100)
          ldd $file | rg "`ZLIB_1.2.9' not found"
      end
      prevd
  end
cd: The directory “./Formats” does not exist
cd: The directory “./Formats/PHPIni” does not exist
./libpangocairo-1.0.so.0: ./libz.so.1: version `ZLIB_1.2.9' not found (required by /nix/store/3ah3k65zwlfz1gjf0fxsv0ygz90b7g8i-libpng-apng-1.6.29/lib/libpng16.so.16)
./libpangoft2-1.0.so: ./libz.so.1: version `ZLIB_1.2.9' not found (required by /nix/store/3ah3k65zwlfz1gjf0fxsv0ygz90b7g8i-libpng-apng-1.6.29/lib/libpng16.so.16)
./libpangocairo-1.0.so: ./libz.so.1: version `ZLIB_1.2.9' not found (required by /nix/store/3ah3k65zwlfz1gjf0fxsv0ygz90b7g8i-libpng-apng-1.6.29/lib/libpng16.so.16)
./libpangoxft-1.0.so.0: ./libz.so.1: version `ZLIB_1.2.9' not found (required by /nix/store/3ah3k65zwlfz1gjf0fxsv0ygz90b7g8i-libpng-apng-1.6.29/lib/libpng16.so.16)
./libpangoxft-1.0.so: ./libz.so.1: version `ZLIB_1.2.9' not found (required by /nix/store/3ah3k65zwlfz1gjf0fxsv0ygz90b7g8i-libpng-apng-1.6.29/lib/libpng16.so.16)
./libpangoft2-1.0.so.0: ./libz.so.1: version `ZLIB_1.2.9' not found (required by /nix/store/3ah3k65zwlfz1gjf0fxsv0ygz90b7g8i-libpng-apng-1.6.29/lib/libpng16.so.16)

The above library files are located in $out/libexec/Mathematica/SystemFiles/Libraries/Linux-x86-64/, which also haslibz.so.1 shipped with Mathematica.

I have confirmed that just deleting this libz.so.1 works fine. Instead of lines 98-102:

    # Delete shipped libz
    case `uname -m` in
      i?86)
        zlib_dirs="Linux" ;;
      x86_64)
        zlib_dirs="Linux-x86-64 Linux" ;;
      armv?l)
        zlib_dirs="Linux-ARM" ;;
    esac
    if [ -n "''${zlib_dirs}" ]; then
      for dir in ''${zlib_dirs}; do
        rm $out/libexec/Mathematica/SystemFiles/Libraries/''${dir}/libz.so.1
      done
    fi

Copy link
Member

Choose a reason for hiding this comment

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

Note that we have zlib 1.2.11 currently and not 1.2.9. I could imagine issues with using our version instead of the vendored one. From your list it seems pango is vendored already as well.

Copy link
Member

Choose a reason for hiding this comment

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

Yet this might just work for now:
https://abi-laboratory.pro/tracker/timeline/zlib/index.html

The ABI change in 1.2.10 for deflate_copyright is probably just that 1.2.10 is one character longer than 1.2.9:

const char deflate_copyright[] =
   " deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler ";

Copy link
Member

@veprbl veprbl Jul 19, 2017

Choose a reason for hiding this comment

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

What I don't understand is how nixpkgs's libpng gets into the picture...

@FRidh FRidh self-assigned this Jul 18, 2017
# Fix library paths
cd $out/libexec/Mathematica/Executables
for path in mathematica MathKernel Mathematica WolframKernel wolfram; do
sed -i -e 's/export LD_LIBRARY_PATH/export LD_LIBRARY_PATH=${builtins.replaceStrings ["/"] ["\\/"] "${zlib}/lib"}:\''${LD_LIBRARY_PATH}/' $path
Copy link
Member

@veprbl veprbl Jul 19, 2017

Choose a reason for hiding this comment

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

Perhaps

sed -i -e 's#export LD_LIBRARY_PATH#export LD_LIBRARY_PATH=${zlib}/lib:\''${LD_LIBRARY_PATH}#' $path

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. That's better. I modified the line.

@FRidh FRidh removed their assignment Jul 19, 2017
@lukateras
Copy link
Member

lukateras commented Aug 10, 2017

What should be changed/added in order for this pull request to be accepted? (Mathematica derivation is also one version behind)

@FRidh FRidh merged commit 006edcc into NixOS:master Aug 13, 2017
@mnacamura mnacamura deleted the mathematica11_fix_ldpath branch August 13, 2017 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NixOS-17.03: mathematica 11.0.1 broken
5 participants