swig / cccl

Unix cc compiler to Microsoft's cl compiler wrapper
GNU General Public License v3.0
125 stars 36 forks source link

Adjust absolute linker paths to use directory #10

Open GitMensch opened 2 years ago

GitMensch commented 2 years ago

link error with

cccl -o conftest.exe -I/d/dev/includes -L/d/dev/libs mconftest.c -lmpir --cccl-verbose

works with

cccl -o conftest.exe -I/d/dev/includes -Ld:/dev/libs mconftest.c -lmpir --cccl-verbose

It looks like link.exe does not like /d/ while the C preprocessor has no issues with that. Possibly paths starting with / could be adjusted; it should be quite save to changed /X/ to X:/ when X is a single letter.

wsfulton commented 2 years ago

it should be quite save to changed /X/ to X:/ when X is a single letter.

Not safe and too hacky IMHO. This approach makes too many presumptions about the file system emulation in the Unix space. cccl is not the right tool to manipulate file names and so won't accept patches to manipulate them.

The correct way is to use the appropriate file manipulation tools (cygpath on mingw/msys/cygwin) or inbuilt path translations in MinGW/MSYS, see https://web.archive.org/web/20201112005258/http://www.mingw.org/wiki/Posix_path_conversion (Wayback machine snapshot of mingw.org is the best I could find). Assuming you are using a mingw based system, I think this is also a bug there as it should adjust file paths when invoking a win32 executable. Or perhaps you have set MSYS_NO_PATHCONV by mistake?

Lastly, the example you gave works for me using MSYS2 and cl.exe finds the library to link with when using a -L with a full path as you've shown using slashes. It would be interesting to see the translated paths that MinGW/MSYS actually pass to cl.exe. Try use one of the sysinternal tools??