[Bug target/59888] Darwin linker error "illegal text-relocation" with -shared

2019-10-30 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

Iain Sandoe  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #23 from Iain Sandoe  ---
fixed on open branches

[Bug target/59888] Darwin linker error "illegal text-relocation" with -shared

2019-10-29 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

--- Comment #22 from Iain Sandoe  ---
Author: iains
Date: Tue Oct 29 20:05:05 2019
New Revision: 277584

URL: https://gcc.gnu.org/viewcvs?rev=277584=gcc=rev
Log:
[Darwin] Amend section for constants with relocations.

Darwin's linker doesn't like text section relocations (they require special
enabling). The Fortran FE, at least, seems to generate cases where the
initialiser for a pointer constant can need a relocation. We can handle
this by special-casing SECCAT_RODATA when the relocation is present by
placing the constant in the .const_data section.

2019-10-29  Iain Sandoe  

Backport from mainline
2019-10-05  Iain Sandoe  

PR target/59888
* config/darwin.c (darwin_rodata_section): Add relocation flag,
choose const_data section for constants with relocations.
(machopic_select_section): Pass relocation flag to
darwin_rodata_section ().


Modified:
branches/gcc-7-branch/gcc/ChangeLog
branches/gcc-7-branch/gcc/config/darwin.c

[Bug target/59888] Darwin linker error "illegal text-relocation" with -shared

2019-10-28 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

--- Comment #21 from Iain Sandoe  ---
Author: iains
Date: Mon Oct 28 19:40:03 2019
New Revision: 277540

URL: https://gcc.gnu.org/viewcvs?rev=277540=gcc=rev
Log:
[Darwin] Amend section for constants with relocations.

Darwin's linker doesn't like text section relocations (they require special
enabling). The Fortran FE, at least, seems to generate cases where the
initialiser for a pointer constant can need a relocation. We can handle
this by special-casing SECCAT_RODATA when the relocation is present by
placing the constant in the .const_data section.

2019-10-28  Iain Sandoe  

Backport from mainline
2019-10-05  Iain Sandoe  

PR target/59888
* config/darwin.c (darwin_rodata_section): Add relocation flag,
choose const_data section for constants with relocations.
(machopic_select_section): Pass relocation flag to
darwin_rodata_section ().


Modified:
branches/gcc-8-branch/gcc/ChangeLog
branches/gcc-8-branch/gcc/config/darwin.c

[Bug target/59888] Darwin linker error "illegal text-relocation" with -shared

2019-10-18 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

--- Comment #20 from Iain Sandoe  ---
Author: iains
Date: Fri Oct 18 08:42:41 2019
New Revision: 277145

URL: https://gcc.gnu.org/viewcvs?rev=277145=gcc=rev
Log:
[Darwin] Amend section for constants with relocations.

Darwin's linker doesn't like text section relocations (they require special
enabling).  The Fortran FE, at least, seems to generate cases where the
initialiser for a pointer constant can need a relocation.  We can handle
this by special-casing SECCAT_RODATA when the relocation is present by
placing the constant in the .const_data section.

gcc/

2019-10-18  Iain Sandoe  

Backport from mainline
2019-10-05  Iain Sandoe  

PR target/59888
* config/darwin.c (darwin_rodata_section): Add relocation flag,
choose const_data section for constants with relocations.
(machopic_select_section): Pass relocation flag to
darwin_rodata_section ().


Modified:
branches/gcc-9-branch/gcc/ChangeLog
branches/gcc-9-branch/gcc/config/darwin.c

[Bug target/59888] Darwin linker error "illegal text-relocation" with -shared

2019-10-16 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

