/usr/bin/ld: warning: /opt/nvidia/hpc_sdk/Linux_x86_64/21.7/compilers/lib/nvhpc.ld contains output sections

I got above error when invoking nvfortran or mpicc. nvcc works fine, also compilation alone (-c) works fine.

There is one hint at the end of the warning:

did you forget -T?

so it seems that the linker is invoked without this option.

I’m running Arch linux, kernel version 5.13.7.

ld -v gives GNU ld (GNU Binutils) 2.36.1

Hi Martin,

I’ve not seen this warning before and couldn’t reproduce it on any of our supported OSs (See: Release Notes Version 21.7 for the list of supported OSs). Fedora 32 is the most recent supported OS and that includes binutils 2.34 which does not produce the warning.

I ended up downloading and building binutils 2.36 to reproduce but I’m not clear what the complaint is. Is it change in behavior in ld where it’s now requiring the “-T” option for linker scripts, a change in how ld expects linker scripts to be formed, or a problem with ld itself. I’ll ask engineering to investigate.

Is the warning benign or is it preventing you from linking?

-Mat

Hi Mat,

thanks for the quick response.
The best information I found so far are complaints from the pascal community, e.g. linux - How to remove warning: link.res contains output sections; did you forget -T? - Stack Overflow.

Building a single file toy application is not a problem, but configure of PETSc 3.15 — PETSc 3.15.3 documentation fails due to the message on STDERR. It does not seem to discriminate between warning and error.

I went ahead and filed a problem report, TPR #30468, and sent it to our engineers for review.

As a quick workaround, I added “-T” before the “$PGILD” variable in “lin8464.rc” file located under “Linux_x86_64/21.7/compilers/bin/rcfiles”. I don’t know if this is the correct fix or if adding “-T” is backwards compatible with older versions of “ld”. Hence it don’t know if it will cause other problems, but worth a try.

Linux_x86_64/21.7/compilers/bin/rcfiles% diff -u lin8664rc.org lin8664rc
--- lin8664rc.org       2021-08-11 09:55:13.303189124 -0700
+++ lin8664rc   2021-08-11 09:55:22.739171666 -0700
@@ -23,7 +23,7 @@
 append DEFDEFS=$if($equal($SYS64,linux86-64-nollvm),__extension__=);

 variable PGILD is default($lookup($COMPBASE/$COMPSYS/$COMPVER/$(COMPLIBPREFIX)lib,nvhpc.ld));
-set DEFLDARGS=-m elf_x86_64 -dynamic-linker $LDSO $PGILD $if($NEEDNVHPCLDSYMS,$NVHPCLDSYMS);
+set DEFLDARGS=-m elf_x86_64 -dynamic-linker $LDSO -T $PGILD $if($NEEDNVHPCLDSYMS,$NVHPCLDSYMS);
 set LINUXCOMMON=-quad;
 set NOLLALIGN=;
 set MALIGN=;

Hope this helps,
Mat

unfortunately, it is not backward compatible.
I’ve installed the compiler on an older Ubuntu and -T somehow prevents linking other libraries, I get

/usr/bin/ld: cannot find -ldl
/usr/bin/ld: cannot find -lpthread

That’s s unfortunate. Hopefully our engineers can find a way to conditionally add “-T” or find a better solution.