can't build PAPI on mac osx

Issue #54 on hold
Carter Schonwald created an issue

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)

  1. Geoff Oxberry

    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 #included in <stdlib.h>, so the compile failures can be patched around by replacing #include <malloc.h> with the snippet

    #if !defined(__APPLE__)
    #include <malloc.h>
    #endif
    

    because #include <stdlib.h> appears earlier in those relevant source files.

    macOS does not include librt, so a conditional must be used to define EXTRALIB in src/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,

    OMPCFLGS="-Xpreprocessor -fopenmp"
    LDFLAGS="$LDFLAGS -L/usr/local/lib -lomp"
    

    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 is incompatible with newer versions of macOS. Last I checked, I believe Valgrind 3.15 added macOS 10.13 compatibility.
    • Even if I set VALGRIND=: (i.e., a no-op command) in src/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.

  2. Giuseppe Congiu

    PAPI currently configures cpu components perf_event and perf_event_uncore by default. These require perf_event_open which is not provided by macOS.

  3. Roland Haas

    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?

  4. Log in to comment