NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.08k stars 13.39k forks source link

The Mathemagix compiler and interpreter throw errors #324970

Open adam-neeley opened 1 month ago

adam-neeley commented 1 month ago

Describe the bug

The Mathemagix compiler (mmc) and interpreter (mmi) throw errors when run.

Steps To Reproduce

First, install the Mathemagix nix package mathemagix. One way:

nix-shell -p mathemagix --pure

Run Compiler

  1. Create file hello.mmx with the contents:

    include "basix/fundamental.mmx";
    mmout << "Hello world!" << lf;
  2. Run mmc hello.mmx

Compiler Error
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
collect2: error: ld returned 1 exit status
mmc: error, link failed for /home/adam/code/mathemagix/hello
mmc: internal compiler error in /home/adam/code/mathemagix/hello.mmx
mmc: abort, 1 error in 1 file

Run Interpreter

  1. Run mmi
Interpreter Error
--------------------------------------------------------------
|:*)              Welcome to Mathemagix 1.0.3             (*:|
|------------------------------------------------------------|
|  This software falls under the GNU General Public License  |
|          It comes without any warranty whatsoever          |
|                http://www.mathemagix.org                   |
|                      (c) 2010-2012                         |
--------------------------------------------------------------
mmi: compiling glue.../nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
collect2: error: ld returned 1 exit status
mmc: error, gluing failed for /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/essential-glue.so
mmc: internal compiler error in /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/essential.mmx
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
collect2: error: ld returned 1 exit status
mmc: error, gluing failed for /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/int-glue.so
mmc: internal compiler error in /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/int.mmx
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
collect2: error: ld returned 1 exit status
mmc: error, gluing failed for /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/generic-glue.so
mmc: internal compiler error in /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/generic.mmx
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
collect2: error: ld returned 1 exit status
mmc: error, gluing failed for /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/literal-glue.so
mmc: internal compiler error in /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/literal.mmx
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
collect2: error: ld returned 1 exit status
mmc: error, gluing failed for /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/compound-glue.so
mmc: internal compiler error in /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/compound.mmx
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
collect2: error: ld returned 1 exit status
mmc: error, gluing failed for /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/expression-glue.so
mmc: internal compiler error in /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/expression.mmx
collect2: error: ld returned 1 exit status
mmc: error, gluing failed for /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/syntactic-glue.so
mmc: internal compiler error in /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/syntactic.mmx
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lreadline: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lncurses: No such file or directory
/nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: cannot find -lltdl: No such file or directory
collect2: error: ld returned 1 exit status
mmc: error, gluing failed for /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/port-glue.so
mmc: internal compiler error in /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/port.mmx
mmc: abort, 8 errors in at least 8 files
mmi: need prior compilation of a dynamic library for ["/home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/essential.mmp", "/home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/double.mmp", "/home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/generic.mmp", "/home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/int.mmp", "/home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/vector.mmp", "/home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/string.mmp", "/home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/table.mmp", "/home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/literal.mmp", "/home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/compound.mmp", "/home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/expression.mmp", "/home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/syntactic.mmp", "/home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/port.mmp"]
mmi: failed command: mmc --old --glue /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/essential.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/double.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/generic.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/int.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/vector.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/string.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/table.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/literal.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/compound.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/expression.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/syntactic.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/port.mmx
mmi: unexpected top level error
Inside files_to_glue: cannot compile dynamic library for /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/essential.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/double.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/generic.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/int.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/vector.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/string.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/table.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/literal.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/compound.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/expression.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/syntactic.mmx /home/adam/.mathemagix/devel-mmc/var/clone/nix/store/fa35pl3xzl90k4q9zg5nyf6g6ds4fmmp-mathemagix-11126/share/basix/mmx/port.mmx

Expected behavior

mmc and mmi should behave as intended, like mmx-light.

❯ mmx-light
--------------------------------------------------------------
|:*)          Welcome to Mathemagix-light 0.4             (*:|
|------------------------------------------------------------|
|  This software falls under the GNU General Public License  |
|          It comes without any warranty whatsoever          |
|                    www.mathemagix.org                      |
|                     (c) 2001--2010                         |
--------------------------------------------------------------
1] include "hello.mmx"
Hello world!
2] 

Additional context

Introduction

Mathemagix is an interesting bit of free software created by mathematician, computer scientist, and researcher Joris van der Hoeven.

In his recent 2023 paper Overview of the Mathemagix type system, van der Hoeven states:

The goal of the Mathemagix project is to develop a new and free software for computer algebra and computer analysis, based on a strongly typed and compiled language.

[...]

The central idea behind the design of the Mathemagix language is that the declaration of a function is analogous to the statement of a mathematical theorem, whereas the implementation of the function is analogous to giving a proof. Of course, this idea is also central in the area of automated proof assistants, such as Coq or Isabelle/Hol. However, Mathemagix only insists on very detailed declarations, whereas the actual implementations do need not to be formally proven.

Whether you are able to produce a complete fix or offer some simple advice, any help is greatly appreciated.

Links

Nix package:

Manual:

Website:

Source code:

van der Hoeven:

Notify maintainers

@drupol

Metadata

❯ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.33-xanmod1, NixOS, 24.11 (Vicuna), 24.11.20240701.00d80d1`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.4`
 - nixpkgs: `/nix/store/bi5zxc0v5g6ylygdwyqzh280sccg3ykb-source`

Add a :+1: reaction to issues you find important.

nixos-discourse commented 1 month ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/compiler-and-interpreter-in-mathemagix-nixpkg-throw-errors-when-run/48642/1

adam-neeley commented 1 month ago

From what I've gathered (thanks to @emilazy), implementing makeWrapper / wrapProgram is likely the best approach for this issue. I am currently working on a solution, but mention this in case others can help.

While Mathemagix recompiles (or "glues") its modules when run, this occurs in the user's home directory. There is no issue of mutable state; the only problem is access to a C++ compiler and libraries.