I figured out what I did wrong. The end of my $LDFLAGS contained "-Wl,-rpath,/path/to/an/old/R/installation/lib64/R/lib" (which predated anyNA) and I was also using --enable-R-shlib, so possibly related to PR#15790 (I say possibly, because I was not using "make install-libR").