[Bug d/87864] libdruntime doesn't link with /bin/ld before Solaris 11.4

2019-02-14 Thread ro at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87864

Rainer Orth  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #11 from Rainer Orth  ---
Fixed for GCC 9.1.

[Bug d/87864] libdruntime doesn't link with /bin/ld before Solaris 11.4

2019-02-14 Thread ro at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87864

--- Comment #10 from Rainer Orth  ---
Author: ro
Date: Thu Feb 14 17:47:49 2019
New Revision: 268886

URL: https://gcc.gnu.org/viewcvs?rev=268886=gcc=rev
Log:
Provide __start_minfo/__stop_minfo for linkers that don't (PR d/87864)

libphobos:
PR d/87864
* configure.ac (DRTSTUFF_SPEC): New variable.
Substitute it.
* libdruntime/m4/druntime/os.m4 (DRUNTIME_OS_MINFO_BRACKETING):
New automake conditional.
* configure: Regenerate.
* libdruntime/gcc/drtstuff.c: New file.
* libdruntime/Makefile.am [!DRUNTIME_OS_MINFO_BRACKETING]
(DRTSTUFF, toolexeclib_DATA): New variables.
(gcc/drtbegin.lo, gcc/drtend.lo): New rules.
(libgdruntime_la_LDFLAGS): Use -Wc instead of -Xcompiler.
Add -dstartfiles -B../src -Bgcc.
(libgdruntime_la_DEPENDENCIES): New variable.
(unittest_static_LDFLAGS): Use -Wc instead of -Xcompiler.
(libgdruntime_t_la_LDFLAGS): Likewise.
(unittest_LDFLAGS): Likewise.
* src/Makefile.am (libgphobos_la_LDFLAGS): Use -Wc instead of
-Xcompiler.
Add -dstartfiles -B../libdruntime/gcc.
(unittest_static_LDFLAGS): Use -Wc instead of -Xcompiler.
(libgphobos_t_la_LDFLAGS): Likewise.
(unittest_LDFLAGS): Likewise.
* libdruntime/Makefile.in, src/Makefile.in: Regenerate.
* Makefile.in, testsuite/Makefile.in: Regenerate.
* libdruntime/rt/sections_elf_shared.d (Minfo_Bracketing): Don't
assert.
* libdruntime/gcc/config.d.in (Minfo_Bracketing): Remove.
* src/drtstuff.spec: New file.
* src/libgphobos.spec.in (DRTSTUFF_SPEC): Substitute.
(*lib): Only pass SPEC_PHOBOS_DEPS without -debuglib, -defaultlib,
-nophoboslib.
* testsuite/testsuite_flags.in <--gdcldflags> (GDCLDFLAGS): Add
-B${BUILD_DIR}/libdruntime/gcc.

gcc/d:
PR d/87864
* lang.opt (dstartfiles): New option.
* d-spec.cc (need_spec): New variable.
(lang_specific_driver) : Enable need_spec.
(lang_specific_pre_link): Also load libgphobos.spec if need_spec.

gcc/testsuite:
PR d/87864
* lib/gdc.exp (gdc_link_flags): Add path to drtbegin.o/drtend.o if
present.

Added:
trunk/libphobos/libdruntime/gcc/drtstuff.c
trunk/libphobos/src/drtstuff.spec
Modified:
trunk/gcc/d/ChangeLog
trunk/gcc/d/d-spec.cc
trunk/gcc/d/lang.opt
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/lib/gdc.exp
trunk/libphobos/ChangeLog
trunk/libphobos/configure   (contents, props changed)
trunk/libphobos/configure.ac
trunk/libphobos/libdruntime/Makefile.am
trunk/libphobos/libdruntime/Makefile.in
trunk/libphobos/libdruntime/gcc/config.d.in
trunk/libphobos/libdruntime/rt/sections_elf_shared.d
trunk/libphobos/m4/druntime/os.m4
trunk/libphobos/src/Makefile.am
trunk/libphobos/src/Makefile.in
trunk/libphobos/src/libgphobos.spec.in
trunk/libphobos/testsuite/testsuite_flags.in   (contents, props changed)

[Bug d/87864] libdruntime doesn't link with /bin/ld before Solaris 11.4

2019-02-14 Thread ro at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87864

Rainer Orth  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
URL|https://gcc.gnu.org/ml/gcc- |https://gcc.gnu.org/ml/gcc-
   |patches/2019-01/msg01666.ht |patches/2019-02/msg01019.ht
   |ml  |ml
   Last reconfirmed||2019-02-14
   Assignee|ibuclaw at gdcproject dot org  |ro at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #9 from Rainer Orth  ---
Mine, slightly revised patch posted.

