[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#944380: GDC generates duplicate symbols when using mixins/interfaces



On 09/11/2019 17:05, Matthias Klose wrote:
> 
> On 09.11.19 16:53, Matthias Klumpp wrote:
>> Am Sa., 9. Nov. 2019 um 16:04 Uhr schrieb Matthias Klose <doko@debian.org>:
>>>
>>> Control: found -1 9.2.1-16
>>> Control: severity -1 important
>>>
>>> according to the upstream report, also with 9.2.0.
>>>
>>> On 08.11.19 23:18, Matthias Klumpp wrote:
>>>> Package: gdc-9
>>>> Version: 9.2.1-17
>>>> Severity: serious
>>>>
>>>> Hi!
>>>> Currently, GDC can't build package like gtk-d because it generates
>>>> duplicate non-weak symbols in object files, causing a collision when
>>>> linking. This seems to happen when using mixins / interfaces.
>>>> For more information and a workaround, please check the upstream bug report.
>>>
>>> if there's a workaround, please don't set the severity to serious.
>>
>> The workaround needs to be applied to GDC, there is nothing we can do
>> in the affected packages. I also haven't tested the workaround and it
>> doesn't look like a good solution to me.
>> So, since this is breaking other packages, a high severity seemed justified.
> 
> Ahh, ok, that wasn't clear to me from the initial report.  Anyway, the issue is 
> present in testing as well, so lets wait for a reply from upstream.
> 

Hi, this patch is fine for the reduced test raised in gcc-bugzilla.

I'll commit it to mainline, but would be interested to know if it addresses the wider gtk-d problem.

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 3824060feb9..7afb1aa0292 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -1803,8 +1803,11 @@ make_thunk (FuncDeclaration *decl, int offset)

   DECL_CONTEXT (thunk) = d_decl_context (decl);

-  /* Thunks inherit the public access of the function they are targetting.  */
-  TREE_PUBLIC (thunk) = TREE_PUBLIC (function);
+  /* Thunks inherit the public access of the function they are targetting.
+     When the function is outside the current compilation unit however, then the
+     thunk must be kept private to not conflict.  */
+  TREE_PUBLIC (thunk) = TREE_PUBLIC (function) && !DECL_EXTERNAL (function);
+
   DECL_EXTERNAL (thunk) = 0;

   /* Thunks are always addressable.  */


Reply to: