public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/104317] New: D language: rt.config module doesn't work as expected in GDC 9/10 (multiple definition linker error)
@ 2022-02-01 0:30 siarhei.siamashka at gmail dot com
2022-02-01 0:35 ` [Bug d/104317] " siarhei.siamashka at gmail dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: siarhei.siamashka at gmail dot com @ 2022-02-01 0:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104317
Bug ID: 104317
Summary: D language: rt.config module doesn't work as expected
in GDC 9/10 (multiple definition linker error)
Product: gcc
Version: 10.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: d
Assignee: ibuclaw at gdcproject dot org
Reporter: siarhei.siamashka at gmail dot com
Target Milestone: ---
The rt.config module provides a set of configuration variables with various
ways to override them as documented here:
https://dlang.org/phobos/rt_config.html
The following small application can be used to test it:
import std.stdio;
extern(C) __gshared bool rt_cmdline_enabled = false;
void main(string[] args) { writeln(args); }
== Expected correct result: ==
$ gdc test.d && ./a.out --DRT-this-cmdline-argument-should-not-be-filtered-out
["./a.out", "--DRT-this-cmdline-argument-should-not-be-filtered-out"]
== Got: ==
$ gdc-9.3.0 test.d
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/libgdruntime.a(lt8-config.o):/var/tmp/portage/sys-devel/gcc-9.3.0-r1/work/gcc-9.3.0/libphobos/libdruntime/rt/config.d:48:
multiple definition of `rt_cmdline_enabled'; /tmp/ccvDzGs7.o:(.bss+0x0): first
defined here
collect2: error: ld returned 1 exit status
$ gdc-12.0.1 test.d && ./a.out
--DRT-this-cmdline-argument-should-not-be-filtered-out
["./a.out", "--DRT-this-cmdline-argument-should-not-be-filtered-out"]
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug d/104317] D language: rt.config module doesn't work as expected in GDC 9/10 (multiple definition linker error)
2022-02-01 0:30 [Bug d/104317] New: D language: rt.config module doesn't work as expected in GDC 9/10 (multiple definition linker error) siarhei.siamashka at gmail dot com
@ 2022-02-01 0:35 ` siarhei.siamashka at gmail dot com
2022-02-01 1:08 ` siarhei.siamashka at gmail dot com
2022-08-09 19:26 ` ibuclaw at gdcproject dot org
2 siblings, 0 replies; 4+ messages in thread
From: siarhei.siamashka at gmail dot com @ 2022-02-01 0:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104317
--- Comment #1 from Siarhei Siamashka <siarhei.siamashka at gmail dot com> ---
An attempted fix for the linker error had been introduced in GDC11 via:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99914
But it made function templates non-inlineable as a side effect:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102765
Also cmdline arguments with "--DRT-" prefix are still incorrectly filtered out:
$ gdc-11.2.0 test.d && ./a.out
--DRT-this-cmdline-argument-should-not-be-filtered-out
["./a.out"]
It would be useful to have a better fix for this problem.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug d/104317] D language: rt.config module doesn't work as expected in GDC 9/10 (multiple definition linker error)
2022-02-01 0:30 [Bug d/104317] New: D language: rt.config module doesn't work as expected in GDC 9/10 (multiple definition linker error) siarhei.siamashka at gmail dot com
2022-02-01 0:35 ` [Bug d/104317] " siarhei.siamashka at gmail dot com
@ 2022-02-01 1:08 ` siarhei.siamashka at gmail dot com
2022-08-09 19:26 ` ibuclaw at gdcproject dot org
2 siblings, 0 replies; 4+ messages in thread
From: siarhei.siamashka at gmail dot com @ 2022-02-01 1:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104317
Siarhei Siamashka <siarhei.siamashka at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |siarhei.siamashka at gmail dot com
--- Comment #2 from Siarhei Siamashka <siarhei.siamashka at gmail dot com> ---
Created attachment 52322
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52322&action=edit
proof of concept patch for gdc10
The attached proof of concept patch for GDC10 fixes the problem in a much less
invasive way. The idea is to just use weak attributes for global variables in
druntime instead of enclosing them in a "template {}" block.
A preliminary pull request for upstream druntime is tracked here:
https://github.com/dlang/druntime/pull/3716
The same simple fix also works fine for GDC11 if we undo PR99914:
https://gist.github.com/ssvb/d8a67fb445e96f9e66d0516a3ba62475
I first tried to toggle "flag_weak_templates" in "gcc/d/lang.opt" from 1 to 0
in GDC11 instead of reverting PR99914, but the resulting toolchain was unable
to compile and link even the most simple applications due to missing symbols
from Phobos.
The part preventing undesirable removal of cmdline arguments is cherry picked
from:
https://github.com/dlang/druntime/commit/ae9581c1e4b96de6707c71eb45dcc9c10dd4d402
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug d/104317] D language: rt.config module doesn't work as expected in GDC 9/10 (multiple definition linker error)
2022-02-01 0:30 [Bug d/104317] New: D language: rt.config module doesn't work as expected in GDC 9/10 (multiple definition linker error) siarhei.siamashka at gmail dot com
2022-02-01 0:35 ` [Bug d/104317] " siarhei.siamashka at gmail dot com
2022-02-01 1:08 ` siarhei.siamashka at gmail dot com
@ 2022-08-09 19:26 ` ibuclaw at gdcproject dot org
2 siblings, 0 replies; 4+ messages in thread
From: ibuclaw at gdcproject dot org @ 2022-08-09 19:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104317
--- Comment #3 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
(In reply to Siarhei Siamashka from comment #2)
> I first tried to toggle "flag_weak_templates" in "gcc/d/lang.opt" from 1 to
> 0 in GDC11 instead of reverting PR99914, but the resulting toolchain was
> unable to compile and link even the most simple applications due to missing
> symbols from Phobos.
>
r13-2002 (and r12-8673) is a start that sows the seeds to make the codegen
option -fno-weak-templates the default. Should just be a case of extending the
forced emission to all instantiations too.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-08-09 19:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-01 0:30 [Bug d/104317] New: D language: rt.config module doesn't work as expected in GDC 9/10 (multiple definition linker error) siarhei.siamashka at gmail dot com
2022-02-01 0:35 ` [Bug d/104317] " siarhei.siamashka at gmail dot com
2022-02-01 1:08 ` siarhei.siamashka at gmail dot com
2022-08-09 19:26 ` ibuclaw at gdcproject dot 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).