Hi all
I’m trying to package Macaulay2 on NixOS 23.05.
The build process creates an executable, but any time it is run, it immediately exits with the message
*** stack smashing detected ***: terminated
How can I build Macaulay2 on NixOS and avoid this?
(I have built this repository on other distributions without this problem.)
Development environment:
# shell.nix
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
shellHook =
''
boostLoc=${pkgs.boost}/lib
'';
nativeBuildInputs = with pkgs ; [
autoconf
automake
gnumake
libtool
bison
pkg-config
gfortran
git
curl
];
buildInputs = with pkgs ; [
boehmgc
tbb
eigen
ncurses
boost
libzip
xz
libxml2
libffi
fflas-ffpack
openblas
flint
givaro
# gtest # (submodule) You should let M2 compile this: https://github.com/google/googletest/blob/36066cfecf79267bdf46ff82ca6c3b052f8f633c/googletest/docs/faq.md#why-is-it-not-recommended-to-install-a-pre-compiled-copy-of-google-test-for-example-into-usrlocal
mpir
gdbm
readline
mpfi
ntl
glpk
cddlib # need to pass CPPFLAGS="$CPPFLAGS $(pkg-config --cflags cddlib)/cddlib" to configure
gfan
singular # Provides factory
_4ti2
lrs
csdp
nauty
libatomic_ops
];
}
Build process:
git clone 'https://github.com/Macaulay2/M2.git' src
cd src/M2
git checkout release-1.22
make # run autoconf, autoheader
sed -i 's/\/bin\/echo/echo/g' configure # replace "/bin/echo" with "echo" in the config file
./configure\
--with-system-gc \ # use the copy of boehmgc on the system
--prefix=<desired-install-path> \
--with-boost-libdir=$boostLoc \ # boost library location
--enable-download \ # allow M2 to download & build more dependencies
CPPFLAGS="$(pkg-config --cflags cddlib)/cddlib" # Ensure the system copy of cddlib is found
sed -i 's/\/bin\/echo/echo/g' GNUmakefile
sed -i 's/\/bin\/echo/echo/g' Macaulay2/m2/Makefile.in
make # Builds the binary, then invokes it to install plugins, triggering the "stack smashing detected" error
# make install, once the errors of make are fixed
A second minor question: how to avoid converting /bin/echo
to echo
everywhere?
I’ve tried using buildFHSUserEnv
, but using it prevents tbb
’s headers from being found, even by pkg-config
, so the situation is not in net improved.
Thank you for your help!