The latest PyO3 version shipped changes to our windows builds to use the raw-dylib feature.
I'm experiencing a fairly significant pain point with raw-dylib - it can't be "renamed" because raw-dylib isn't an accepted kind to rustc -l <kind>=<name>:<rename>.
Without raw-dylib PyO3 was accepting any user-supplied name for libpython and was passing (via build script) the equivalent of -l dylib=pythonXY:<real-name>, and we then decorated extern blocks with #[link(name = "pythonXY")]. With raw-dylib we couldn't keep this structure and switched to macros to generate conditional #[cfg_attr(<condition>, link(kind = "raw-dylib", name = "<name>"))] for a known set of <condition>, <name> pairs.
This of course doesn't work for all possible user-supplied namse so we'll have to find ways to accept those (probably falling back to cdylib linking in this case).
It would be nice to reduce this complexity. I think a possible way to do it would be to allow passing -l raw-dylib=pythonXY:<name> to rustc (via cargo), which would have the effect of changing blocks marked #[link(kind = "raw-dylib", name = "pythonXY")] to link against a final library name of <name> supplied on the command line.
I looked into the macro thing and I think that would be a pretty complex language change to allow macros in attribute meta args, and might even end up with some ambiguity. It seems that there is a lot of cursedness here, according to Jana, the resident attribute parsing expert.
So even though it looks a bit ironic, I'd expect the compiler raw-dylib remapping to actually be simpler to implement.
I had a quick look and concluded the same thing; I started playing around with a patch to support -l raw-dylib=..., will see if I can finish it off in the near future.
This "just" needs us to be able to reference paths in attributes, which is challenging to implement. I've been meaning to get back into implementing that.
It's easy to implement if you turn [link] into a builtin macro, but that comes with its own set of problems, and is not the way I'd like to see things go.
We only support that in #[attr = Expr], because it was allowed in the past if you passed the expr through a macro invocation
Supporting that further is hard, because we'd a) need to figure out the story about how this interacts with attribute macros. #[attr = value] is never a macro, so that sidesteps it there, and b) we would need to parse attributes much earlier or parse macro invocations in attributes much later which would be rather difficult and/or hacky to implement.