Macaulay2 / homebrew-tap

The Macaulay2 tap for Homebrew
7 stars 6 forks source link

Csdp, clang, unknown type name inline #103

Closed nobuki-takayama closed 3 years ago

nobuki-takayama commented 3 years ago

Hi, I tried to install M2 by

 brew install Macaulay2/tap/M2

on M1-Mac. However, it failed to compile Csdp. The clang does not recognize the keyword "inline"; I guess that it needs an option to understand the c99 specification. Many thanks in advance for advices.

mahrud commented 3 years ago

Did you try the solution in https://github.com/Macaulay2/homebrew-tap/issues/92#issuecomment-867150098?

mahrud commented 3 years ago

Which package requires libomp, by the way? Like, if you just do

brew uninstall --ignore-dependencies libomp

and try to build csdp, what fails?

nobuki-takayama commented 3 years ago

The workaround of #92 causes the same error. Here is the output of brew uninstall --ignore-dependencies libomp and brew install csdp

bash-3.2$ brew uninstall --ignore-dependencies libomp
Uninstalling /opt/homebrew/Cellar/libomp/13.0.0... (9 files, 1.5MB)
bash-3.2$ brew install csdp
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Formulae
Updated 20 formulae.
==> Updated Casks
Updated 28 casks.
==> Deleted Casks
qqbrowser                                      uc-one

==> Downloading https://ghcr.io/v2/homebrew/core/libomp/manifests/13.0.0
Already downloaded: 
/Users/nobuki/Library/Caches/Homebrew/downloads/e5d1162de21152d4e8edcdcad88daf8290f53769dd8c7677d94025982d5594fc--libomp-13.0.0.bottle_manifest.json
==> Downloading 
https://ghcr.io/v2/homebrew/core/libomp/blobs/sha256:13fb59602f7b525b38416ca
Already downloaded: 
/Users/nobuki/Library/Caches/Homebrew/downloads/03cb9866585a0de09771ee8d044b5298286d8de5303a99aa78ae263862e840b8--libomp--13.0.0.arm64_big_sur.bottle.tar.gz
==> Downloading 
https://raw.githubusercontent.com/Macaulay2/M2/1f99f71a1308318679412de7f20e9
Already downloaded: 
/Users/nobuki/Library/Caches/Homebrew/downloads/3502d46bdfc627a4d2dd452c2bf7e15efbbf546591d07240043326fe5f64df8e--patch-6.2.0
==> Downloading 
https://github.com/coin-or/Csdp/archive/releases/6.2.0.tar.gz
Already downloaded: 
/Users/nobuki/Library/Caches/Homebrew/downloads/49d31940eb27a9babe8061a83fed6d3b764e7d86091ebbd31a2ce4b559baa31c--Csdp-releases-6.2.0.tar.gz
==> Installing csdp from macaulay2/tap
==> Installing dependencies for macaulay2/tap/csdp: libomp
==> Installing macaulay2/tap/csdp dependency: libomp
==> Pouring libomp--13.0.0.arm64_big_sur.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libomp/13.0.0: 9 files, 1.5MB
==> Installing macaulay2/tap/csdp
==> Patching
==> Applying patch-6.2.0
patching file Makefile
patching file example/Makefile
patching file lib/user_exit.c
patching file solver/Makefile
patching file theta/Makefile
patching file theta/rand_graph.c
==> make CC=clang ${OpenMP_C_FLAGS} ${CFLAGS} LDLIBS=${OpenMP_C_LDLIBS} 
LIBS=-L../lib -lsdp
Last 15 lines from /Users/nobuki/Library/Logs/Homebrew/csdp/01.make:
clang -Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include -ansi 
-Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME -I../include 
-ansi -Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME 
-I../include   -c -o op_o.o op_o.c
clang -Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include -ansi 
-Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME -I../include 
-ansi -Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME 
-I../include   -c -o psd_feas.o psd_feas.c
clang -Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include -ansi 
-Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME -I../include 
-ansi -Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME 
-I../include   -c -o op_a.o op_a.c
clang -Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include -ansi 
-Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME -I../include 
-ansi -Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME 
-I../include   -c -o op_at.o op_at.c
clang -Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include -ansi 
-Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME -I../include 
-ansi -Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME 
-I../include   -c -o Fnorm.o Fnorm.c
clang -Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include -ansi 
-Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME -I../include 
-ansi -Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME 
-I../include   -c -o calc_pobj.o calc_pobj.c
In file included from op_o.c:15:
/opt/homebrew/opt/libomp/include/omp.h:484:12: error: unknown type name 
'inline'
     static inline int omp_is_initial_device(void) { return 1; }
            ^
