Project

General

Profile

Bug #1749

Configuration hiccups on Mac M1

Added by John Abbott 10 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
High
Assignee:
Category:
Portability
Target version:
Start date:
03 Jul 2023
Due date:
% Done:

100%

Estimated time:
3.33 h
Spent time:

Description

Max Horn reported by email several configuration/compilation hiccups on Mac M1 platform.
Investigate & fix.


Related issues

Related to CoCoALib - Feature #1748: July 2023New2023-06-30

History

#1 Updated by John Abbott 10 months ago

I was trying to compiled CoCoA from source. I downloaded CoCoALib-0.99818 sources from your website.

Unfortunately I failed to compile it. For reference, this is on an M1 mac running macOS 12.6.7. GMP is installed via homebrew. I had to point the configure script at it, but then it died with this error:

$ ./configure --with-libgmp=/opt/homebrew/lib/libgmp.dylib
---------------------------------------------------------------------
Starting configuration process for CoCoALib, CoCoA-5 (without Qt-GUI)
---------------------------------------------------------------------

Using GMP version 6.2.1:
  header   is  /opt/homebrew/include/gmp.h
  library  is  /opt/homebrew/lib/libgmp.dylib

./configure: ERROR:  Supplied value of CXXFLAGS, namely "  -std=c++14  -Wall  -pedantic  -fPIC  -O2" 
./configure: ERROR:  is not compatible with GMP library
ERROR: failed to compile/link test-gmp-cxxflags --> see LogFile.   [[gmp-check-cxxflags.sh]]

It claims that the C++ compiler flags are not compatible with GMP, but that seems odd, the flags are pretty normal? I would debug further, but unfortunately I could not find the "LogFile" it mentions.

Well, I dug a bit deeper; seems you put the logfile into a temp directory, but without telling users were it is, that is not so helpful... I added some printing to "gmp-check-cxxflags.sh" to find the LogFile content after all:

g++    -std=c++14  -Wall  -pedantic  -fPIC  -O2  test-gmp-cxxflags.c  -o test-gmp-cxxflags  -I"/Users/mhorn/Downloads/CoCoALib-0.99818/configuration/ExternalLibs/include"  -L"/Users/mhorn/Downloads/CoCoALib-0.99818/configuration/ExternalLibs/lib"  -lgmp
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
ld: library not found for -lgmp
clang: error: linker command failed with exit code 1 (use -v to see invocation)

So the problems seems to be this: you specify -lgmp but then the -L flag points out a dir you created, with a hierarchy of symlinks:

$ tree configuration/ExternalLibs
configuration/ExternalLibs
├── include
│   └── gmp.h -> /opt/homebrew/include/gmp.h
└── lib
    └── libgmp-symlink.dylib -> /opt/homebrew/lib/libgmp.dylib

So the library there has the name "libgmp-symlink" instead of "libgmp", so instead of -lgmp one would need -lgmp-symlink...

After hacking around this, I got a new error:

ERROR: unexpected extn in /opt/homebrew/lib/libgmp.dylib

So it seems your build system just is not able to deal with shared libraries on macOS? OK, let's try a

Eventually this got me past the configure script:

./configure --with-libgmp=/opt/homebrew/lib/libgmp.a  --with-boost-hdr-dir=/opt/homebrew/include

Doing make shows a tons of warnings

ld: warning: -no_pie is deprecated when targeting new OS versions
ld: warning: -no_pie ignored for arm64

Unfortunately the test suite then fails:

~/Downloads/CoCoALib-0.99818 (git:main+)$ make
=======================================================
Compiling CoCoALib-0.99818
  CXX = g++
  CXXFLAGS = -std=c++14  -Wall  -pedantic  -fPIC  -O2
  CXXFLAGS_DEFINES =
=======================================================
Compiling CoCoALib source subdirectory AlgebraicCore/
-----------------------------------------------------
[CoCoALib already compiled]

