Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::pair<double, double> EghtPointSolid::vertex(int which) const: gcc-10.1+ with C++17 warns a lot on aarch64 #1043

Closed
wdconinc opened this issue Jan 17, 2023 · 11 comments · Fixed by #1048
Labels

Comments

@wdconinc
Copy link
Contributor

  • OS version: ubuntu
  • Compiler version: gcc-12.2.0
  • Package version: dd4hep-1.23
  • Goal: use DD4hep in Mac M1/M2 stacks
  • Reproduced by: exact steps to reproduce the problem: checkout, setup environment (Geant4/ROOT version, LCG/iLCSoft/Key4hep release), cmake, build, run...
    • This is a rather heavy minimal example since it requires building a whole HEP stack on aarch64... which I do in qemu and takes many hours...

The issue is in Shapes.h, which is included indirectly in all user classes through Detector.h. That results in warnings such as:

#42 27.11 In file included from /usr/._local/pngv3ezdlqpfj7bpyjk3r2usgmgqukvs/include/DD4hep/Detector.h:22,
#42 27.11                  from /usr/._local/pngv3ezdlqpfj7bpyjk3r2usgmgqukvs/include/XML/Helper.h:18,
#42 27.11                  from /usr/._local/pngv3ezdlqpfj7bpyjk3r2usgmgqukvs/include/DD4hep/DetFactoryHelper.h:18,
#42 27.11                  from /tmp/det/src/FieldMapBrBz.cpp:4:
#42 27.11 /usr/._local/pngv3ezdlqpfj7bpyjk3r2usgmgqukvs/include/DD4hep/Shapes.h: In member function ‘std::pair<double, double> dd4hep::EightPointSolid::vertex(int) const’:
#42 27.11 /usr/._local/pngv3ezdlqpfj7bpyjk3r2usgmgqukvs/include/DD4hep/Shapes.h:1758:57: note: parameter passing for argument of type ‘std::pair<double, double>’ when C++17 is enabled changed to match C++14 in GCC 10.1
#42 27.11  1758 |     std::pair<double, double> vertex(int which) const   {
#42 27.11       |                                                         ^

The underlying issue is https://gcc.gnu.org/gcc-10/changes.html#empty_base (which aarch64 started warning about in gcc-12.2, https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=b243ad1afb7f06ef4ab7649600d900b09b9c6b52). I'm not sure what to do about the call (or whether to just shut it up with a pragma to -Wno-psabi for those lines), but it's very noisy since it emits a warning for every detector plugin :-)

@wdconinc wdconinc added the bug label Jan 17, 2023
@wdconinc
Copy link
Contributor Author

which aarch64 started warning about in gcc-12.2

Not exactly the right commit, but it points to the code where gcc emits the warning.

@MarkusFrankATcernch
Copy link
Contributor

This is a very bizarre warning.
Yes a fix would probably be to enclose this very function in something like:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wno-psabi"
    std::pair<double, double> vertex(int which) const   {
      const double* values = access()->GetVertices();
      return std::make_pair(values[2*which], values[2*which+1]);
    }
#pragma GCC diagnostic pop

But I do not understand the reasoning: a problem would only arise if code with different ABI standards would be mixed...
One question is if the warning arises from the inline code (then we could move this code to the cpp) or already from the function declaration. In the header I do not really like the #pragma statements, in the cpp it would be tolerable....
We unfortunately also do not really have a testbed for the aarch64 configuration.

@wdconinc
Copy link
Contributor Author

We unfortunately also do not really have a testbed for the aarch64 configuration.

I'm with you there: I don't have an aarch64 system either :-) All that is on qemu for me... very... very... slowly... (fortunately most of the time it runs just fine on its own on a build farm).

I agree it's a strange warning and not really a problem, per se. But it may prevent people from running with -Wall -Werror. I'll try some more things. It is likely that a return type of std::tuple<double,double> does not have the same issue, but it would be an API change and be slightly less performant.

@MarkusFrankATcernch
Copy link
Contributor

First of all, this is a temporary issue and probably will disappear in a few GCC versions ahead.
Secondly I would suggest to ignore this warning until someone really faces the problem in real ie. is directly affected.

Then we rethink and try to solve together with the guy the problem. I am simply against solving problems which may appear at some time in the future..... At this very moment also the question of the testbed is solved.
BTW. How do you know that this is causing these warnings ? Perhaps you are already our volunteer ;-D

@andresailer
Copy link
Member

If these kind of changes only happen when new major versions are release (there are no .0 releases?), we don't run into these issues, because everything in our communities is always compiled with the same major version of a compiler, right?

@MarkusFrankATcernch
Copy link
Contributor

I was yesterday building on ubuntu with gcc-12 (12.1.0) and I did not see any of these warnings.
There must be something else in addition.......

@andresailer
Copy link
Member

ubuntu on aarch64?

@andresailer
Copy link
Member

PS: we are building DD4hep on aarch64 for the lcg stacks, e.g.: /cvmfs/sft.cern.ch/lcg/nightlies/dev4/Tue/DD4hep/01.23/aarch64-centos7-gcc11-opt/logs/DD4hep-01.23-build.log

@wdconinc
Copy link
Contributor Author

DD4hep on aarch64 for the lcg stacks

I notice the same warning in those logs too.

@andresailer
Copy link
Member

Yes, but we don't monitor those logs for warnings. And the question is still, if we can just -Wno-psabi in DD4hep because we don't expect to mix compiler versions or standards. I expect other things to fail long before you run into the ABI incompatibility in that case.

@wdconinc
Copy link
Contributor Author

I think -Wno-psabi as a (gcc-only?) flag in DD4hep would be fine. I'm indeed not worried about actual ABI incompatibility, only about the number of warnings which might mask other warnings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants