Skip to content

Conversation

@steffenlarsen
Copy link
Contributor

@steffenlarsen steffenlarsen commented Aug 25, 2022

Due to a bug in GCC versions older than 11.1 SYCL math builtins may fail to compile when using GCC as the host compiler. To work around this issue, this commit renames all host-side builtin implementations used by the SYCL math builtins.

The bug:

#include <cmath>

namespace __host_std {
  template <typename R, typename T>
  inline R __invoke_sqrt(T a) {
    extern R sqrt(T);
    return sqrt(a);
  }
}

int main() {
  __host_std::__invoke_sqrt<double>(3.5);
  return 0;
}

With gcc 10.4:

<source>: In instantiation of 'R __host_std::__invoke_sqrt(T) [with R = double; T = double]':
<source>:12:42:   required from here
<source>:6:18: error: local external declaration 'R __host_std::sqrt(T) [with R = double; T = double]' [-fpermissive]
    6 |         extern R sqrt(T);
      |                  ^~~~
In file included from /usr/include/features.h:461,
                 from /opt/compiler-explorer/gcc-10.4.0/include/c++/10.4.0/x86_64-linux-gnu/bits/os_defines.h:39,
                 from /opt/compiler-explorer/gcc-10.4.0/include/c++/10.4.0/x86_64-linux-gnu/bits/c++config.h:522,
                 from /opt/compiler-explorer/gcc-10.4.0/include/c++/10.4.0/cmath:41,
                 from <source>:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:143:1: note: does not match previous declaration 'double sqrt(double)'
  143 | __MATHCALL (sqrt,, (_Mdouble_ __x));
      | ^~~~~~~~~~
Compiler returned: 1

Due to a bug in GCC versions older than 11.1 SYCL math builtins may
fail to compile when using GCC as the host compiler. To work around this
issue, this commit renames all host-side builtin implementations used
by the SYCL math builtins.

Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
@steffenlarsen steffenlarsen requested a review from a team as a code owner August 25, 2022 15:21
@steffenlarsen steffenlarsen merged commit c786894 into intel:sycl Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants