Don't hard-code `-ldl -lpthread` for `format_args`
As of #2822 "Start reusing rustc's format_args parser", we add -ldl -lpthread to LIBS in gcc/rust/Make-lang.in. Instead of doing this unconditionally, we should check if those libraries exist at all, and which are actually necessary -- query Cargo about crate's linker flags?
note that this was done exclusively because the build was breaking in our GCC 4.8 CI - other contributors on IRC have mentioned the existence of flags/autoconf functions to check for the existence/necessity of these libraries, so any help would be greatly appreciated
Cross-referencing https://gcc.gnu.org/PR113499 "crab1 fails to link when configuring with --disable-plugin" here.
If "query Cargo about crate's linker flags" is not feasible (at this time, at least), then indeed I think I'd add a simple check whether *.so exist (that is, can be linked via a dummy Autoconf stanza -- or is there even a AC_[...] to check for libraries' existence?), and if yes, then link crab1 against those unconditionally.
some notes from discussing this with jakub:
│18:20:52 jakub │ cohenarthur1: depends on what you want to test; if it is just test whether "do I need to link with -ldl if I use dlopen or not" or "do I need to link with -lpthread or -pthread if I use pthread_create or not", then │ nathanchance
│ │ yes, adding similar configure.ac checks and using it in Makefile.in/make fragments will be enough; but if you need to somehow handle the case where hosts doesn't have pthread │ ndesaulniers
│18:20:54 jakub │ at all and either just silently should have rust not configured in on --enable-languages=all, or have some nice error than <pthread.h>, no such header or similar, then more work is needed │ Nebraskka
│18:21:18 jakub │ as for not using @DL_LIB@ anywhere, no idea, you'd need to ask the folks which added it to configure.ac (see git blame) │ nightstrike
│18:22:06 cohenarthur1 │ ah, fair - since you were the one talking about it I assumed it was your addition :) thanks for the help │ noteness
│18:23:49 jakub │ note, I think the current configure.ac test for DL_LIB actually doesn't check if you can use dlopen without linking -ldl; so in the recent glibc or Darwin case, it might be better try to link a program using │ nrubsig
│ │ #include <dlfcn.h> and using dlopen, dlsym, dlclose without -ldl, if that works, set DL_LIB or whatever to nothing, otherwise try to link with -ldl, if that works, set DL_LIB to │ ogabbay__
│18:23:52 jakub │ -ldl, otherwise if neither works, do something reasonable (error out if rust is configured, ...)
@CohenArthur Unless mistaken this issue should be closed