public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114229] New: [modules] duplicate symbols when including stl in submodule
@ 2024-03-04 16:42 nickbegg at gmail dot com
  2024-03-04 16:48 ` [Bug c++/114229] " nickbegg at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: nickbegg at gmail dot com @ 2024-03-04 16:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114229

            Bug ID: 114229
           Summary: [modules] duplicate symbols when including stl in
                    submodule
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nickbegg at gmail dot com
  Target Milestone: ---

using the same test src code as PR113930 -

// submod.mpp

module;

#include <iostream>

export module modA:submod;

// modA.mpp

module;

export module modA;

export import :submod;

// main.cpp

#include <string>

import modA;

std::string test_func() {
    return "";
}

Note that this test code causes #113930 to check in a GCC debug build.
With a GCC release build, at link time numerous STL symbols become duplicated -

% /home/nick/inst/gcc-trunk-release/bin/g++ -freport-bug -g
CMakeFiles/moduleMin.dir/main.cpp.o CMakeFiles/moduleMin.dir/submod.mpp.o
CMakeFiles/moduleMin.dir/modA.mpp.o -o moduleMin

/usr/bin/ld: CMakeFiles/moduleMin.dir/modA.mpp.o:(.rodata+0x40): multiple
definition of `vtable for std::basic_ios<wchar_t, std::char_traits<wchar_t> >';
CMakeFiles/moduleMin.dir/main.cpp.o:(.rodata+0x950): first defined here
/usr/bin/ld: CMakeFiles/moduleMin.dir/modA.mpp.o:(.rodata+0x60): multiple
definition of `vtable for std::basic_ostream<wchar_t, std::char_traits<wchar_t>
>'; CMakeFiles/moduleMin.dir/main.cpp.o:(.rodata+0x8f0): first defined here
/usr/bin/ld: CMakeFiles/moduleMin.dir/modA.mpp.o:(.rodata+0xb0): multiple
definition of `VTT for std::basic_ostream<wchar_t, std::char_traits<wchar_t>
>'; CMakeFiles/moduleMin.dir/main.cpp.o:(.rodata+0x940): first defined here
/usr/bin/ld: CMakeFiles/moduleMin.dir/modA.mpp.o:(.rodata+0xc0): multiple
definition of `vtable for std::basic_istream<wchar_t, std::char_traits<wchar_t>
>'; CMakeFiles/moduleMin.dir/main.cpp.o:(.rodata+0x740): first defined here

[snip]

Note that #including <iostream> in both places (rather than string in main.cpp)
resolves the issue - Is the include guard mechanism failing?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/114229] [modules] duplicate symbols when including stl in submodule
  2024-03-04 16:42 [Bug c++/114229] New: [modules] duplicate symbols when including stl in submodule nickbegg at gmail dot com
@ 2024-03-04 16:48 ` nickbegg at gmail dot com
  2024-03-05 19:52 ` ppalka at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: nickbegg at gmail dot com @ 2024-03-04 16:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114229

--- Comment #1 from Nick Begg <nickbegg at gmail dot com> ---
gcc (GCC) 14.0.1 20240301 (experimental)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/114229] [modules] duplicate symbols when including stl in submodule
  2024-03-04 16:42 [Bug c++/114229] New: [modules] duplicate symbols when including stl in submodule nickbegg at gmail dot com
  2024-03-04 16:48 ` [Bug c++/114229] " nickbegg at gmail dot com
@ 2024-03-05 19:52 ` ppalka at gcc dot gnu.org
  2024-03-05 20:25 ` [Bug c++/114229] [modules] duplicate vtable " ppalka at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-05 19:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114229

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=112820
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-03-05
      Known to fail|                            |13.2.0, 14.0
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed, thanks for the bug report.  Reduced (needs -fno-module-lazy):

$ cat 114229_a.C
module;
template<class> struct basic_streambuf { virtual void overflow() { } };
extern template struct basic_streambuf<long>;
export module modA;
export basic_streambuf<long> *p;

$ cat 114229_b.C
export module modB;
import modA;

$ cat 114229_c.C
import modA;
import modB;
int main() { }

$ cat 114229_d.C
template<class> struct basic_streambuf { virtual void overflow() { } };
template struct basic_streambuf<long>;

$ g++ -Wno-global-module -fmodules-ts -fno-module-lazy 114229_*.C
/usr/bin/ld: /tmp/ccNDPhFZ.o:(.rodata+0x0): multiple definition of `vtable for
basic_streambuf<long>'; /tmp/ccW7B4xy.o:(.rodata+0x0): first defined here

PR112820 also was extern template related.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/114229] [modules] duplicate vtable symbols when including stl in submodule
  2024-03-04 16:42 [Bug c++/114229] New: [modules] duplicate symbols when including stl in submodule nickbegg at gmail dot com
  2024-03-04 16:48 ` [Bug c++/114229] " nickbegg at gmail dot com
  2024-03-05 19:52 ` ppalka at gcc dot gnu.org
@ 2024-03-05 20:25 ` ppalka at gcc dot gnu.org
  2024-03-07 22:02 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-05 20:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114229

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
In the reduced testcase the vtable for basic_streambuf<long> should get emitted
only from 114229_d but it seems to get emitted from 114229_b too.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/114229] [modules] duplicate vtable symbols when including stl in submodule
  2024-03-04 16:42 [Bug c++/114229] New: [modules] duplicate symbols when including stl in submodule nickbegg at gmail dot com
                   ` (2 preceding siblings ...)
  2024-03-05 20:25 ` [Bug c++/114229] [modules] duplicate vtable " ppalka at gcc dot gnu.org
@ 2024-03-07 22:02 ` cvs-commit at gcc dot gnu.org
  2024-03-07 22:05 ` nshead at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-07 22:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114229

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathaniel Shead <nshead@gcc.gnu.org>:

https://gcc.gnu.org/g:9ccd03dee4c35a24c6699a58a7251a5277a91cf5

commit r14-9375-g9ccd03dee4c35a24c6699a58a7251a5277a91cf5
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date:   Thu Mar 7 23:09:03 2024 +1100

    c++: Redetermine whether to write vtables on stream-in [PR114229]

    We currently always stream DECL_INTERFACE_KNOWN, which is needed since
    many kinds of declarations already have their interface determined at
    parse time.  But for vtables and type-info declarations we need to
    re-evaluate on stream-in as whether they need to be emitted or not
    changes in each TU, so this patch clears DECL_INTERFACE_KNOWN on these
    kinds of declarations so that they can go through 'import_export_decl'
    again.

    Note that the precise details of the virt-2 tests will need to change
    when we implement the resolution of [1], for now I just updated the test
    to not fail with the new (current) semantics.

    [1]: https://github.com/itanium-cxx-abi/cxx-abi/pull/171

            PR c++/114229

    gcc/cp/ChangeLog:

            * module.cc (trees_out::core_bools): Redetermine
            DECL_INTERFACE_KNOWN on stream-in for vtables and tinfo.
            * decl2.cc (import_export_decl): Add fixme for ABI changes with
            module vtables and tinfo.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/virt-2_b.C: Update test to acknowledge that we
            now emit vtables here too.
            * g++.dg/modules/virt-3_a.C: New test.
            * g++.dg/modules/virt-3_b.C: New test.
            * g++.dg/modules/virt-3_c.C: New test.
            * g++.dg/modules/virt-3_d.C: New test.

    Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/114229] [modules] duplicate vtable symbols when including stl in submodule
  2024-03-04 16:42 [Bug c++/114229] New: [modules] duplicate symbols when including stl in submodule nickbegg at gmail dot com
                   ` (3 preceding siblings ...)
  2024-03-07 22:02 ` cvs-commit at gcc dot gnu.org
@ 2024-03-07 22:05 ` nshead at gcc dot gnu.org
  2024-03-07 23:04 ` nickbegg at gmail dot com
  2024-03-08 15:49 ` ppalka at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-03-07 22:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114229

Nathaniel Shead <nshead at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |nshead at gcc dot gnu.org
   Target Milestone|---                         |14.0
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |nshead at gcc dot gnu.org

--- Comment #5 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Fixed for GCC 14.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/114229] [modules] duplicate vtable symbols when including stl in submodule
  2024-03-04 16:42 [Bug c++/114229] New: [modules] duplicate symbols when including stl in submodule nickbegg at gmail dot com
                   ` (4 preceding siblings ...)
  2024-03-07 22:05 ` nshead at gcc dot gnu.org
@ 2024-03-07 23:04 ` nickbegg at gmail dot com
  2024-03-08 15:49 ` ppalka at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: nickbegg at gmail dot com @ 2024-03-07 23:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114229

--- Comment #6 from Nick Begg <nickbegg at gmail dot com> ---
Looks good - my test code compiles ok.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/114229] [modules] duplicate vtable symbols when including stl in submodule
  2024-03-04 16:42 [Bug c++/114229] New: [modules] duplicate symbols when including stl in submodule nickbegg at gmail dot com
                   ` (5 preceding siblings ...)
  2024-03-07 23:04 ` nickbegg at gmail dot com
@ 2024-03-08 15:49 ` ppalka at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-08 15:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114229

--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 113930 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-03-08 15:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-04 16:42 [Bug c++/114229] New: [modules] duplicate symbols when including stl in submodule nickbegg at gmail dot com
2024-03-04 16:48 ` [Bug c++/114229] " nickbegg at gmail dot com
2024-03-05 19:52 ` ppalka at gcc dot gnu.org
2024-03-05 20:25 ` [Bug c++/114229] [modules] duplicate vtable " ppalka at gcc dot gnu.org
2024-03-07 22:02 ` cvs-commit at gcc dot gnu.org
2024-03-07 22:05 ` nshead at gcc dot gnu.org
2024-03-07 23:04 ` nickbegg at gmail dot com
2024-03-08 15:49 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).