Skip to content

CMake build fails without OPENMP after setting USE_OPENMP=OFF #5518

@aviks

Description

@aviks

The CMake option of USE_OPENMP=OFF is meant to allow compilation of xgboost without the OpenMP libraries. However this fails on master. It did work as expected on 1.0.2 and 0.82.0

Build Script:

git submodule init; git submodule update
mkdir build; cd build
cmake .. -DUSE_OPENMP=OFF
make -j2

On a Mac, using clang, without libgomp installed, we get a compiler error

[ 47%] Building CXX object src/CMakeFiles/objxgboost.dir/metric/rank_metric.cc.o
/Users/aviks/dev/julia/xgboost/src/metric/rank_metric.cc:192:13: error: use of undeclared identifier 'omp_in_parallel'
        if (omp_in_parallel()) {
            ^
/Users/aviks/dev/julia/xgboost/src/metric/rank_metric.cc:560:13: error: use of undeclared identifier 'omp_in_parallel'
        if (omp_in_parallel()) {
            ^
2 errors generated.
make[2]: *** [src/CMakeFiles/objxgboost.dir/metric/rank_metric.cc.o] Error 1
make[1]: *** [src/CMakeFiles/objxgboost.dir/all] Error 2
make: *** [all] Error 2

On a linux machine with gcc9, we get a linker error

[ 98%] Linking CXX executable ../xgboost
/usr/bin/ld: src/CMakeFiles/objxgboost.dir/metric/rank_metric.cc.o: in function `xgboost::metric::EvalAucPR::Eval(xgboos
t::HostDeviceVector<float> const&, xgboost::MetaInfo const&, bool)':
rank_metric.cc:(.text._ZN7xgboost6metric9EvalAucPR4EvalERKNS_16HostDeviceVectorIfEERKNS_8MetaInfoEb[_ZN7xgboost6metric9E
valAucPR4EvalERKNS_16HostDeviceVectorIfEERKNS_8MetaInfoEb]+0x5a4): undefined reference to `omp_in_parallel'
/usr/bin/ld: rank_metric.cc:(.text._ZN7xgboost6metric9EvalAucPR4EvalERKNS_16HostDeviceVectorIfEERKNS_8MetaInfoEb[_ZN7xgb
oost6metric9EvalAucPR4EvalERKNS_16HostDeviceVectorIfEERKNS_8MetaInfoEb]+0x1069): undefined reference to `omp_in_parallel
'
/usr/bin/ld: src/CMakeFiles/objxgboost.dir/metric/rank_metric.cc.o: in function `xgboost::metric::EvalAuc::Eval(xgboost:
:HostDeviceVector<float> const&, xgboost::MetaInfo const&, bool)':
rank_metric.cc:(.text._ZN7xgboost6metric7EvalAuc4EvalERKNS_16HostDeviceVectorIfEERKNS_8MetaInfoEb[_ZN7xgboost6metric7Eva
lAuc4EvalERKNS_16HostDeviceVectorIfEERKNS_8MetaInfoEb]+0x484): undefined reference to `omp_in_parallel'
/usr/bin/ld: rank_metric.cc:(.text._ZN7xgboost6metric7EvalAuc4EvalERKNS_16HostDeviceVectorIfEERKNS_8MetaInfoEb[_ZN7xgboo
st6metric7EvalAuc4EvalERKNS_16HostDeviceVectorIfEERKNS_8MetaInfoEb]+0x864): undefined reference to `omp_in_parallel'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/runxgboost.dir/build.make:191: ../xgboost] Error 1
make[1]: *** [CMakeFiles/Makefile2:172: CMakeFiles/runxgboost.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions