Thank you both for the patch and the explanation regarding the fix.
Another approach would be to change the signature of expand_dynamic_library_name() to receive a boolean and only srip the $libdir if it's true, but I think that the expand function should not handle the strip logic, it should only expand the dynamic library path and nothing else.
The reasoning makes sense to me.
I'm also attaching a second patch that has a TAP test case that reproduce this issue, it has some hacks to move dynamic library files around to exercice the problem so I'm not sure if it could be good to also include these tests on the final patch.
The TAP test is useful in testing various paths of extension files. It will be cleaner if the dummy_index_am.so is deleted at the end of the
tests from the $libdir.
Currently, the tests seem to be failing as follows for windows:
[19:07:13.107] # Failed test'create extension from custom extension control path'[19:07:13.107] # at C:/cirrus/src/test/modules/test_extensions/t/002_strip_modulepathname.pl line 102.[19:07:13.107] # got: '2'[19:07:13.107] # expected: '0'[19:07:13.107] # Looks like you failed 1 test of 7.[19:07:13.107] [19:07:13.107] (test program exited with status code 1)