[Bug d/87864] libdruntime doesn't link with /bin/ld before Solaris 11.4

2019-02-01 Thread ro at CeBiTec dot Uni-Bielefeld.DE
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87864

--- Comment #8 from ro at CeBiTec dot Uni-Bielefeld.DE  ---
> --- Comment #7 from Johannes Pfau  ---
>> The Minfo_Bracketing assert in sections_elf_shared.d fails now, of
>> course, but the file is usable even without linker-provided
>> bracketing.  Should this go completely?
>
> I think the assert should go, it doesn't belong there anyway. Minfo_Bracketing
> is unused then, AFAICS, so it should be fine to also remove it from
> gcc/config.d.

I've already removed the assert in the posted patch.  Minfo_Bracketing
is indeed unused now; I've removed it completely locally, awaiting other
review comments.

> Other changes look fine.

Thanks.

[Bug d/87864] libdruntime doesn't link with /bin/ld before Solaris 11.4

2019-01-31 Thread johannespfau at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87864

Johannes Pfau  changed:

   What|Removed |Added

 CC||johannespfau at gmail dot com

--- Comment #7 from Johannes Pfau  ---
> The Minfo_Bracketing assert in sections_elf_shared.d fails now, of
> course, but the file is usable even without linker-provided
> bracketing.  Should this go completely?

I think the assert should go, it doesn't belong there anyway. Minfo_Bracketing
is unused then, AFAICS, so it should be fine to also remove it from
gcc/config.d.

Other changes look fine.

[Bug d/87864] libdruntime doesn't link with /bin/ld before Solaris 11.4

2019-01-29 Thread ro at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87864

Rainer Orth  changed:

   What|Removed |Added

URL||https://gcc.gnu.org/ml/gcc-
   ||patches/2019-01/msg01666.ht
   ||ml

--- Comment #6 from Rainer Orth  ---
Patch posted.

[Bug d/87864] libdruntime doesn't link with /bin/ld before Solaris 11.4

2018-11-27 Thread ro at CeBiTec dot Uni-Bielefeld.DE
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87864

--- Comment #5 from ro at CeBiTec dot Uni-Bielefeld.DE  ---
> --- Comment #3 from ro at CeBiTec dot Uni-Bielefeld.DE  Uni-Bielefeld.DE> ---
>>> --- Comment #1 from Iain Buclaw  ---
>>> Is there another way to get a section in earlier versions of Solaris?
>>
>> What I initially did in LLVM's compiler-rt (which prompted the addition
>> of __start_SEC/__stop_SEC support to ld) was to add two startup files to
>> define the necessary labels and link the __start_SEC one early, the
>> __stop_SEC one late:
>>
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/
>>
>> See sancov_begin.S and sancov_end.S.

The attached patch implements this.  There were a couple of unexpected
problems, though.

