xtensor-stack / xtensor

C++ tensors with broadcasting and lazy computing
BSD 3-Clause "New" or "Revised" License
3.27k stars 390 forks source link

Linker error on GCC and Clang CPP14 when using xt::numeric_constants #2516

Open spectre-ns opened 2 years ago

spectre-ns commented 2 years ago

Ran into some weird behavior where some compilers allowed me to do as I wish and use the predefined numerical constants in xmath.hpp and other were not allowing it. The build logs from pr #2514 show the issue. I eventually resolved it (Worked around it) by redefining PI in detail namespace away from the interface. Not a great fix.

spectre-ns commented 2 years ago

[build] /home/drew-hubley/anaconda3/envs/xtensor/bin/../lib/gcc/x86_64-conda-linux-gnu/11.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: CMakeFiles/test_xfft.dir/test_xfft.cpp.o: warning: relocation against _ZN2xt17numeric_constantsIdE2PIE' in read-only section.text._ZN2xt3fft6detail15transformRadix2IdNS_13xstrided_viewIRNS_16xarray_containerINS_7uvectorISt7complexIdESaIS7_EEELNS_11layout_typeE1ENS_7svectorImLm4ESaImELb1EEENS_22xtensor_expression_tagEEESD_LSA_0ENS_6detail20inner_storage_getterISGEEEEEEDaRKT0[_ZN2xt3fft6detail15transformRadix2IdNS_13xstrided_viewIRNS_16xarray_containerINS_7uvectorISt7complexIdESaIS7_EEELNS_11layout_typeE1ENS_7svectorImLm4ESaImELb1EEENS_22xtensor_expression_tagEEESD_LSA_0ENS_6detail20inner_storage_getterISGEEEEEEDaRKT0]' [build] /home/drew-hubley/anaconda3/envs/xtensor/bin/../lib/gcc/x86_64-conda-linux-gnu/11.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: CMakeFiles/test_xfft.dir/test_xfft.cpp.o: in function auto xt::fft::detail::transformRadix2<double, xt::xstrided_view<xt::xarray_container<xt::uvector<double, std::allocator<double> >, (xt::layout_type)1, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, xt::xtensor_expression_tag>&, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, (xt::layout_type)0, xt::detail::inner_storage_getter<xt::xarray_container<xt::uvector<double, std::allocator<double> >, (xt::layout_type)1, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, xt::xtensor_expression_tag>&> > >(xt::xstrided_view<xt::xarray_container<xt::uvector<double, std::allocator<double> >, (xt::layout_type)1, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, xt::xtensor_expression_tag>&, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, (xt::layout_type)0, xt::detail::inner_storage_getter<xt::xarray_container<xt::uvector<double, std::allocator<double> >, (xt::layout_type)1, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, xt::xtensor_expression_tag>&> > const&)': [build] /home/drew-hubley/xtensor/include/xtensor/xfft.hpp:63: undefined reference toxt::numeric_constants::PI' [build] /home/drew-hubley/anaconda3/envs/xtensor/bin/../lib/gcc/x86_64-conda-linux-gnu/11.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: CMakeFiles/test_xfft.dir/test_xfft.cpp.o: in function auto xt::fft::detail::transformRadix2<double, xt::xstrided_view<xt::xarray_container<xt::uvector<std::complex<double>, std::allocator<std::complex<double> > >, (xt::layout_type)1, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, xt::xtensor_expression_tag>&, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, (xt::layout_type)0, xt::detail::inner_storage_getter<xt::xarray_container<xt::uvector<std::complex<double>, std::allocator<std::complex<double> > >, (xt::layout_type)1, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, xt::xtensor_expression_tag>&> > >(xt::xstrided_view<xt::xarray_container<xt::uvector<std::complex<double>, std::allocator<std::complex<double> > >, (xt::layout_type)1, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, xt::xtensor_expression_tag>&, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, (xt::layout_type)0, xt::detail::inner_storage_getter<xt::xarray_container<xt::uvector<std::complex<double>, std::allocator<std::complex<double> > >, (xt::layout_type)1, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, xt::xtensor_expression_tag>&> > const&)': [build] /home/drew-hubley/xtensor/include/xtensor/xfft.hpp:63: undefined reference toxt::numeric_constants::PI' [build] /home/drew-hubley/anaconda3/envs/xtensor/bin/../lib/gcc/x86_64-conda-linux-gnu/11.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: warning: creating DT_TEXTREL in a PIE