Macaulay2 / M2

The primary source code repository for Macaulay2, a system for computing in commutative algebra, algebraic geometry and related fields.
https://macaulay2.com
345 stars 230 forks source link

Downloads frobby despite finding it previously #1279

Closed yurivict closed 4 years ago

yurivict commented 4 years ago
...
-- Found Frobby: /usr/local/include (Required is at least version "0.9.0")
...

--- CMakeFiles/build-fflas_ffpack-install.dir/all ---
fatal: repository '/usr/ports/math/macaulay2/work/M2-version-1.15.1.0-460-g6da6a66ec/M2/submodules/fflas_ffpack/.git' does not exist
--- CMakeFiles/build-frobby-install.dir/all ---
fatal: repository '/usr/ports/math/macaulay2/work/M2-version-1.15.1.0-460-g6da6a66ec/M2/submodules/frobby/.git' does not exist
--- CMakeFiles/build-fflas_ffpack-install.dir/all ---
-- Had to git clone more than once:
          3 times.
CMake Error at tmp/build-fflas_ffpack-gitclone.cmake:31 (message):
  Failed to clone repository:
  '/usr/ports/math/macaulay2/work/M2-version-1.15.1.0-460-g6da6a66ec/M2/submodules/fflas_ffpack/.git'

--- CMakeFiles/build-frobby-install.dir/all ---
-- Had to git clone more than once:
          3 times.
CMake Error at tmp/build-frobby-gitclone.cmake:31 (message):
  Failed to clone repository:
  '/usr/ports/math/macaulay2/work/M2-version-1.15.1.0-460-g6da6a66ec/M2/submodules/frobby/.git'

mkdir x doesn't help.

mahrud commented 4 years ago

The way frobby, givaro, and fflas-ffpack are managed is a bit irregular. Basically, they don't support out-of-tree builds, and we need to keep the source directory of submodules clean, so these lines make a 2nd clone from the local repository located at GIT_REPOSITORY: https://github.com/Macaulay2/M2/blob/0a178a4583cf52e8cfb272a7ac0d42e124fd0aaa/M2/cmake/build-libraries.cmake#L539-L543

Admittedly, this is a kludge. I'll keep in mind to find a more elegant solution, but for now the best way to make it work from an archive is to patch cmake/build-libraries.cmake to directly download the archives as follows:

From 1c06a5990f5436fbb554c30226eb8493268649e9 Mon Sep 17 00:00:00 2001
From: Mahrud Sayrafi <mahrud@berkeley.edu>
Date: Mon, 15 Jun 2020 15:37:09 -0500
Subject: [PATCH] freebsd-patch-01

---
 M2/cmake/build-libraries.cmake | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/M2/cmake/build-libraries.cmake b/M2/cmake/build-libraries.cmake
index 093522352..2a3819f7d 100644
--- a/M2/cmake/build-libraries.cmake
+++ b/M2/cmake/build-libraries.cmake
@@ -432,8 +432,8 @@ _ADD_COMPONENT_DEPENDENCY(libraries factory "mp;mpfr;ntl;flint" FACTORY_FOUND)
 # https://github.com/Macaulay2/frobby
 set(frobby_CXXFLAGS "${CPPFLAGS} ${CXXFLAGS} -Wno-deprecated-declarations")
 ExternalProject_Add(build-frobby
-  GIT_REPOSITORY    ${CMAKE_SOURCE_DIR}/submodules/frobby/.git
-  GIT_TAG           HEAD # WIP: 51c3e075 # use the submodule commit to make a new, clean clone
+  URL               ...
+  URL_HASH          SHA256=...
   PREFIX            libraries/frobby
   SOURCE_DIR        libraries/frobby/build
   BUILD_IN_SOURCE   ON
@@ -537,8 +537,8 @@ _ADD_COMPONENT_DEPENDENCY(libraries mpsolve "mp;mpfr" MPSOLVE_FOUND)
 # Currently we make a clone from a local submodule
 set(givaro_LICENSEFILES COPYRIGHT Licence_CeCILL-B_V1-en.txt Licence_CeCILL-B_V1-fr.txt)
 ExternalProject_Add(build-givaro
-  GIT_REPOSITORY    ${CMAKE_SOURCE_DIR}/submodules/givaro/.git
-  GIT_TAG           HEAD # use the submodule commit to make a new, clean clone
+  URL               ...
+  URL_HASH          SHA256=...
   PREFIX            libraries/givaro
   SOURCE_DIR        libraries/givaro/build
   BUILD_IN_SOURCE   ON
@@ -576,8 +576,8 @@ _ADD_COMPONENT_DEPENDENCY(libraries givaro mp GIVARO_FOUND)
 # instead we add an extra autotune target for generating fflas-ffpack-thresholds.h
 # TODO: to make sure AppleClang works with OpenMP see: https://github.com/linbox-team/fflas-ffpack/issues/309
 ExternalProject_Add(build-fflas_ffpack
-  GIT_REPOSITORY    ${CMAKE_SOURCE_DIR}/submodules/fflas_ffpack/.git
-  GIT_TAG           HEAD # use the submodule commit to make a new, clean clone
+  URL               ...
+  URL_HASH          SHA256=...
   PREFIX            libraries/fflas_ffpack
   SOURCE_DIR        libraries/fflas_ffpack/build
   BUILD_IN_SOURCE   ON
-- 
2.26.2

Alternatively, you can delete both GIT and URL methods and just extract the archives in the right place; here it is for givaro:

/usr/ports/math/macaulay2/work/.build/libraries/givaro/build
DanGrayson commented 4 years ago

I fixed the bug with givaro and out-of-tree builds, and I see no reason to keep the source directory clean, because the files made there, such as aclocal.m4 and configure, are independent of build options or even build system.

mahrud commented 4 years ago

It's still leaving the directory dirty, but I couldn't reproduce the problems, so I changed the build system: https://github.com/Macaulay2/M2/pull/1281

@yurivict let me know if you get a chance to try the new changes.

DanGrayson commented 4 years ago

Here's one problem that might result from leaving the source tree of givaro dirty with the files made by the autogen script: we might pull an update to the files, and try to rebuild. If autogen doesn't get run again, then the configure script, for example, might not be up to date. But it is the job of the givaro makefile to check whether the configure script is not up to date, and to rerun autogen if so.

mahrud commented 4 years ago

CMake runs autogen if the build-givaro-configure stamp is outdated.