pgfortran confused by -Bstatic -Bdynamic option

Dear developer,

the compiler pgfortran (at least versions 15.10 & 16.3) seem to be confused, when both, the -Bstatic and -Bdynamic options appear on the command line for the linking command. The command

pgfortran fxudriver.o module.o -o fxudriver -Bstatic -Llib -lfortyxima -Bdynamic

is not executed, but aborts with the error message

/usr/bin/ld: ..../16.3/linux86-64/16.3/lib/libpgmp.a(init_pthr.o): undefined reference to symbol '__tls_get_addr@@GLIBC_2.3'
//lib/x86_64-linux-gnu/ld-linux-x86-64.so.2: error adding symbols: DSO missing from command line

Leaving away the -Bdynamic from the end would solve the problem, but it is automatically emitted by my build system. Also, according to the ld man-page, it is completely legid to use -Bstatic and -Bdynamic in one linker call.

Best regards, Bálint

Hello,

-Bstatic and -Bdynamic can be used on the command line.
The intent is that everything after -Bstatic is a static link of libfoo.a,
instead of the shared libfoo.so (if it exists). Once -Bdynamic is set in the
link line, everything after that will use the libfoo.so instead of libfoo.a.

But -Bstatic alone sometimes means to link everything statically,
somewhat like -Wl,-static would do.

Look at the verbose output of a simple foo.f build with -Bstatic_pgi,
which is our switch for linking PGI libraries statically, while letting the
non-PGI libs link dynamically. You will see that by careful ordering of
the libs with -Bdynamic and -Bstatic, you can build codes on a platform
and run them on other Linux platforms, w/o havingto move PGI libs to the
new platform.

pgfortran -v -o hello hello.f -Bstatic_pgi

dave