1 error generated.
clang -Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include -ansi 
-Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME -I../include 
-ansi -Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME 
-I../include   -c -o calc_dobj.o calc_dobj.c
make[1]: *** [op_o.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2
mahrud commented 3 years ago

Can you try again with removing libomp and then running the following before installing csdp?

brew install --build-bottle libomp
mahrud commented 3 years ago

Oh you said you already tried that, never mind.

mahrud commented 3 years ago

I don't have access to an M1 system. It would help if someone tried to build csdp from source on an M1 system and tell us which configure flags worked.

nobuki-takayama commented 3 years ago

I removed -ansi from the CFLAG and added -lomp for the link. Csdp itself could be built.

bash-3.2$ pwd
/private/tmp/csdp-20211015-96409-69ak5e/Csdp-releases-6.2.0

bash-3.2$ diff Makefile.orig1 Makefile 
14c14,15 
< export CFLAGS += -ansi -Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME -I../include
---
> # Remove -ansi
> export CFLAGS += -Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME -I../include -Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include -Wall -DUSEOPENMP -DSETNUMTHREADS -DUSESIGTERM -DUSEGETTIME 
18c19,21
< export LIBS=-L../lib -lsdp -llapack -lblas -lm
---
> #export LIBS=-L../lib -lsdp -llapack -lblas -lm
> # Add -lomp
> export LIBS=-L/opt/homebrew/lib -L../lib  -lomp -lsdp -llapack -lblas -lm
youngsuKim-CSUSB commented 3 years ago

Thank you, @nobuki-takayama. I tried your approach, and I was able to compile Csdp from the source, too.

In my case, I did git clone https://github.com/coin-or/Csdp.git. Then I removed -ansi in CFLAGS and -static in LIBS. I needed to add export CC=gcc-11.

I wonder if I can update the homebrew formula accordingly. I tried to play with it but did not succeed.

mahrud commented 3 years ago

Thanks @nobuki-takayama! If removing -ansi is all it takes then it's an easy fix. I just made #104 and will merge it once it passes the tests. Can you give it another try in a few minutes?

nobuki-takayama commented 3 years ago

Thanks @mahrud ! The change is already in the main branch and the building of the dependent systems are all fine! But, as it is already reported in #105, the procedure stops at

 cmake --build M2/BUILD/build-brew --target install-packages

with several warnings of missing nodes of documents.

-------  snip
-- warning: missing node: (prune,Complex) cited by isFree(Complex)
 -- warning: 58 warning(s) occurred in documentation for package Complexes
ninja: build stopped: subcommand failed.

Is it a new issue?

mahrud commented 3 years ago

So csdp built fine? That's great! Yes, I believe that issue is due to gfan crashing. Did you see the other issue I tagged you in?

nobuki-takayama commented 3 years ago

04.cmake.log

The csdp is fine. I attach the ~/Library/Logs/Homebrew/macaulay2/04.cmake to check the details of the failure.

nobuki-takayama commented 3 years ago

It seems to be a different issue. Then, I will close this issue. Many thanks!

mahrud commented 3 years ago

Yes, those are precisely the examples that depend on gfan! See #100. If you could help compile gfan on M1 and troubleshoot why it crashes even on the most simple examples that would be very helpful!

youngsuKim-CSUSB commented 3 years ago

I'm sorry for my slow response. I can also confirm that Csdp installs fine on my machine (though I also face some errors with cmake). Thank you!

nobuki-takayama commented 3 years ago

gfan crashes on M1 MacBook Pro for some inputs, but it does not on M1 Mac-mini. It seems that these systems are not identical. I have an analogous trouble in a different software project. I guess that a bug in memory management causes the crash, but it will take time to find it...

youngsuKim-CSUSB commented 3 years ago

This afternoon I got it working. My issue was related to setting up the TBB library correctly. One package installation (the last one) failed, but everything else went ok.

I don't seem to have an issue with gfan. Mine is the iMac 24 inch. Thank you again for your help and tips!

mahrud commented 3 years ago

gfan crashes on M1 MacBook Pro for some inputs, but it does not on M1 Mac-mini. It seems that these systems are not identical. I have an analogous trouble in a different software project. I guess that a bug in memory management causes the crash, but it will take time to find it...

@nobuki-takayama Do you have any more information about this? Is the other project also written in c++? Any clues would be helpful.

nobuki-takayama commented 3 years ago

I'm occupied with teaching and other duties for now and have no progress. asir2018 in http://www.openxm.org (http://c1.math.kobe-u.ac.jp/cgi-bin/cvsweb.cgi/OpenXM_contrib2/asir2018/ ) is written in C with BoehmGC and GMP and have an analogous issue on M1 MacBook Pro.

On 2021/10/27 2:35, Mahrud Sayrafi wrote:

gfan crashes on M1 MacBook Pro for some inputs, but it does not on
M1 Mac-mini. It seems that these systems are not identical. I have
an analogous trouble in a different software project. I guess that a
bug in memory management causes the crash, but it will take time to
find it...

@nobuki-takayama https://github.com/nobuki-takayama Do you have any more information about this? Is the other project also written in c++? Any clues would be helpful.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Macaulay2/homebrew-tap/issues/103#issuecomment-952160701, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSA7NV6UFORAEO35JV4V53UI3RGDANCNFSM5GA23ODA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

MichaelABurr commented 2 years ago

@mahrud I found this issue and got around it by adding -std=gnu17 (or any other gnu standard) to the clang compiler flags (I directly compiled the files which had this issue and didn't add it to the full configure).

mahrud commented 2 years ago

Thanks! I'm not sure if I added a flag but I believe csdp is now bottled for brew on M1, isn't it? Meaning people don't need to compile it.