Compiling CoCoALib source subdirectory AlgebraicCore/
-----------------------------------------------------
[CoCoALib already compiled]

Compiling and running all CoCoALib tests
----------------------------------------

Running the CoCoALib tests (120-CoCoALib tests altogether)
----------------------------------------------------------
[1/120-CoCoALib] test-empty..... OK
[2/120-CoCoALib] test-BigInt1..... OK
[3/120-CoCoALib] test-BigInt2..... OK
[4/120-CoCoALib] test-BigInt3..... OK
[5/120-CoCoALib] *****  test-BigRat1 FAILED  ***** (wrong output)
[6/120-CoCoALib] test-BigRat2..... OK
[7/120-CoCoALib] test-BigRat3..... OK
[8/120-CoCoALib] test-BigRat4..... OK
[9/120-CoCoALib] test-bool3..... OK
[10/120-CoCoALib] *****  test-exbugs FAILED  ***** (wrong output)
[11/120-CoCoALib] test-combinatorics1..... OK
[12/120-CoCoALib] test-convert1..... OK
[13/120-CoCoALib] test-cyclotomic..... OK
[14/120-CoCoALib] *****  test-DenseUPolyRing1 FAILED  ***** (wrong output)
[15/120-CoCoALib] test-DynamicBitset1..... OK
[16/120-CoCoALib] test-factor1..... OK
[17/120-CoCoALib] test-FloatApprox1..... OK
[18/120-CoCoALib] test-FractionField1..... OK
[19/120-CoCoALib] test-FreeModule1..... OK
[20/120-CoCoALib] *****  test-FreeModule2 FAILED  ***** (wrong output)
[21/120-CoCoALib] test-frobby1..... OK
[22/120-CoCoALib] *****  test-GMPAllocator FAILED  ***** (wrong output)
[23/120-CoCoALib] *****  test-GOperations1 FAILED  ***** (wrong output)
[24/120-CoCoALib] test-GOperations2..... OK
[25/120-CoCoALib] *****  test-GReductor1 FAILED  ***** (wrong output)
[26/120-CoCoALib] test-Graeffe..... OK
[27/120-CoCoALib] test-gsl1..... OK
[28/120-CoCoALib] test-hilbert1..... OK
[29/120-CoCoALib] test-HomomorphismOps1..... OK
[30/120-CoCoALib] test-ideal1..... OK
[31/120-CoCoALib] test-ideal2..... OK
[32/120-CoCoALib] test-IdealOfPoints1..... OK
[33/120-CoCoALib] test-IntOperations1..... OK
[34/120-CoCoALib] test-IntOperations2..... OK
[35/120-CoCoALib] test-IntOperations3..... OK
[36/120-CoCoALib] *****  test-IsInteger1 FAILED  ***** (wrong output)
[37/120-CoCoALib] test-LRSDegeneracy1..... OK
[38/120-CoCoALib] test-LRSDegeneracy2..... OK
[39/120-CoCoALib] test-MachineInt1..... OK
[40/120-CoCoALib] test-MachineInt2..... OK
[41/120-CoCoALib] test-matrix1..... OK
[42/120-CoCoALib] *****  test-matrix2 FAILED  ***** (wrong output)
[43/120-CoCoALib] test-matrix3..... OK
[44/120-CoCoALib] test-matrix4..... OK
[45/120-CoCoALib] test-MatrixForOrdering1..... OK
[46/120-CoCoALib] *****  test-MatrixForOrdering2 FAILED  ***** (wrong output)
[47/120-CoCoALib] test-MatrixSpecial1..... OK
[48/120-CoCoALib] test-MatrixSpecial2..... OK
[49/120-CoCoALib] test-MatrixOps1..... OK
[50/120-CoCoALib] test-MinPoly1..... OK
[51/120-CoCoALib] test-MinPoly2..... OK
[52/120-CoCoALib] test-module1..... OK
[53/120-CoCoALib] test-MonomialIdeal1..... OK
[54/120-CoCoALib] test-GFan1..... OK
[55/120-CoCoALib] test-normaliz1..... OK
[56/120-CoCoALib] test-normaliz2..... OK
[57/120-CoCoALib] *****  test-NumTheory1 FAILED  ***** (wrong output)
[58/120-CoCoALib] test-NumTheory2..... OK
[59/120-CoCoALib] *****  test-NumTheory3 FAILED  ***** (wrong output)
[60/120-CoCoALib] test-NumTheory4..... OK
[61/120-CoCoALib] test-NumTheory5..... OK
[62/120-CoCoALib] *****  test-obsolescent FAILED  ***** (wrong output)
[63/120-CoCoALib] *****  test-OpenMath1 FAILED  ***** (wrong output)
[64/120-CoCoALib] test-OrderedDomain1..... OK
[65/120-CoCoALib] test-OrderedDomain2..... OK
[66/120-CoCoALib] *****  test-output FAILED  ***** (wrong output)
[67/120-CoCoALib] *****  test-PPMonoid1 FAILED  ***** (wrong output)
[68/120-CoCoALib] *****  test-PPMonoid2 FAILED  ***** (wrong output)
[69/120-CoCoALib] *****  test-PPMonoidSparse1 FAILED  ***** (wrong output)
[70/120-CoCoALib] test-PPMonoidHom1..... OK
[71/120-CoCoALib] test-PPVector..... OK
[72/120-CoCoALib] test-QuotientRing1..... OK
[73/120-CoCoALib] *****  test-QBGenerator1 FAILED  ***** (wrong output)
[74/120-CoCoALib] test-RadicalMembership1..... OK
[75/120-CoCoALib] test-RandomSource1..... OK
[76/120-CoCoALib] test-RandomSource2..... OK
[77/120-CoCoALib] test-RandomSource3..... OK
[78/120-CoCoALib] *****  test-RandomLong1 FAILED  ***** (wrong output)
[79/120-CoCoALib] *****  test-RandomBigInt1 FAILED  ***** (wrong output)
[80/120-CoCoALib] test-RingAssign1..... OK
[81/120-CoCoALib] test-RingElem1..... OK
[82/120-CoCoALib] test-RingElem2..... OK
[83/120-CoCoALib] test-RingElem3..... OK
[84/120-CoCoALib] test-RingElem4..... OK
[85/120-CoCoALib] test-RingElem5..... OK
[86/120-CoCoALib] test-RingElem6..... OK
[87/120-CoCoALib] test-RingFp1..... OK
[88/120-CoCoALib] test-RingFq1..... OK
[89/120-CoCoALib] *****  test-RingHom1 FAILED  ***** (wrong output)
[90/120-CoCoALib] *****  test-RingHom2 FAILED  ***** (wrong output)
[91/120-CoCoALib] *****  test-RingHom3 FAILED  ***** (wrong output)
[92/120-CoCoALib] test-RingHom4..... OK
[93/120-CoCoALib] test-RingQQ1..... OK
[94/120-CoCoALib] test-RingTwinFloat1..... OK
[95/120-CoCoALib] test-RingTwinFloat2..... OK
[96/120-CoCoALib] test-RingTwinFloat3..... OK
[97/120-CoCoALib] test-RingTwinFloat4..... OK
[98/120-CoCoALib] test-RingTwinFloat5..... OK
[99/120-CoCoALib] test-RingWeyl1..... OK
[100/120-CoCoALib] test-RingZZ1..... OK
[101/120-CoCoALib] test-RingZZ2..... OK
[102/120-CoCoALib] test-RingZZmodN1..... OK
[103/120-CoCoALib] test-RootBound1..... OK
[104/120-CoCoALib] test-RootBound2..... OK
[105/120-CoCoALib] test-SmallFp1..... OK
[106/120-CoCoALib] test-SmallFp2..... OK
[107/120-CoCoALib] *****  test-SparsePolyRing1 FAILED  ***** (wrong output)
[108/120-CoCoALib] *****  test-SparsePolyRing2 FAILED  ***** (wrong output)
[109/120-CoCoALib] test-SqFreeFactor1..... OK
[110/120-CoCoALib] test-SturmSeq1..... OK
[111/120-CoCoALib] test-symbol1..... OK
[112/120-CoCoALib] test-symbol2..... OK
[113/120-CoCoALib] test-toric1..... OK
[114/120-CoCoALib] *****  test-TmpIsTree FAILED  ***** (wrong output)
[115/120-CoCoALib] test-TmpMorseElement..... OK
[116/120-CoCoALib] test-TmpMorsePath..... OK
[117/120-CoCoALib] test-TmpMorseGraph..... OK
[118/120-CoCoALib] test-TmpResolutionMinimization..... OK
[119/120-CoCoALib] test-utils1..... OK
[120/120-CoCoALib] test-utils2..... OK
**********************
*****  Bad news  *****
**********************
*****  The following CoCoALib tests failed, please tell us about it.
*****   test-BigRat1 test-exbugs test-DenseUPolyRing1 test-FreeModule2 test-GMPAllocator test-GOperations1 test-GReductor1 test-IsInteger1 test-matrix2 test-MatrixForOrdering2 test-NumTheory1 test-NumTheory3 test-obsolescent test-OpenMath1 test-output test-PPMonoid1 test-PPMonoid2 test-PPMonoidSparse1 test-QBGenerator1 test-RandomLong1 test-RandomBigInt1 test-RingHom1 test-RingHom2 test-RingHom3 test-SparsePolyRing1 test-SparsePolyRing2 test-TmpIsTree
make[3]: *** [check] Error 1
make[2]: *** [check] Error 2
make[1]: *** [check] Error 2
make: *** [default] Error 2