> To elaborate, here's my current plan:
>
> * Have some drtstuff.c like this
>
> #ifdef DRT_BEGIN
> void *__start_minfo[]
> __attribute__((used, section("minfo"), aligned(sizeof(void * = { };
> #endif
>
> #ifdef DRT_END
> void *__stop_minfo[]
> __attribute__((used, section("minfo"), aligned(sizeof(void * = { };
> #endif
>
>   and compile it into separate drtbegin.o/drtend.o.

This worked fine.  I'm wrapping it in __ELF__ to make certain there's
no attempt to compile it on targets without named section support.

> * Based on the outcome of DCFG_MINFO_BRACKETING, add them to
>   libgphobos.spec like this:
>
> %rename startfile startfile_orig
> *startfile: %(startfile_orig) drtbegin.o%s
>
> %rename endfile endfile_orig
> *endfile: %(endfile_orig) drtend.o%s

This works, too.  However, the substitution needs to be done using
AC_SUBST_FILE with the fragment above in a separate file.  Initially, I
put it into a make variable, but the multiline variable confused the
hell out of make.

> * This will have to be done explicitly for libgdruntime.la and
>   libgphobos.la since both are linked with -nophoboslib.

This is the part that didn't work the way I initially thought: I tried
to explicitly add drtbegin.o to *_la_LDFLAGS (so it comes at the very
beginning of the link line) and drtend.o to *_la_LDADD (so it comes at
the end).  I couldn't get this to work, though: libtool insisted on
always moving those two files (either as .o or .lo files) to the very
end of the link line, completely breaking the intended bracketing.
Preceding the object files with -Wl or -Wc didn't change a thing.

So instead I went for a different approach: have gdc in concert with
libgphobos.spec do the work even when linking libgdruntime.la and
libgphobos.la.  The problem was that I still needed the
drtbegin.o/drtend.o files to be added despite the use of -nophoboslib.
To achieve that, I added a new -dstartfiles option.  I initially tried
-startfiles matching the existing -nostartfiles, but couldn't get that
option to be recognized by gdc.  Of course I now need to add the
matching -B options so both libgphobos.spec and drtbegin.o/drtend.o are
found.

> Doing the equivalent of this manually allowed the libs to be linked on
> Solaris 10.  However, this was before the section_elf_shared.d work, so
> the resulting libs had unresolved references.

I first tried this on Solaris 11.3 because S10 has quite a number of
additional problems.  I needed only a single additional patch (to be
submitted separately) because unlike S11.4 the networking functions have
not yet been folded into libc, but live in separate libsocket and
libnsl.

With this patch, I could bootstrap sparc-sun-solaris2.11 and with as and
i386-pc-solaris2.11, each on S11.4 (where ld does section bracketing)
and S11.3 (where it doesn't).

A couple of additional comments/questions:

* I'm uncertain if we want -dstartfiles to be documented at all: it's
  purely internal, I believe.

* I've switched the Makefile.am's from -Xcompiler to -Wc because the
  latter is way less verbose and allows to apppend several
  comma-separated args.

* The Minfo_Bracketing assert in sections_elf_shared.d fails now, of
  course, but the file is usable even without linker-provided
  bracketing.  Should this go completely?

There still are a very large number of execution failures in the
libphobos and gdc.* testsuites, but this is already the case on S11.4
when the linker adds the minfo bracketing.  At least we get the runtime
libs to link now.

[Bug d/87864] libdruntime doesn't link with /bin/ld before Solaris 11.4

2018-11-27 Thread ro at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87864

--- Comment #4 from Rainer Orth  ---
Created attachment 45106
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45106=edit
Initial patch

[Bug d/87864] libdruntime doesn't link with /bin/ld before Solaris 11.4

2018-11-22 Thread ro at CeBiTec dot Uni-Bielefeld.DE
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87864

--- Comment #3 from ro at CeBiTec dot Uni-Bielefeld.DE  ---
>> --- Comment #1 from Iain Buclaw  ---
>> Is there another way to get a section in earlier versions of Solaris?
>
> What I initially did in LLVM's compiler-rt (which prompted the addition
> of __start_SEC/__stop_SEC support to ld) was to add two startup files to
> define the necessary labels and link the __start_SEC one early, the
> __stop_SEC one late:
>
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/
>
> See sancov_begin.S and sancov_end.S.

To elaborate, here's my current plan:

* Have some drtstuff.c like this

#ifdef DRT_BEGIN
void *__start_minfo[]
__attribute__((used, section("minfo"), aligned(sizeof(void * = { };
#endif

#ifdef DRT_END
void *__stop_minfo[]
__attribute__((used, section("minfo"), aligned(sizeof(void * = { };
#endif

  and compile it into separate drtbegin.o/drtend.o.

* Based on the outcome of DCFG_MINFO_BRACKETING, add them to
  libgphobos.spec like this:

%rename startfile startfile_orig
*startfile: %(startfile_orig) drtbegin.o%s

%rename endfile endfile_orig
*endfile: %(endfile_orig) drtend.o%s

* This will have to be done explicitly for libgdruntime.la and
  libgphobos.la since both are linked with -nophoboslib.

Doing the equivalent of this manually allowed the libs to be linked on
Solaris 10.  However, this was before the section_elf_shared.d work, so
the resulting libs had unresolved references.

[Bug d/87864] libdruntime doesn't link with /bin/ld before Solaris 11.4

2018-11-02 Thread ro at CeBiTec dot Uni-Bielefeld.DE
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87864

--- Comment #2 from ro at CeBiTec dot Uni-Bielefeld.DE  ---
> --- Comment #1 from Iain Buclaw  ---
> Is there another way to get a section in earlier versions of Solaris?

What I initially did in LLVM's compiler-rt (which prompted the addition
of __start_SEC/__stop_SEC support to ld) was to add two startup files to
define the necessary labels and link the __start_SEC one early, the
__stop_SEC one late:

http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/

See sancov_begin.S and sancov_end.S.

As long as only a single section needs to be dealt with, that's a viable
option.  With too many sections needing similar treatment, this gets out
of hand.

[Bug d/87864] libdruntime doesn't link with /bin/ld before Solaris 11.4

2018-11-02 Thread ibuclaw at gdcproject dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87864

--- Comment #1 from Iain Buclaw  ---
Is there another way to get a section in earlier versions of Solaris?

The alternative is to support a vagary of methods in order to determine loaded
modules at runtime.

[Bug d/87864] libdruntime doesn't link with /bin/ld before Solaris 11.4

2018-11-02 Thread ro at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87864

Rainer Orth  changed:

   What|Removed |Added

   Target Milestone|--- |9.0