OpenBLAS icon indicating copy to clipboard operation
OpenBLAS copied to clipboard

Soft linking issue when building with MSYS2/minGW

Open hanblee opened this issue 5 years ago • 10 comments

When building with MSYS2/minGW, I run into the following problem:

$ make libs TARGET=HASWELL ONLY_CBLAS=1 USE_THREAD=0 USE_LOCKING=1 NO_LAPACK=1 NO_LAPACKE=1 BUILD_BFLOAT16=1 DYNAMIC_ARCH=1 DYNAMIC_LIST="SKYLAKEX COOPERLAKE" F_COMPILER="" MAKE_NB_JOBS=-1
ln: failed to create symbolic link 'libopenblas.a': No such file or directory
make: [Makefile:170: libs] Error 1 (ignored)

This is because on MSYS2/minGW, the behavior of ln is different than on other platforms in that, if the target of the ln command does not exist, it fails to create a soft link (as is the case here where the Makefile creates the soft link before the static library gets built). In fact, instead of creating a soft link, ln's behavior on MSYS2/minGW is to create a copy.

The solution would be to move the ln command (https://github.com/xianyi/OpenBLAS/blob/develop/Makefile#L170) after the creation of the library file (https://github.com/xianyi/OpenBLAS/blob/develop/Makefile#L199).

hanblee avatar Apr 23 '21 20:04 hanblee

In the default case it does make all before make libs , could you try this way, i.e omitting libs parameter?

brada4 avatar Apr 23 '21 20:04 brada4

Same with make all:

$ make all TARGET=HASWELL ONLY_CBLAS=1 USE_THREAD=0 USE_LOCKING=1 NO_LAPACK=1 NO_LAPACKE=1 BUILD_BFLOAT16=1 DYNAMIC_ARCH=1 DYNA
MIC_LIST="SKYLAKEX COOPERLAKE" F_COMPILER="" MAKE_NB_JOBS=-1
ln: failed to create symbolic link 'libopenblas.a': No such file or directory
make: [Makefile:170: libs] Error 1 (ignored)

hanblee avatar Apr 23 '21 20:04 hanblee

BTW, you see this ld error when people report building issues with minGW (often immaterial to the issue they are having, but it serves as a confirmation of the issue). For example, https://github.com/xianyi/OpenBLAS/issues/2975

hanblee avatar Apr 23 '21 21:04 hanblee

Where did you get the idea to use libs parameter or any parameter exept "rules" variables? Please run "make clean ; make TARGET=HASWELL ONLY_CBLAS=1 USE_THREAD=0 USE_LOCKING=1 NO_LAPACK=1 NO_LAPACKE=1 BUILD_BFLOAT16=1 DYNAMIC_ARCH=1 DYNAMIC_LIST="SKYLAKEX COOPERLAKE" F_COMPILER="" MAKE_NB_JOBS=-1"

brada4 avatar Apr 24 '21 12:04 brada4

Windows 10 supports symlinks without admin privilege starting from 1703. If you are stuck with something more ancient thanks to enterprise

  • get a Linux VM and perform a cross build
  • clang-cl + visual studio (without anacondas)

brada4 avatar Apr 25 '21 07:04 brada4

"make clean ; make TARGET=HASWELL ONLY_CBLAS=1 USE_THREAD=0 USE_LOCKING=1 NO_LAPACK=1 NO_LAPACKE=1 BUILD_BFLOAT16=1 DYNAMIC_ARCH=1 DYNAMIC_LIST="SKYLAKEX COOPERLAKE" F_COMPILER="" MAKE_NB_JOBS=-1"

This does not create the link to static library either.

Windows 10 supports symlinks without admin privilege starting from 1703. If you are stuck with something more ancient thanks to enterprise

get a Linux VM and perform a cross build clang-cl + visual studio (without anacondas)

Why not fix the problem instead of these workarounds? Is there any reason that ln command has to come before the library creation?

hanblee avatar Apr 26 '21 06:04 hanblee

I have not had time to look at this. Anybody can comment here, and any kind of accepted pull request will automatically add the "Contributor" label to their name from then on.

martin-frbg avatar Apr 26 '21 06:04 martin-frbg

As I mentioned in the initial message, this fix works for me:

The solution would be to move the ln command (https://github.com/xianyi/OpenBLAS/blob/develop/Makefile#L170) after the creation of the library file (https://github.com/xianyi/OpenBLAS/blob/develop/Makefile#L199).

hanblee avatar Apr 26 '21 07:04 hanblee

Windows 10 supports symlinks without admin privilege starting from 1703. If you are stuck with something more ancient thanks to enterprise

  • get a Linux VM and perform a cross build
  • clang-cl + visual studio (without anacondas)

Windows version is not the issue (we're using something newer than 1703). The problem is that MSYS2's ln.exe isn't creating a Windows 10 soft link. We don't know why and, if we're affected, so may be others.

We are not blocked by this issue (there are workarounds and we do have cross builds too). We're simply asking that it be fixed the proper way and the symlink not get created until the library is actually compiled.

thiagomacieira avatar Apr 26 '21 15:04 thiagomacieira

It is not nice and easy https://github.com/git-for-windows/git/wiki/Symbolic-Links#allowing-non-administrators-to-create-symbolic-links https://superuser.com/questions/550732/use-mklink-in-msys I am stuck with hardening so bad that no cygwin or msys ever runs, thats where two away-from-the-box options come from

brada4 avatar Apr 26 '21 18:04 brada4