#2 Updated by John Abbott 3 months ago

  • Priority changed from Normal to High

#3 Updated by John Abbott about 2 months ago

I'm hoping to sort this out soon... ideally by tomorrow (ha ha!). It seems I've forgotten username/password (sigh). Hope to resolve it tomorrow. Maybe the error mesgs from Max Horn are already enough to make some improvements?

#4 Updated by John Abbott about 2 months ago

  • Status changed from New to In Progress
  • Assignee set to John Abbott
  • % Done changed from 0 to 10

I have now changed all messages in the checking scripts so that they specify the full path when referring to LogFile, and in some cases I added a reference to the LogFile.
I have also revised configure so that the suffix for libgmp is (hopefully) correctly handled: it expects one of .a or .so or .dylib or .dll.a (weird Micrsoft name?)

Uff! Now I suppose I must check the changes (sigh)

I'm puzzled by the wrong output errors in some of the tests. Not sure how to fix this with trying it myself.

#5 Updated by John Abbott about 2 months ago

Aha! The examples with wrong output are all examples which are expected to produce output.

There are two likely causes:
  • the output of the execution is written into the wrong place/file
  • the comparison of the output with the expected output incorrectly reports a problem (maybe weird newlines?)

#6 Updated by John Abbott about 2 months ago

  • Status changed from In Progress to Resolved
  • % Done changed from 10 to 70

CoCoALib now seems to compile without too many hiccups... Will check in shortly.
Not yet tried CoCoA-5

#7 Updated by John Abbott about 2 months ago

#8 Updated by John Abbott about 2 months ago

  • Status changed from Resolved to Feedback
  • % Done changed from 70 to 90

Verified that CoCoA-5 also build OK on Mac M1.
--> feedback

#9 Updated by John Abbott about 1 month ago

Failed to verify on Anna's old intel MacBook: compiler gave an error about ptrdiff_t in some system header (sigh)
[probably xcode is not correctly installed]

#10 Updated by John Abbott about 1 month ago

  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100
  • Estimated time set to 3.33 h

Also available in: Atom PDF