Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile Mac OS binary with xCode AND OpenMP #246

Open
w-bruns opened this issue Aug 10, 2019 · 5 comments
Open

Compile Mac OS binary with xCode AND OpenMP #246

w-bruns opened this issue Aug 10, 2019 · 5 comments

Comments

@w-bruns
Copy link
Contributor

w-bruns commented Aug 10, 2019

This is indeed possible if one installs the dynamic library for OpenMP from Homebrew (information from Dan Grayson). Some tricks are necessary, but we will do it in the long run.

@w-bruns
Copy link
Contributor Author

w-bruns commented Oct 22, 2019

See http://antonmenshov.com/2017/09/09/clang-openmp-setup-in-xcode/

Further information by D. Grayson:

..but the secret seems to be to give g++ the pair of options

-Xpreprocessor -fopenmp

and then to link with

-lomp


think that's right. Also, you should upgrade to the latest version of the openmp macro file and then apply this diff, which includes
a hack for trying a pair of options.

gallium$ diff -u m4/ax_openmp-2.69.m4 m4/ax_openmp.m4
--- m4/ax_openmp-2.69.m4 2019-08-07 11:53:41.000000000 -0400
+++ m4/ax_openmp.m4 2019-08-07 12:16:18.000000000 -0400
@@ -79,11 +79,12 @@
 #                -xopenmp (Sun), -omp (Tru64),
 #                -qsmp=omp (AIX),
 #                none
-ax_openmp_flags="-fopenmp -openmp -qopenmp -mp -xopenmp -omp -qsmp=omp none"
+ax_openmp_flags="-fopenmp -openmp -qopenmp -mp -xopenmp -omp -qsmp=omp -Xpreprocessor%-fopenmp none"
 if test "x$OPENMP_[]_AC_LANG_PREFIX[]FLAGS" != x; then
   ax_openmp_flags="$OPENMP_[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flags"
 fi
 for ax_openmp_flag in $ax_openmp_flags; do
+  ax_openmp_flag=`echo $ax_openmp_flag | sed 's/%/ /g'` ;
   case $ax_openmp_flag in
     none) []_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[] ;;
     *) []_AC_LANG_PREFIX[]FLAGS="$save[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flag" ;;

@mahrud
Copy link
Contributor

mahrud commented Dec 15, 2021

By the way, I'm not sure if you're aware but I've made a homebrew "bottle" for Normaliz based on this formula. It's on a separate homebrew tap, so you need an extra step to install it:

brew tap Macaulay2/tap
brew install normaliz

The key for getting it to build with OpenMP is the following flag:

ENV["OPENMP_CXXFLAGS"] = "-Xpreprocessor\ -fopenmp\ -I#{libomp.opt_include} #{libomp.opt_lib}/libomp.dylib"

Other than that, my PR #335 the only fix to get this to work automatically.

@w-bruns
Copy link
Contributor Author

w-bruns commented Dec 15, 2021

Very good! Thanks for your support.

I am preparing a list of questions for you.

@w-bruns
Copy link
Contributor Author

w-bruns commented Dec 19, 2021

In order to integrate your "bottle" completely the following steps would be necessary:

  1. Insertion into the install scripts (install_normaliz.sh in the main directory and in install_scripts_opt for the optional libaries) with the corresponding changes in the manual

  2. integration into out GitHub workflow, in particular for the compilation of an almost static binary that we can download as an artifact.

It would also be good if we could include an M1-binary in our distribution. I am not sure where we could compile it. It is unclear to me whether GitHub actions offer M1 support.

@mahrud
Copy link
Contributor

mahrud commented Dec 19, 2021

I'm not sure if I follow. In what way would you like to integrate the bottle?

If you'd like, you can create and maintain your own tap on a repository Normaliz/homebrew-tap by following this guide, but the GitHub Workflows on the Macaulay2 tap already build bottles for Normaliz on linux and macOS catalina and big sur (currently GitHub only supports x86_64 actions), so it wouldn't be any different.

If you do decide to create your own tap, you're welcome to copy the formula I created here as the starting point, and I'll switch the dependencies so your tap is used as the source.

You can also try to get Normaliz to be included in the homebrew's core repository (see this guide), which has the benefit of also building bottles for M1 systems, but that might require some additional work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants