public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/109108] New: d: Undefined reference to lambda in private enum
@ 2023-03-12 14:52 ibuclaw at gcc dot gnu.org
  2023-03-14 18:16 ` [Bug d/109108] " cvs-commit at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ibuclaw at gcc dot gnu.org @ 2023-03-12 14:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109108
           Summary: d: Undefined reference to lambda in private enum
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: ibuclaw at gcc dot gnu.org
  Target Milestone: ---

Similar to pr108055.  Lambdas should be emitted in every module they are
referenced from.

```
import other;
void main()
{
    auto a = callFun(1);
}
```

```
private enum int function(ref int)[] funs =
[
    0: (ref idx) => 0,
    1: (ref idx) => 1,
];

int callFun(I)(I idx)
{
    return funs[idx](idx);
}
```

Only compiling the "main" module results in linker errors.
---
$ gdc test.d -Wl,--demangle=dlang
/usr/x86_64-pc-linux-gnu/bin/ld: /tmp/ccDW8iNw.o: in function
`other.callFun!(int).callFun(int)':
test.d:(.text+0x4b): undefined reference to
`other.__lambda4!(int).__lambda4(ref int)'
test.d:(.text+0x56): undefined reference to
`other.__lambda5!(int).__lambda5(ref int)'
collect2: error: ld returned 1 exit status

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

* [Bug d/109108] d: Undefined reference to lambda in private enum
  2023-03-12 14:52 [Bug d/109108] New: d: Undefined reference to lambda in private enum ibuclaw at gcc dot gnu.org
@ 2023-03-14 18:16 ` cvs-commit at gcc dot gnu.org
  2023-03-14 19:11 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-14 18:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:423d34f61c43e400f0d5b837fe93c83963b2ecdd

commit r13-6668-g423d34f61c43e400f0d5b837fe93c83963b2ecdd
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Tue Mar 14 13:16:11 2023 +0100

    d: Fix undefined reference to lambda defined in private enum [PR109108]

    Previously lambdas were connected to the module they were defined in.
    Now they are emitted into every referencing compilation unit, and are
    given one-only linkage.

            PR d/109108

    gcc/d/ChangeLog:

            * decl.cc (function_defined_in_root_p): Remove.
            (get_symbol_decl): Set DECL_LAMBDA_FUNCTION_P on function literals.
            (start_function): Unconditionally unset DECL_EXTERNAL
            (set_linkage_for_decl): Give lambda functions one-only linkage.

    gcc/testsuite/ChangeLog:

            * gdc.dg/torture/imports/pr109108.d: New test.
            * gdc.dg/torture/pr109108.d: New test.

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

* [Bug d/109108] d: Undefined reference to lambda in private enum
  2023-03-12 14:52 [Bug d/109108] New: d: Undefined reference to lambda in private enum ibuclaw at gcc dot gnu.org
  2023-03-14 18:16 ` [Bug d/109108] " cvs-commit at gcc dot gnu.org
@ 2023-03-14 19:11 ` cvs-commit at gcc dot gnu.org
  2023-03-14 19:55 ` cvs-commit at gcc dot gnu.org
  2023-03-14 20:18 ` ibuclaw at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-14 19:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:0dcfd68b2a8369b647650bb68ff612cad3b33ac9

commit r12-9252-g0dcfd68b2a8369b647650bb68ff612cad3b33ac9
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Tue Mar 14 13:16:11 2023 +0100

    d: Fix undefined reference to lambda defined in private enum [PR109108]

    Previously lambdas were connected to the module they were defined in.
    Now they are emitted into every referencing compilation unit, and are
    given one-only linkage.

            PR d/109108

    gcc/d/ChangeLog:

            * decl.cc (function_defined_in_root_p): Remove.
            (get_symbol_decl): Set DECL_LAMBDA_FUNCTION_P on function literals.
            (start_function): Unconditionally unset DECL_EXTERNAL
            (set_linkage_for_decl): Give lambda functions one-only linkage.

    gcc/testsuite/ChangeLog:

            * gdc.dg/torture/imports/pr109108.d: New test.
            * gdc.dg/torture/pr109108.d: New test.

    (cherry picked from commit 423d34f61c43e400f0d5b837fe93c83963b2ecdd)

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

* [Bug d/109108] d: Undefined reference to lambda in private enum
  2023-03-12 14:52 [Bug d/109108] New: d: Undefined reference to lambda in private enum ibuclaw at gcc dot gnu.org
  2023-03-14 18:16 ` [Bug d/109108] " cvs-commit at gcc dot gnu.org
  2023-03-14 19:11 ` cvs-commit at gcc dot gnu.org
@ 2023-03-14 19:55 ` cvs-commit at gcc dot gnu.org
  2023-03-14 20:18 ` ibuclaw at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-14 19:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:bd109dee471aa83f2397a6b56d074583c48475c7

commit r11-10575-gbd109dee471aa83f2397a6b56d074583c48475c7
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Tue Mar 14 13:16:11 2023 +0100

    d: Fix undefined reference to lambda defined in private enum [PR109108]

    Previously lambdas were connected to the module they were defined in.
    Now they are emitted into every referencing compilation unit, and are
    given one-only linkage.

            PR d/109108

    gcc/d/ChangeLog:

            * decl.cc (get_symbol_decl): Set DECL_LAMBDA_FUNCTION_P on function
            literals.
            (start_function): Unconditionally unset DECL_EXTERNAL.
            (set_linkage_for_decl): Give lambda functions one-only linkage.

    gcc/testsuite/ChangeLog:

            * gdc.dg/torture/torture.exp (srcdir): New proc.
            * gdc.dg/torture/imports/pr109108.d: New test.
            * gdc.dg/torture/pr109108.d: New test.

    (cherry picked from commit 423d34f61c43e400f0d5b837fe93c83963b2ecdd)

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

* [Bug d/109108] d: Undefined reference to lambda in private enum
  2023-03-12 14:52 [Bug d/109108] New: d: Undefined reference to lambda in private enum ibuclaw at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-03-14 19:55 ` cvs-commit at gcc dot gnu.org
@ 2023-03-14 20:18 ` ibuclaw at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ibuclaw at gcc dot gnu.org @ 2023-03-14 20:18 UTC (permalink / raw)
  To: gcc-bugs

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

ibuclaw at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #4 from ibuclaw at gcc dot gnu.org ---
Fix committed and backported.

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

end of thread, other threads:[~2023-03-14 20:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-12 14:52 [Bug d/109108] New: d: Undefined reference to lambda in private enum ibuclaw at gcc dot gnu.org
2023-03-14 18:16 ` [Bug d/109108] " cvs-commit at gcc dot gnu.org
2023-03-14 19:11 ` cvs-commit at gcc dot gnu.org
2023-03-14 19:55 ` cvs-commit at gcc dot gnu.org
2023-03-14 20:18 ` ibuclaw 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).