can't build PAPI on mac osx
hello! I was having a go at building PAPI on osx and ... well, the linker settings dont make sense afaict?
/usr/bin/clang -I../testlib -I.. -I. -DNEED_FFSLL -O2 -c display_error.c
/usr/bin/clang -I../testlib -I.. -I. -DNEED_FFSLL -O2 -c instructions_testcode.c
/usr/bin/clang -o cycles_validation cycles_validation.o ../testlib/libtestlib.a display_error.o instructions_testcode.o ../libpapi.a -lrt
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cycles_validation] Error 1
make: *** [validation_tests] Error 2
i dont think you can/need to link to the c runtime lib explicilty / its always dynamic linked or something on osx? either way, currently doesn't build. I tried cleaning it up and seeing where i got stuck next and i got some strange errors like
zero_shmem.c:11:10: fatal error: 'malloc.h' file not found
which makes me think i was trying to patch it wrong :)
Comments (5)
-
-
PAPI currently configures cpu components
perf_event
andperf_event_uncore
by default. These requireperf_event_open
which is not provided by macOS. -
- changed status to on hold
might be fixed by future versions
-
We do not support compiling anything on OSX using clang. It may work but so far we never managed to. Only gcc from homebrew or macos are tested. With those PAPI should (TM) build (or did during the last release). Is this no longer the case?
-
Currently, PAPI does not build on MacOS for the reasons I explained above.
- Log in to comment
I took a stab at building PAPI on macOS 10.14.5 and was able to patch it enough to build without errors, but running the tests results in a number of failures. See the
fix-darwin-build
branch of https://github.com/goxberry/papi. Note that I wouldn’t patch it the way I did if I were submitting a pull request – some of the build system changes hard-code changes that I would put into conditionals or additional variables.The testlib failures are relatively easy to patch --
`malloc.h
is in a bizarre location on macOS, but happens to be#include
d in<stdlib.h>
, so the compile failures can be patched around by replacing#include <malloc.h>
with the snippetbecause
#include <stdlib.h>
appears earlier in those relevant source files.macOS does not include librt, so a conditional must be used to define
EXTRALIB
insrc/validation_tests/Makefile
appropriately for macOS. As far as I could tell, libSystem on macOS contains some of the functionality that would be in librt on other systems, so-framework System
or-lSystem
could be used instead of-lrt
for linking.PAPI looks to require OpenMP, although it's not clear from the documentation -- perhaps I missed it? -- what version of the OpenMP standard is required. So I inserted the following two lines after
src/configure.in:1595
,and I installed version 8.0.0 of LLVM's OpenMP library,
libomp
, via Homebrew.These changes enabled me to build PAPI successfully. When I ran the tests in
src/run_tests.sh
, I encountered some problems:VALGRIND=:
(i.e., a no-op command) insrc/run_tests.sh
, some tests fail or segfault. I haven’t tried to step through any of the failures in a debugger yet. If I were to try to figure out the cause of the segfaults, I’d use Address Sanitizer instead of Valgrind.If there’s any further interest in getting PAPI to run successfully on macOS, I’d be happy to test changes, but I’m not sure I could devote much bandwidth to fixing the issues on macOS.