cms-sw / cmssw

CMS Offline Software
http://cms-sw.github.io/
Apache License 2.0
1.07k stars 4.29k forks source link

Compiling DataFormats/L1Trigger with Apple clang 13 produces error: reference to 'complex' is ambiguous from HLS header. #36821

Open gartung opened 2 years ago

gartung commented 2 years ago

This line is identified in HLS package header ap_fixed_special.h https://github.com/Xilinx/HLS_arbitrary_Precision_Types/blob/200a9aecaadf471592558540dc5a88256cbf880f/include/ap_fixed_special.h#L30 and this line in HLS package header ap_int_special.h https://github.com/Xilinx/HLS_arbitrary_Precision_Types/blob/200a9aecaadf471592558540dc5a88256cbf880f/include/ap_int_special.h#L30

Error message

[ 42%] Building CXX object DataFormats/L1Trigger/CMakeFiles/DataFormatsL1Trigger.dir/DataFormatsL1Trigger_x.cc.o
cd /var/folders/sb/_59sd1t97k149f3mrk_hqhbr0000gp/T/gartung/spack-stage/spack-stage-fwlite-12.2.0-t3luyy7v3r5hpefmdy6iqbmjjdbmqt6h/spack-build-t3luyy7/DataFormats/L1Trigger && /Volumes/Fireworks/spack/lib/spack/env/clang/clang++ -DBOOST_MATH_DISABLE_STD_FPCLASSIFY -DBOOST_SPIRIT_THREADSAFE -DBOOST_UUID_RANDOM_PROVIDER_FORCE_POSIX -DDataFormatsL1Trigger_EXPORTS -DFMT_LOCALE -DPHOENIX_THREADSAFE -DTBB_SUPPRESS_DEPRECATED_MESSAGES -DTBB_USE_GLIBCXX_VERSION=80400 -I/var/folders/sb/_59sd1t97k149f3mrk_hqhbr0000gp/T/gartung/spack-stage/spack-stage-fwlite-12.2.0-t3luyy7v3r5hpefmdy6iqbmjjdbmqt6h/spack-src -I/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/boost-1.77.0-ci6chcjt67nlrvtuwo4eh7efteymkloc/include/python -I/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/md5-cms-1.0.0-yrowgnp3fzlmnggjadnxese4irlqqztm/include -I/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/eigen-3.4.0-ql3rpwuetoe4kp3uyuj7jrkhnyifp766/include/eigen3 -I/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/gsl-2.7-7llx6km5yr4k46w6uptrnfr7w3miqomx/include -I/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/python-3.8.12-m7tbiq6aaifgwtkdhcuw6secmdx6trj6/include/python3.8 -I/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/tinyxml2-6.2.0-tj4sczjvu2ylzjubtsnlwpkojofclits/include -I/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/libuuid-2.32.1-uryjrb6nv2hjm7rhk62vlow5s2adujix/include -I/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/clhep-2.4.4.0-bzju5mleaquhodyvpab6ahjiqoy74bu6/lib/CLHEP-2.4.4.0/../../include -I/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/hls-2019-200a9aecaadf471592558540dc5a88256cbf880f-rmqkximaq3mj2y3ukr4gz6zgsa22btz4/include -isystem /Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/root-6.24.06-uw6d2nikzm4hgdwyjqblwsm6nlc2rwtd/include -isystem /Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/boost-1.77.0-ci6chcjt67nlrvtuwo4eh7efteymkloc/include -isystem /Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/fmt-8.0.1-hihda7juash3miab6c6kx4gprwdxzhtb/include -isystem /Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/intel-tbb-oneapi-2021.3.0-gebwgh6par7gv6tsb4l6aric6bkc2v55/include -std=c++17 -m64 -pipe -fsigned-char -fno-common -Qunused-arguments -pthread -stdlib=libc++ -Wno-attributes -O2 -g -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -fPIC -std=gnu++17 -Os -Wno-unused-variable -MD -MT DataFormats/L1Trigger/CMakeFiles/DataFormatsL1Trigger.dir/DataFormatsL1Trigger_x.cc.o -MF CMakeFiles/DataFormatsL1Trigger.dir/DataFormatsL1Trigger_x.cc.o.d -o CMakeFiles/DataFormatsL1Trigger.dir/DataFormatsL1Trigger_x.cc.o -c /var/folders/sb/_59sd1t97k149f3mrk_hqhbr0000gp/T/gartung/spack-stage/spack-stage-fwlite-12.2.0-t3luyy7v3r5hpefmdy6iqbmjjdbmqt6h/spack-build-t3luyy7/DataFormats/L1Trigger/DataFormatsL1Trigger_x.cc
In file included from /var/folders/sb/_59sd1t97k149f3mrk_hqhbr0000gp/T/gartung/spack-stage/spack-stage-fwlite-12.2.0-t3luyy7v3r5hpefmdy6iqbmjjdbmqt6h/spack-build-t3luyy7/DataFormats/L1Trigger/DataFormatsL1Trigger_x.cc:38:
In file included from /var/folders/sb/_59sd1t97k149f3mrk_hqhbr0000gp/T/gartung/spack-stage/spack-stage-fwlite-12.2.0-t3luyy7v3r5hpefmdy6iqbmjjdbmqt6h/spack-src/DataFormats/L1Trigger/src/classes.h:35:
In file included from /var/folders/sb/_59sd1t97k149f3mrk_hqhbr0000gp/T/gartung/spack-stage/spack-stage-fwlite-12.2.0-t3luyy7v3r5hpefmdy6iqbmjjdbmqt6h/spack-src/DataFormats/L1Trigger/interface/Vertex.h:7:
In file included from /var/folders/sb/_59sd1t97k149f3mrk_hqhbr0000gp/T/gartung/spack-stage/spack-stage-fwlite-12.2.0-t3luyy7v3r5hpefmdy6iqbmjjdbmqt6h/spack-src/DataFormats/L1TrackTrigger/interface/TTTrack.h:18:
In file included from /var/folders/sb/_59sd1t97k149f3mrk_hqhbr0000gp/T/gartung/spack-stage/spack-stage-fwlite-12.2.0-t3luyy7v3r5hpefmdy6iqbmjjdbmqt6h/spack-src/DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h:20:
In file included from /Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/hls-2019-200a9aecaadf471592558540dc5a88256cbf880f-rmqkximaq3mj2y3ukr4gz6zgsa22btz4/include/ap_int.h:327:
In file included from /Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/hls-2019-200a9aecaadf471592558540dc5a88256cbf880f-rmqkximaq3mj2y3ukr4gz6zgsa22btz4/include/ap_fixed.h:356:
/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/hls-2019-200a9aecaadf471592558540dc5a88256cbf880f-rmqkximaq3mj2y3ukr4gz6zgsa22btz4/include/ap_fixed_special.h:60:7: error: reference to 'complex' is ambiguous
class complex<ap_fixed<_AP_W, _AP_I, _AP_Q, _AP_O, _AP_N> > {
      ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/complex:257:28: note: candidate found by name lookup is 'std::__1::complex'
class _LIBCPP_TEMPLATE_VIS complex
                           ^
/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/hls-2019-200a9aecaadf471592558540dc5a88256cbf880f-rmqkximaq3mj2y3ukr4gz6zgsa22btz4/include/ap_fixed_special.h:32:30: note: candidate found by name lookup is 'std::complex'
template<typename _Tp> class complex;
                             ^
/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/hls-2019-200a9aecaadf471592558540dc5a88256cbf880f-rmqkximaq3mj2y3ukr4gz6zgsa22btz4/include/ap_fixed_special.h:193:11: error: reference to 'complex' is ambiguous
    const complex<ap_fixed<_AP_W, _AP_I, _AP_Q, _AP_O, _AP_N> > &__x,
          ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/complex:257:28: note: candidate found by name lookup is 'std::__1::complex'
class _LIBCPP_TEMPLATE_VIS complex
                           ^
/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/hls-2019-200a9aecaadf471592558540dc5a88256cbf880f-rmqkximaq3mj2y3ukr4gz6zgsa22btz4/include/ap_fixed_special.h:32:30: note: candidate found by name lookup is 'std::complex'
template<typename _Tp> class complex;
                             ^
/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/hls-2019-200a9aecaadf471592558540dc5a88256cbf880f-rmqkximaq3mj2y3ukr4gz6zgsa22btz4/include/ap_fixed_special.h:203:11: error: reference to 'complex' is ambiguous
    const complex<ap_fixed<_AP_W, _AP_I, _AP_Q, _AP_O, _AP_N> > &__y) {
          ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/complex:257:28: note: candidate found by name lookup is 'std::__1::complex'
class _LIBCPP_TEMPLATE_VIS complex
                           ^
/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/hls-2019-200a9aecaadf471592558540dc5a88256cbf880f-rmqkximaq3mj2y3ukr4gz6zgsa22btz4/include/ap_fixed_special.h:32:30: note: candidate found by name lookup is 'std::complex'
template<typename _Tp> class complex;
                             ^
/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/hls-2019-200a9aecaadf471592558540dc5a88256cbf880f-rmqkximaq3mj2y3ukr4gz6zgsa22btz4/include/ap_fixed_special.h:211:11: error: reference to 'complex' is ambiguous
    const complex<ap_fixed<_AP_W, _AP_I, _AP_Q, _AP_O, _AP_N> > &__x,
          ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/complex:257:28: note: candidate found by name lookup is 'std::__1::complex'
class _LIBCPP_TEMPLATE_VIS complex
                           ^
/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/hls-2019-200a9aecaadf471592558540dc5a88256cbf880f-rmqkximaq3mj2y3ukr4gz6zgsa22btz4/include/ap_fixed_special.h:32:30: note: candidate found by name lookup is 'std::complex'
template<typename _Tp> class complex;
                             ^
/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/hls-2019-200a9aecaadf471592558540dc5a88256cbf880f-rmqkximaq3mj2y3ukr4gz6zgsa22btz4/include/ap_fixed_special.h:221:16: error: reference to 'complex' is ambiguous
    const std::complex<ap_fixed<_AP_W, _AP_I, _AP_Q, _AP_O, _AP_N> > &__y) {
               ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/complex:257:28: note: candidate found by name lookup is 'std::__1::complex'
class _LIBCPP_TEMPLATE_VIS complex
                           ^
/Volumes/Fireworks/spack/opt/spack/darwin-monterey-skylake/apple-clang-13.0.0/hls-2019-200a9aecaadf471592558540dc5a88256cbf880f-rmqkximaq3mj2y3ukr4gz6zgsa22btz4/include/ap_fixed_special.h:32:30: note: candidate found by name lookup is 'std::complex'
template<typename _Tp> class complex;
                             ^
5 errors generated.
cmsbuild commented 2 years ago

A new Issue was created by @gartung Patrick Gartung.

@Dr15Jones, @perrotta, @dpiparo, @makortel, @smuzaffar, @qliphy can you please review it and eventually sign/assign? Thanks.

cms-bot commands are listed here

makortel commented 2 years ago

assign l1

cmsbuild commented 2 years ago

New categories assigned: l1

@epalencia,@rekovic,@cecilecaillol you have been requested to review this Pull request/Issue and eventually sign? Thanks

makortel commented 2 years ago

https://github.com/Xilinx/HLS_arbitrary_Precision_Types/blob/200a9aecaadf471592558540dc5a88256cbf880f/include/ap_fixed_special.h#L28-L33 has

// FIXME AP_AUTOCC cannot handle many standard headers, so declare instead of
// include.
// #include <complex>
namespace std {
template<typename _Tp> class complex;
}

The C++ standard says that adding declarations to namespace std leads to undefined behavior (whose implications we observe now). If the AP_AUTOCC (whatever that is) can't handle <complex>, would it be possible to add an #ifdef there to use the (non-standard) forward declaration only when compiling with AP_AUTOCC?

Then how should we do that? I see https://github.com/Xilinx/HLS_arbitrary_Precision_Types has last been updated almost 3 years ago, and has no issues or pull requests. We could fork it to cms-externals and patch it there, but I suppose it could be good to inform Xilinx even then.

An alternative would be to remove the use of hls external from DataFormats/L1TrackTrigger (although the undefined behavior might come back to bite us later in the future).