NAG compiler and .rsp file (2)
This is a follow up to #18232 (closed).
- It seems the current version of the NAG Fortran compiler (7.1) supports the
@
syntax directly, no-Wl,
needed. - Actually, using
-Wl,@
did not work for me: The file is passed to the linker (gcc
) correctly, but in the wrong order, so linking fails. - There seems to be a line length limit of ~1029 characters in the
.rsp
file. It works if each object file (or library or whatever) is written in a new line. (See also #20070 (comment 665002))
Regarding 2, it occurs when adding the -unsharedrts
flag ("this allows a dynamically linked executable to be run on systems where the NAG Fortran Compiler is not installed").
$ nagfor -V
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7101
Product NPL6A71NA for x86-64 Linux
Copyright 1990-2020 The Numerical Algorithms Group Ltd., Oxford, U.K.
# With plain @
$ nagfor -quiet -unsharedrts @file.rsp other.o
# With -Wl,@
$ nagfor -quiet -unsharedrts -Wl,@file.rsp other.o
a.o: In function `main_':
a.014265.c:(.text+0x79): undefined reference to `__NAGf90_write_seq'
a.014265.c:(.text+0x89): undefined reference to `__NAGf90_init_loutput'
a.014265.c:(.text+0xa1): undefined reference to `__NAGf90_lio_write_ch'
a.014265.c:(.text+0xad): undefined reference to `__NAGf90_end_write_sequential'
a.014265.c:(.text+0xb7): undefined reference to `__NAGf90_finish'
collect2: error: ld returned 1 exit status
# The command like passed for linking:
$ nagfor -quiet -unsharedrts -Wl,@a.rsp other.o -#
/usr/bin/gcc -m64 /usr/local/lib/NAG_Fortran/quickfit.o b.o /usr/local/lib/NAG_Fortran/libf71rts.a -lm -lpthread @file.rsp
# This, indeed, doesn't work:
$ /usr/bin/gcc -m64 /usr/local/lib/NAG_Fortran/quickfit.o b.o /usr/local/lib/NAG_Fortran/libf71rts.a -lm -lpthread @file.rsp
a.o: In function `main_':
a.014265.c:(.text+0x79): undefined reference to `__NAGf90_write_seq'
a.014265.c:(.text+0x89): undefined reference to `__NAGf90_init_loutput'
a.014265.c:(.text+0xa1): undefined reference to `__NAGf90_lio_write_ch'
a.014265.c:(.text+0xad): undefined reference to `__NAGf90_end_write_sequential'
a.014265.c:(.text+0xb7): undefined reference to `__NAGf90_finish'
collect2: error: ld returned 1 exit status
#But this does:
$ /usr/bin/gcc -m64 @file.rsp /usr/local/lib/NAG_Fortran/quickfit.o b.o /usr/local/lib/NAG_Fortran/libf71rts.a -lm -lpthread
In short, at least from version 7.1, the response file should be passed with @
and not with -Wl,@
.
Edited by Jellby