--- Comment #19 from Iain Sandoe  ---
(In reply to Zaak from comment #18)
> (In reply to Iain Sandoe from comment #17)
> > by the way, I haven't been able to find a C reproducer for this issue - if
> > you feel we should have a testcase for it perhaps a link test for the
> > fortran example would work?

The Fortran FE folks might also want to convince themselves that the behaviour
FX describes in comment #8 is correct.

> It would be great to have a test to prevent future regressions here. I have
> no experience contributing to GCC or using dejagnu but if people are having
> trouble cooking up a C source to produce an object/library to link the
> Fortran against, I can try to find something to trigger this.

That's not the problem;
When C generates initialisers for function pointers, these end up in the
correct section already, the problem is triggered by something that the 
Fortran FE does differently.

So that means it's going to be hard to make a test that lives outside the
Fortran testsuite.

A testcase does not have to execute to be useful (a link test using the code at
comment #12 would be OK).  However someone has to package the test and decide
where it should live in the Fortran testsuite :-)

> As I mentioned previously this blocks gtk-fortran from linking on Darwin,
> however both GTK and gtk-fortran are not adequately small reproducers.

I will back port this in due course.

[Bug target/59888] Darwin linker error "illegal text-relocation" with -shared

2019-10-08 Thread zbeekman at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

--- Comment #18 from Zaak  ---
(In reply to Iain Sandoe from comment #17)
> by the way, I haven't been able to find a C reproducer for this issue - if
> you feel we should have a testcase for it perhaps a link test for the
> fortran example would work?

It would be great to have a test to prevent future regressions here. I have no
experience contributing to GCC or using dejagnu but if people are having
trouble cooking up a C source to produce an object/library to link the Fortran
against, I can try to find something to trigger this.

As I mentioned previously this blocks gtk-fortran from linking on Darwin,
however both GTK and gtk-fortran are not adequately small reproducers.

[Bug target/59888] Darwin linker error "illegal text-relocation" with -shared

2019-10-05 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

--- Comment #17 from Iain Sandoe  ---
by the way, I haven't been able to find a C reproducer for this issue - if you
feel we should have a testcase for it perhaps a link test for the fortran
example would work?

[Bug target/59888] Darwin linker error "illegal text-relocation" with -shared

2019-10-05 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

--- Comment #16 from Iain Sandoe  ---
Author: iains
Date: Sat Oct  5 08:05:44 2019
New Revision: 276623

URL: https://gcc.gnu.org/viewcvs?rev=276623=gcc=rev
Log:
[Darwin] Amend section for constants with reloactions.

Darwin's linker doesn't like text section relocations (they require special
enabling).  At least, the Fortran FE seems to generate cases where the
initialiser for a pointer constant can need a relocation.  We can handle
this by special-casing SECCAT_RODATA when the relocation is present by
placing the constant in the .const_data section.

gcc/ChangeLog:

2019-10-05  Iain Sandoe  

PR target/59888
* config/darwin.c (darwin_rodata_section): Add relocation flag,
choose const_data section for constants with relocations.
(machopic_select_section): Pass relocation flag to
darwin_rodata_section ().


Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/darwin.c

[Bug target/59888] Darwin linker error "illegal text-relocation" with -shared

2019-04-24 Thread zbeekman at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

Zaak  changed:

   What|Removed |Added

 CC||zbeekman at gmail dot com

--- Comment #15 from Zaak  ---
This is preventing gtk-fortran from compiling on macOS with GCC 8.3, AFAICT.

cd /tmp/gtk-fortran-20190424-36870-ggjnvc/gtk-fortran-19.04.gtk3.24.8/build/src
&& /usr/local/Cellar/cmake/3.14.3/bin/cmake -E cmake_link_script
CMakeFiles/gtk-fortran_shared.dir/link.txt --verbose=1
/usr/local/bin/gfortran -pthread -O2 -fPIC -dynamiclib
-Wl,-headerpad_max_install_names -compatibility_version 0.1.0 -current_version
0.1.0 -o libgtk-3-fortran.0.1.dylib -install_name
@rpath/libgtk-3-fortran.0.1.dylib
CMakeFiles/gtk-fortran_object.dir/atk-auto.f90.o
CMakeFiles/gtk-fortran_object.dir/cairo-auto.f90.o
CMakeFiles/gtk-fortran_object.dir/gdk-auto.f90.o
CMakeFiles/gtk-fortran_object.dir/gdk-pixbuf-auto.f90.o
CMakeFiles/gtk-fortran_object.dir/glib-auto.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-hl.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-hl-container.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-hl-button.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-hl-entry.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-hl-tree.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-hl-menu.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-hl-combobox.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-hl-spin-slider.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-hl-chooser.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-hl-dialog.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-hl-progress.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-hl-accelerator.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-hl-infobar.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-hl-assistant.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-hl-misc.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-draw-hl.f90.o
CMakeFiles/gtk-fortran_object.dir/gtk-sup.f90.o
CMakeFiles/gtk-fortran_object.dir/gdk-pixbuf-hl.f90.o
CMakeFiles/gtk-fortran_object.dir/pango-auto.f90.o
CMakeFiles/gtk-fortran_object.dir/gdkevents-auto3.f90.o
CMakeFiles/gtk-fortran_object.dir/unixonly-auto.f90.o 
-L/usr/local/Cellar/plplot/5.14.0_1/lib
-Wl,-rpath,/usr/local/Cellar/plplot/5.14.0_1/lib
/usr/local/lib/libatk-1.0.dylib /usr/local/lib/libcairo.dylib
/usr/local/lib/libgdk-3.0.dylib /usr/local/lib/libgdk_pixbuf-2.0.dylib
/usr/local/lib/libglib-2.0.dylib /usr/local/lib/libgio-2.0.dylib
/usr/local/lib/libgobject-2.0.dylib /usr/local/lib/libgtk-3.0.dylib
/usr/local/lib/libpango-1.0.dylib
ld: illegal text-relocation to '_hl_gtk_listn_edit_cb' in
CMakeFiles/gtk-fortran_object.dir/gtk-hl-tree.f90.o from 'lC72' in
CMakeFiles/gtk-fortran_object.dir/gtk-hl-tree.f90.o for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [src/libgtk-3-fortran.0.1.dylib] Error 1
make[1]: *** [src/CMakeFiles/gtk-fortran_shared.dir/all] Error 2
make: *** [all] Error 2

[Bug target/59888] Darwin linker error "illegal text-relocation" with -shared

2018-02-18 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

Eric Gallager  changed:

   What|Removed |Added

 CC||egallager at gcc dot gnu.org
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=63622,
   ||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=63580

--- Comment #14 from Eric Gallager  ---
(In reply to Francois-Xavier Coudert from comment #13)
> Might this be related with PR63622 (and thus PR63580)?

These have both been closed.

[Bug target/59888] Darwin linker error illegal text-relocation with -shared

2014-11-01 Thread fxcoudert at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

--- Comment #13 from Francois-Xavier Coudert fxcoudert at gcc dot gnu.org ---
Might this be related with PR63622 (and thus PR63580)?


[Bug target/59888] Darwin linker error illegal text-relocation with -shared

2014-10-16 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

--- Comment #9 from Iain Sandoe iains at gcc dot gnu.org ---
do we have a revision # that triggered this behaviour?
(or has it always been there?)


[Bug target/59888] Darwin linker error illegal text-relocation with -shared

2014-10-16 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

--- Comment #10 from Dominique d'Humieres dominiq at lps dot ens.fr ---
 do we have a revision # that triggered this behaviour?
 (or has it always been there?)

Up to r189986 (2012-07-30) compiling the second code in comment 6 gives the
error

pr59888_3.f90:5.22:

call gee(c_funloc(gee))
  1
Error: Parameter 'gee' to 'c_funloc' at (1) must be BIND(C)

After r190090 (2012-08-02) compiling the same code gives

ld: illegal text-relocation to '___foo_MOD_gee' in
/var/folders/8q/sh_swgz96r7f5vnn08f7fxr0gn/T//ccutec2S.o from 'anon' in
/var/folders/8q/sh_swgz96r7f5vnn08f7fxr0gn/T//ccutec2S.o for architecture
x86_64
collect2: error: ld returned 1 exit status

Probably

2012-07-31  Tobias Burnus  bur...@net-b.de

* interface.c (gfc_procedure_use): Return gfc_try instead of void.
* gfortran.h (gfc_procedure_use): Update prototype.
* resolve.c (gfc_iso_c_func_interface): Allow noninteroperable
procedures for c_funloc for TS29113.
* (gfc_iso_c_sub_interface): Ditto for c_f_procpointer. Add
diagnostic for c_ptr vs. c_funptr for c_f_(proc)pointer.


[Bug target/59888] Darwin linker error illegal text-relocation with -shared

2014-10-16 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

--- Comment #11 from Dominique d'Humieres dominiq at lps dot ens.fr ---
The change occurred at r190003 and an error

Error: TS 29113: Noninteroperable argument 'gee' to 'c_funloc' at (1)

is emitted if one uses -std=f2008.


[Bug target/59888] Darwin linker error illegal text-relocation with -shared

2014-10-16 Thread fxcoudert at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

--- Comment #12 from Francois-Xavier Coudert fxcoudert at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #11)
 The change occurred at r190003 and an error
 Error: TS 29113: Noninteroperable argument 'gee' to 'c_funloc' at (1)
 is emitted if one uses -std=f2008.

I realize that in simplifying the testcase, I made it non-standard conforming.
Try the same revisions with the amended program below, I fear the error message
might be a red herring:

module foo
contains
  subroutine bar
use, intrinsic :: iso_c_binding
call gee(c_funloc(gee))
  end subroutine
  subroutine gee(f) bind(c)
use, intrinsic :: iso_c_binding
type(c_funptr) :: f
  end subroutine 
end module foo


[Bug target/59888] Darwin linker error illegal text-relocation with -shared

2014-10-04 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

--- Comment #7 from Iain Sandoe iains at gcc dot gnu.org ---
Let's work on the principle that the linker is DTRT (it seems reasonable, at
least).

---

So, I started to try and replicate what the failing case was doing with a c
equivalent.

My investigations are not complete (and the usual limited time problem applies)
- but so far, it seems - in the c case - that the static variable gets placed
in .data (which is fine, from ld64's pov).

As of now, I suspect that the placement into the .const section *might* be
fallout from the restrict markup.

.. hmm, it's quite hard to point to a useful avenue of exploration (other that
confirming that the reference is being lowered as expected, and that the
restrict markup is correctly applied).

.. when i have a few more cycles, I'll try and improve my c case to match the
fortran more closely.


[Bug target/59888] Darwin linker error illegal text-relocation with -shared

2014-10-04 Thread fxcoudert at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59888

--- Comment #8 from Francois-Xavier Coudert fxcoudert at gcc dot gnu.org ---
(In reply to Iain Sandoe from comment #7)
 As of now, I suspect that the placement into the .const section *might* be
 fallout from the restrict markup.

To confirm whether it was linked to restrict, I patched the compiler to simply
not add the restrict qualifier for f (and later checked that it worked by
looking at the tree dumps):

Index: trans-types.c
===
--- trans-types.c(revision 215645)
+++ trans-types.c(working copy)
@@ -2206,7 +2206,7 @@ gfc_sym_type (gfc_symbol * sym)
   else
 {
   type = build_reference_type (type);
-  if (restricted)
+  if (0  restricted)
 type = build_qualified_type (type, TYPE_QUAL_RESTRICT);
 }
 }

However, removing the restrict qualifier doesn't remove the linker error at
all. So, I think restrict might be a red herring.