Repository: pytorch
Issue: USE_SYSTEM_SLEEF: undefined reference to symbol 'Sleef_expd4_u10'
Labels: module: build,triaged,module: sleef

## 🐛 Bug

I'm trying to build PyTorch 1.7.1 with `USE_SYSTEM_SLEEF` and I'm seeing the following error:
```
[4267/4704] Linking CXX executable bin/vec256_test_all_types_AVX2
FAILED: bin/vec256_test_all_types_AVX2 
: && /home/t-astewart/spack/lib/spack/env/gcc/g++ -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_VULKAN_WRAPPER -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow -DHAVE_AVX_CPU_DEFINITION -DHAVE_AVX2_CPU_DEFINITION -O3 -DNDEBUG -DNDEBUG -rdynamic -Wl,-rpath -Wl,/home/t-astewart/spack/opt/spack/linux-ubuntu18.04-haswell/gcc-7.5.0/hwloc-2.5.0-e7ygv5b2kvnvzl3bxbft2b72xzaqkciu/lib -Wl,-rpath -Wl,/home/t-astewart/spack/opt/spack/linux-ubuntu18.04-haswell/gcc-7.5.0/libevent-2.1.12-p2dxdtdk7dzoe3hifzobmiesuhssfjto/lib -Wl,-rpath -Wl,/home/t-astewart/spack/opt/spack/linux-ubuntu18.04-haswell/gcc-7.5.0/zlib-1.2.11-fegtmskef3daxdtyp3x3m6zz2fjfpxpq/lib -Wl,-rpath -Wl,/home/t-astewart/spack/opt/spack/linux-ubuntu18.04-haswell/gcc-7.5.0/openmpi-4.0.5-7qbqtxj5elk634wyigfpl4uuecfknflk/lib -L/home/t-astewart/spack/opt/spack/linux-ubuntu18.04-haswell/gcc-7.5.0/hwloc-2.5.0-e7ygv5b2kvnvzl3bxbft2b72xzaqkciu/lib -L/home/t-astewart/spack/opt/spack/linux-ubuntu18.04-haswell/gcc-7.5.0/libevent-2.1.12-p2dxdtdk7dzoe3hifzobmiesuhssfjto/lib -L/home/t-astewart/spack/opt/spack/linux-ubuntu18.04-haswell/gcc-7.5.0/zlib-1.2.11-fegtmskef3daxdtyp3x3m6zz2fjfpxpq/lib -pthread caffe2/CMakeFiles/vec256_test_all_types_AVX2.dir/__/aten/src/ATen/test/vec256_test_all_types.cpp.o -o bin/vec256_test_all_types_AVX2 -L/opt/intel/mkl/lib/intel64 -Wl,-rpath,/home/t-astewart/spack/opt/spack/linux-ubuntu18.04-haswell/gcc-7.5.0/protobuf-3.12.2-kk7635xzwbwci5fs25kan4gnlu6rqepl/lib:/home/t-astewart/spack/opt/spack/linux-ubuntu18.04-haswell/gcc-7.5.0/zlib-1.2.11-fegtmskef3daxdtyp3x3m6zz2fjfpxpq/lib:/home/t-astewart/spack/opt/spack/linux-ubuntu18.04-haswell/gcc-7.5.0/openblas-0.3.15-oqbdvprnws5d63wrdu54x2gv6l3rbbpc/lib:/opt/intel/mkl/lib/intel64:/tmp/t-astewart/spack-stage/spack-stage-py-torch-1.7.1-yufiftqx3amdddpg23zwtys6izz2ukjq/spack-src/build/lib:/usr/local/cuda/lib64:/home/t-astewart/spack/opt/spack/linux-ubuntu18.04-haswell/gcc-7.5.0/cudnn-8.0.5.39-10.1-gzf5kd5mcxqyrojkrpj3gdijiu2kvybi/lib64  lib/libgtest_main.a  -Wl,--no-as-needed,"/tmp/t-astewart/spack-stage/spack-stage-py-torch-1.7.1-yufiftqx3amdddpg23zwtys6izz2ukjq/spack-src/build/lib/libtorch.so" -Wl,--as-needed  -Wl,--no-as-needed,"/tmp/t-astewart/spack-stage/spack-stage-py-torch-1.7.1-yufiftqx3amdddpg23zwtys6izz2ukjq/spack-src/build/lib/libtorch_cpu.so" -Wl,--as-needed  /home/t-astewart/spack/opt/spack/linux-ubuntu18.04-haswell/gcc-7.5.0/protobuf-3.12.2-kk7635xzwbwci5fs25kan4gnlu6rqepl/lib/libprotobuf.so.3.12.2.0  -lpthread  /home/t-astewart/spack/opt/spack/linux-ubuntu18.04-haswell/gcc-7.5.0/zlib-1.2.11-fegtmskef3daxdtyp3x3m6zz2fjfpxpq/lib/libz.so  /home/t-astewart/spack/opt/spack/linux-ubuntu18.04-haswell/gcc-7.5.0/openblas-0.3.15-oqbdvprnws5d63wrdu54x2gv6l3rbbpc/lib/libopenblas.so  -lmkl_intel_lp64  -lmkl_gnu_thread  -lmkl_core  -fopenmp  -lpthread  -lm  /usr/lib/x86_64-linux-gnu/libdl.so  lib/libdnnl.a  -ldl  -Wl,--no-as-needed,"/tmp/t-astewart/spack-stage/spack-stage-py-torch-1.7.1-yufiftqx3amdddpg23zwtys6izz2ukjq/spack-src/build/lib/libtorch_cuda.so" -Wl,--as-needed  lib/libc10_cuda.so  lib/libc10.so  /usr/local/cuda/lib64/libcudart.so  /usr/local/cuda/lib64/libnvToolsExt.so  /usr/local/cuda/lib64/libcufft.so  /usr/local/cuda/lib64/libcurand.so  /usr/local/cuda/lib64/libcublas.so  /home/t-astewart/spack/opt/spack/linux-ubuntu18.04-haswell/gcc-7.5.0/cudnn-8.0.5.39-10.1-gzf5kd5mcxqyrojkrpj3gdijiu2kvybi/lib64/libcudnn.so  lib/libgtest.a  -pthread && :
/usr/bin/ld: caffe2/CMakeFiles/vec256_test_all_types_AVX2.dir/__/aten/src/ATen/test/vec256_test_all_types.cpp.o: undefined reference to symbol 'Sleef_expd4_u10'
//home/t-astewart/spack/opt/spack/linux-ubuntu18.04-haswell/gcc-7.5.0/sleef-2019-07-30-iihgvx52ioaaxk5ndxrlb6as6c2i5h7j/lib/libsleef.so.3: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
```

## To Reproduce

Steps to reproduce the behavior:

1. Set `USE_SYSTEM_SLEEF`
1. `python setup.py install`

## Expected behavior

I would expect to be able to build with a system installation of sleef.

## Environment

 - PyTorch Version: 1.7.1
 - OS: Linux (Ubuntu 18.04)
 - How you installed PyTorch: `spack`
 - Build command you used: `python setup.py install`
 - Python version: 3.8.10
 - CUDA/cuDNN version: 10.1.243/8.0.5.39
 - GPU models and configuration: K80 (sm_37)

## Additional context

* [build log](https://github.com/pytorch/pytorch/files/6681430/spack-build-out.txt)
* [build env](https://github.com/pytorch/pytorch/files/6681431/spack-build-env.txt)

cc @malfet @seemethere @walterddr