Bug 1589382 - installing both libstdc++-devel.x86_64 and libstdc++-devel.i686 may break ext/stdio_filebuf.h
Summary: installing both libstdc++-devel.x86_64 and libstdc++-devel.i686 may break ext...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-06-08 20:56 UTC by Serguei Makarov
Modified: 2018-08-10 13:57 UTC (History)
12 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2018-08-10 13:57:18 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
.ii file for testcase (707.03 KB, text/plain)
2018-06-11 14:22 UTC, Serguei Makarov
no flags Details
.ii file from second reproduction attempt (754 bytes, text/plain)
2018-06-11 17:25 UTC, Serguei Makarov
no flags Details

Description Serguei Makarov 2018-06-08 20:56:05 UTC
Description of problem:

Programs using __gnu_cxx::stdio_filebuf fail to compile with

Version-Release number of selected component (if applicable):
gcc-c++-8.1.1-1.fc29.x86_64
libstdc++-devel-8.1.1-1.fc29.x86_64
libstdc++-8.1.1-1.fc29.i686

How reproducible:

$ cat >reproducer2.cxx
#include <ext/stdio_filebuf.h>

using namespace std;

int main() {
  __gnu_cxx::stdio_filebuf<char> fb;
}
$ g++ reproducer2.cxx -o reproducer2

Actual results:

/tmp/cc05mWrZ.o:(.rodata._ZTVN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEE[_ZTVN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEE]+0x30): undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::seekoff(long long, std::_Ios_Seekdir, std::_Ios_Openmode)'
collect2: error: ld returned 1 exit status

Expected results:

File compiles without errors.

Additional info:

Comment 1 Jonathan Wakely 2018-06-09 06:56:03 UTC
That missing symbol is not defined by the library, instead it defines:
_ZNSt13basic_filebufIcSt11char_traitsIcEE7seekoffElSt12_Ios_SeekdirSt13_Ios_Openmode

i.e. basic_filebuf<char>::seekoff(long, std::_Ios_Seekdir, std::_Ios_Openmode) with first parameter of long, not long long.

This suggests you've done something odd to your copy of the headers.

Comment 2 Jonathan Wakely 2018-06-09 06:56:57 UTC
Please compile with -save-temps and attach the .ii file here.

Comment 3 Serguei Makarov 2018-06-11 14:22:53 UTC
Created attachment 1450063 [details]
.ii file for testcase

Attaching .ii file from the affected system.

I will install a fresh rawhide VM and double-check that the problem recurs.

Comment 4 Jonathan Wakely 2018-06-11 15:20:10 UTC
Your preprocessed source shows:

# 90 "/usr/include/c++/8/bits/postypes.h" 3
  typedef long long streamoff;

Which comes from this code:

#ifdef _GLIBCXX_HAVE_INT64_T_LONG
  typedef long          streamoff;
#elif defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG)
  typedef long long     streamoff;
#elif defined(_GLIBCXX_HAVE_INT64_T) 
  typedef int64_t       streamoff;
#else
  typedef long long     streamoff;
#endif


On rawhide x86_64 you should have _GLIBCXX_HAVE_INT64_T_LONG defined:

# g++ -E -dM -include ext/stdio_filebuf.h -x c++ /dev/null | fgrep INT64_T_LONG
#define _GLIBCXX_HAVE_INT64_T_LONG 1


So I still think you've messed something up on your system.

Comment 5 Serguei Makarov 2018-06-11 17:23:55 UTC
Thank you for looking into this. I found that conditions to reproduce the problem are more complex, and it has something to do with having both libstdc++-devel.x86_64 and libstdc++-devel.i686 installed on the same system. According to rpm -ql both packages claim to own the file /usr/include/c++/8/ext/stdio_filebuf.h. (The actual problem is in some other header which they include.)

The version of the package for .i686 has:

[root@Fedora-rawhide-64 smakarov]# g++ -E -dM -include ext/stdio_filebuf.h -x c++ /dev/null | fgrep INT64_T_LONG
#define _GLIBCXX_HAVE_INT64_T_LONG_LONG 1

The header file is also owned by both packages on my Fedora 28 machine, but there stdio_filebuf.h contains the correct #define, and everything seems to coexist correctly.

Doing `dnf reinstall libstdc++-devel.x86_64` on the affected Rawhide machine fixed the problem for me. So the issue has a simple if not immediately obvious workaround.

My attempt trying to reproduce the problem on a fresh install only yielded a different error:

- Boot https://kojipkgs.fedoraproject.org/compose/rawhide/Fedora-Rawhide-20180608.n.1/compose/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-Rawhide-20180608.n.1.iso
- dnf update
- dnf install libstdc++-devel.i686
- dnf group install "C Development Tools and Libraries"
- Create reproducer2.cxx and compile it. Fails as follows:

[liveuser@localhost-live ~]$ g++ reproducer2.cxx -o reproducer2 -save-temps
In file included from /usr/include/c++/8/ios:38,
                 from /usr/include/c++/8/istream:38,
                 from /usr/include/c++/8/fstream:38,
                 from /usr/include/c++/8/ext/stdio_filebuf.h:34,
                 from reproducer2.cxx:1:
/usr/include/c++/8/iosfwd:38:10: fatal error: bits/c++config.h: No such file or directory
 #include <bits/c++config.h>
          ^~~~~~~~~~~~~~~~~~
compilation terminated.

(Will attach preprocessed data as error1.ii)

Such a sequence of install steps is strange (a user is more likely to install the native x86_64 development tools first) but as far as I understand not obviously insane / unsupported.

I suspect (but haven't proven yet) that the problem on my original system could have been the result of a similar weird sequence of package installs, or possibly an unlucky dnf update on a system with both packages. I don't recall doing anything to those header files outside of standard dnf install/update operations.

Comment 6 Serguei Makarov 2018-06-11 17:25:15 UTC
Created attachment 1450159 [details]
.ii file from second reproduction attempt

Comment 7 Jakub Jelinek 2018-06-11 17:32:46 UTC
You of course can have just libstdc++-devel.i686 and not libstdc++-devel.x86_64 installed on x86_64 box, but then you shouldn't try to compile 64-bit C++ programs, only 32-bit ones.  If you want both, install both.

Comment 8 Jonathan Wakely 2018-06-11 19:12:34 UTC
You've changed the title to "installing both libstdc++-devel.x86_64 and libstdc++-devel.i686 may break ext/stdio_filebuf.h" but as far as I can tell, you haven't installed both.

If you install libstdc++-devel.i686 first, then the dependencies for the gcc-c++ package and the "C Development Tools and Libraries" group will be satisfied, and so the x86_64 version won't be installed. That explains the error you get: you don't have the 64-bit headers.

The fix is to install libstdc++-devel.x86_64

I still have no idea what your first error was caused by, there should be no sequence of installation steps that can cause it.

Comment 9 Serguei Makarov 2018-06-12 15:23:40 UTC
I am still unable to reproduce this problem on a new rawhide install. There are still peculiarities on the affected system (after doing 'dnf reinstall libstdc++-devel.x86_64', 'rpm -qa' claims 'libstdc++-devel.i686' is no longer installed, even though the reinstall command does not claim to have erased it, the package files are present and both 64-bit and 32-bit compiles use the correct headers) but at this point I've worked around my original problem and it seems whatever sequence of events caused this in the first place is improbable.

Thank you again for looking into this; it would have taken a lot of trial and error on my part to understand what was going on.

Comment 10 Marek Polacek 2018-08-10 13:57:18 UTC
Let's close this, then.


Note You need to log in before you can comment on or make changes to this bug.