choishingwan / PRSice

A software package for calculating, applying, evaluating and plotting the results of polygenic risk scores
http://prsice.info
GNU General Public License v3.0
185 stars 86 forks source link

[BUG] `sys/sysctl.h` is deprecated in glibc-2.3.2 #338

Open espenhgn opened 1 year ago

espenhgn commented 1 year ago

Describe the bug Dear @choishingwan. The deprecated sys/sysctl.h is used in a few places across the PRSice codes, preventing compilation of the project.

Error Log Compilation error running make:

...
43.57 -- Found ZLIB: /usr/lib/aarch64-linux-gnu/libz.so (found version "1.2.11") 
43.57 -- Looking for C++ include pthread.h
43.64 -- Looking for C++ include pthread.h - found
43.64 -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
43.73 -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
43.73 -- Found Threads: TRUE  
43.73 -- Configuring done
43.74 -- Generating done
43.75 -- Build files have been written to: /tmp/PRSice-2.3.5/build
43.78 [  4%] Building CXX object src/CMakeFiles/bgen.dir/bgen_lib.cpp.o
43.96 In file included from /tmp/PRSice-2.3.5/inc/memoryread.hpp:4,
43.96                  from /tmp/PRSice-2.3.5/lib/bgen_lib.hpp:10,
43.96                  from /tmp/PRSice-2.3.5/src/bgen_lib.cpp:7:
43.96 /tmp/PRSice-2.3.5/inc/misc.hpp:51:10: fatal error: sys/sysctl.h: No such file or directory
43.96    51 | #include <sys/sysctl.h>
43.96       |          ^~~~~~~~~~~~~~
43.96 compilation terminated.
43.96 make[2]: *** [src/CMakeFiles/bgen.dir/build.make:76: src/CMakeFiles/bgen.dir/bgen_lib.cpp.o] Error 1
43.96 make[1]: *** [CMakeFiles/Makefile2:112: src/CMakeFiles/bgen.dir/all] Error 2
43.96 make: *** [Makefile:91: all] Error 2

To Reproduce

Try build the following Dockerfile (some work in progress virtual machine, based on Ubuntu jammy (22.04LTS):

# R container
FROM rocker/r-ver:4.3.1

ENV TZ=Europe
ENV DEBIAN_FRONTEND noninteractive

WORKDIR /tmp/

# some system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils=2.4.10 && \
    apt-get update && apt-get install -y --no-install-recommends ca-certificates=20230311ubuntu0.22.04.1 && \
    update-ca-certificates
RUN apt-get update && apt-get install -y --no-install-recommends \
   unzip=6.0-26ubuntu3.1 \
   wget=1.21.2-2ubuntu1 \
   curl=7.81.0-1ubuntu1.13 \
   node-shasum=1.0.2-3 \
   libatlas-base-dev=3.10.3-12ubuntu1 \
   libgslcblas0=2.7.1+dfsg-3 \
   cmake=3.22.1-1ubuntu1.22.04.1 \
   zlib1g-dev \
   && \
   apt-get clean && \
   rm -rf /var/lib/apt/lists/*

# install PRSice-2
RUN wget --no-check-certificate https://github.com/choishingwan/PRSice/archive/refs/tags/2.3.5.zip && \
    unzip 2.3.5.zip && \
    cd PRSice-2.3.5 && \
    mkdir build && \
    cd build && \
    cmake ../ && \
    make && \
    cp PRSice/bin/PRSice /bin/ && \
    cd /tmp && \
    rm -rf 2.3.5.zip PRSice-2.3.5

RUN rm -rf /tmp/*

WORKDIR /

issuing: docker build -t prsice2 -f Dockerfile .

espenhgn commented 1 year ago

Hi again, just to add a bit more context. I'm trying to provide a cross-platform solution for PRSice2 etc. including M1 Macs via Docker (arm64-based architecture). I could get the compilation to work now on this rocker/r-ver:4.3.1 base image (based on Ubuntu 22.04 LTS) on a x86_64 host machine by removing #include <sys/sysctl.h> and replacing #include <Eigen/Dense> by #include <eigen3/Eigen/Dense> across inc/*.h files, but still encountered an issue that I couldn't resolve with the arm64 based platform in a Plink derived file:

77.35 [ 36%] Building CXX object src/CMakeFiles/plink.dir/plink_common.cpp.o
77.43 In file included from /tmp/PRSice-2.3.5/src/plink_common.cpp:18:
77.43 /tmp/PRSice-2.3.5/lib/plink_common.hpp:160:2: error: #error "64-bit builds currently require SSE2.  Try producing a 32-bit build instead."
77.43   160 | #error \
77.43       |  ^~~~~
77.43 /tmp/PRSice-2.3.5/lib/plink_common.hpp:163:10: fatal error: emmintrin.h: No such file or directory
77.43   163 | #include <emmintrin.h>
77.43       |          ^~~~~~~~~~~~~
77.43 compilation terminated.
77.43 make[2]: *** [src/CMakeFiles/plink.dir/build.make:76: src/CMakeFiles/plink.dir/plink_common.cpp.o] Error 1
77.43 make[1]: *** [CMakeFiles/Makefile2:191: src/CMakeFiles/plink.dir/all] Error 2
77.43 make: *** [Makefile:91: all] Error 2

(similar to an older version of https://github.com/chrchang/plink-ng/blob/master/1.9/plink_common.h I presume)

Do you think it is feasible to provide better "official" support on M1/arm64-based architectures, as well as more recent OS such as Ubuntu 22.04 (LTS)?

chrchang commented 1 year ago

fyi, recent plink 1.9 builds use the SIMDe library (https://github.com/simd-everywhere/simde ) to support ARM builds; see lines 190-195 of the current plink_common.h .