Darwin linker error "illegal text-relocation" with -shared
Ryan S. Elliott
relliott@umn.edu
Mon Apr 16 21:09:00 GMT 2018
On Mon, 16 Apr 2018, Steve Kargl wrote:
> On Mon, Apr 16, 2018 at 02:51:16PM -0500, Ryan S. Elliott wrote:
>>
>> No, you are right. I should have included the -fPIC flag, but this doesn't
>> change the results:
>>
>>
>> $ gfortran-7 -shared -fPIC foo.f90
>> ld: illegal text-relocation to '_gee' in /var/folders/q0/mth73zrd307d66c43f8r3xv80000gp/T//ccG1nHc0.o from 'lC0' in /var/folders/q0/mth73zrd307d66c43f8r3xv80000gp/T//ccG1nHc0.o for architecture x86_64
>> collect2: error: ld returned 1 exit status
>>
>
> google 'macos ld illegal text-relocation' suggests that this
> is a longstanding problem with macos. Perhaps, a bug report
> to Apple is appropriate?
>
> Try adding "-Wl,-read_only_relocs suppress" to your command line.
Yes, this is a long standing issue. I do not believe that it is really an
apple problem. I think gfortran is doing something that apple considers
invalid.
The "-Wl,-read_only_relocs suppress" argument only works if you compile in 32
bit (with "-m32") otherwise it is not a valid argument:
$ gfortran-7 -shared -fPIC "-Wl,-read_only_relocs suppress" foo.f90
ld: unknown option: -read_only_relocs suppress
collect2: error: ld returned 1 exit status
Ryan
More information about the Fortran
mailing list