DReichLab / DReichLab/AdmixTools

Compilation issues on macOS Monterey and Sequoia (M1 Mac)

Open
#90 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
235
Forks
76
PR merge metrics
No merged PRs in 30d

Description

If you found this issue while trying to compile and install ADMIXTOOLS on the latest macOS Sequoia, take a look at my complete summary here. This contains the most up-to-date instructions.

I am leaving my original post below as it is, but it’s likely it won’t solve your issues on the latest macOS version.


Background

I just encountered some issues while compiling ADMIXTOOLS on a freshly unpacked M1 MacBook Pro running macOS Monterey Version 12.3.1 (openblas and gsl installed from Homebrew). The problem manifests both on the latest development commit of ADMIXTOOLS from GitHub as well as on the latest tagged v7.0.2 release.

Description of the problem # 1

The usual combination of cd src/ && make clobber && make install leads to:

[ ... snip ... ]

clang: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
admutils.c:459:9: error: implicitly declaring library function 'finite' with type 'int (double)' [-Werror,-Wimplicit-function-declaration]
   if (!finite(a[i])) fatalx("(testnan) fails:  index %d\n",i) ;
        ^
admutils.c:459:9: note: include the header <math.h> or explicitly provide a declaration for 'finite'
admutils.c:885:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
admutils.c:1114:28: warning: more '%' conversions than data arguments [-Wformat-insufficient-args]
    printf("(setid2pops): %s not found\n") ;
                          ~^
2 warnings and 1 error generated.
make: *** [admutils.o] Error 1

Solution to the problem # 1

I found out that the latest macOS compiler infrastructure provided by Xcode no longer considers implicit function declarations as warnings (as seems to have been the case at least prior to the latext Xcode v13) but it turns them into errors.

Adding -Wno-implicit-function-declaration to the CFLAGS list here so that it becomes:

override CFLAGS += -c -g -p -pg -Wimplicit -I./ -I./nicksrc -Wno-implicit-function-declaration

Fixed this particular error.

This is really an emergency solution, but one that works without modifying the source code. Explicitly including #include <math.h> in appropriate places should be the way to go, but I have not tested that myself.

Maybe it's worth implementing it in the Makefile? Unlike the usual openblas or gsl compilation errors, which are easy even for non-C/C++ programmers to solve with a bits of googling, this one took me a bit to get around.


Description of the problem # 2

Also, for completeness, it seems that the location of Homebrew-installed libraries suggested in the Makefiles under src/ is different in the latest version of Homebrew and/or macOS Monterey, the paths suggested here no longer work. Because of this, even uncommenting the Mac-specific flags doesn't work, and the compiler complains about the missing GSL.

Solution to the problem # 2

I had to change these flags to these locations:

override CFLAGS += -I/opt/homebrew/opt/openblas/include -I/opt/homebrew/opt/gsl/include
override LDFLAGS += -L/opt/homebrew/opt/openblas/lib -L/opt/homebrew/opt/gsl/lib

Obviously this will depend on the version of Homebrew and possibly also macOS so I'm not sure if it's worth modifying the Makefile (maybe it is, because this is the current status of things in the Homebrew world). However, I think the issue #1 with implicit function declarations is backwards compatible as well as necessary in latest Xcode, so it would be great to have it implemented in future versions.

With both of these fixes in place, I was able to compile ADMIXTOOLS on the latest M1 MBP macOS without further problems, using the default Makefile.


Hope this helps (even if only for people googling for similar errors, in ADMIXTOOLS or elsewhere).

--Martin

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/Makefile and the admutils.c compiler error, then run cd src && make clobber && make install on an M1 Mac with Homebrew dependencies. Done means ADMIXTOOLS compiles and installs on macOS Monterey or Sequoia without the reported implicit-declaration or missing-library errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, macos
Domain
build-system, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.