DevHeads.net

gcc-c++ and libatomic -- link issues

Hi,

I maintain the hpx package and it uses std:atomic and when I install
gcc-c++ it seems that libatomic is not a dependency of the gcc-c++
package. My program fails, because it can not link against libatomic. Is
this the supposed behavior to install libatomic or should libatomic
become one of the dependencies of gcc-c++?

Best,

Patrick

Comments

Re: gcc-c++ and libatomic -- link issues

By Jonathan Wakely at 02/11/2019 - 07:04

On 08/02/19 19:56 -0600, Patrick Diehl wrote:
Not all C++ programs need libatomic. If hpx needs it, I think you
should require it explicitly.

Re: gcc-c++ and libatomic -- link issues

By Florian Weimer at 02/11/2019 - 07:14

* Jonathan Wakely:

Not all C++ programs need libstdc++ or librt. Yet both are available by
default.

What's the benefit of not installing libatomic as a dependency of
gcc-c++?

Thanks,
Florian

Re: gcc-c++ and libatomic -- link issues

By Jonathan Wakely at 02/11/2019 - 07:22

On 11/02/19 12:14 +0100, Florian Weimer wrote:
True.

None that I know of. It would mean that certain things Just Work™.

Re: gcc-c++ and libatomic -- link issues

By Jakub Jelinek at 02/11/2019 - 07:20

On Mon, Feb 11, 2019 at 12:14:10PM +0100, Florian Weimer wrote:
Don't know why you are mentioning librt, gcc-c++ nor libstdc++ don't have a
dependency on librt, either rpm or DT_NEEDED.
You have to try hard to avoid libstdc++, that is what you get by default,
one needs to use -nostdinc, link with gcc instead of g++, usually disable
rtti/exceptions etc. or link with -lsupc++ (which is in libstdc++-devel
anyway).

Compared to that, most of the C++ programs don't need libatomic, most of
them don't need libitm, etc. So, why force it upon everybody when only
0.05% will need it?

Jakub

Re: gcc-c++ and libatomic -- link issues

By Jonathan Wakely at 02/12/2019 - 05:49

On 11/02/19 12:20 +0100, Jakub Jelinek wrote:
On that basis, why does gcc-c++ install libgomp and libgfortran?

libatomic might be needed for some uses of std::atomic, but nothing in
ISO C++ requires OpenMP or Fortran.

Re: gcc-c++ and libatomic -- link issues

By Jakub Jelinek at 02/12/2019 - 05:55

On Tue, Feb 12, 2019 at 09:49:23AM +0000, Jonathan Wakely wrote:
I think gcc-c++ doesn't require libgfortran, gcc-gfortran does.

The reason to have libgomp in the dependencies was that it is a library that
isn't explicitly used on the command line, while to link against libatomic
you need to specify -latomic and so, like for any other random library you
need to make sure that the library is installed, one doesn't need to specify
-lgomp, simply linking with -fopenmp needs that library.

Though, I admit that the sanitizer libraries behave like libgomp, yet they
aren't required by default (on the other side, those are development
instrumentation libraries).

Jakub

Re: gcc-c++ and libatomic -- link issues

By Jonathan Wakely at 02/12/2019 - 07:47

On 12/02/19 10:55 +0100, Jakub Jelinek wrote:
Ah yes, sorry. I ran 'mock -r fedora-rawhide-x86_64 --install gcc-c++'
and saw it installing libgfortran, but actually it was already
installed (because of an earlier BuildRequires seen in the mock
chroot) and it was upgrading it because gcc-c++ was being upgraded.

OK, that's logical.