Windows package: statically link libssp inside MEX files

Since 3244340e7a, the MEX files are built with
-fstack-protector. But this added a dynamic link to libssp-0.dll on some MEX
files, making them unusable.
silicon
Sébastien Villemot 2023-03-15 17:02:49 +01:00
parent dd93aa3cd8
commit 12008bc6eb
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
1 changed files with 9 additions and 1 deletions

View File

@ -51,7 +51,15 @@ case ${MATLAB_ARCH} in
# using threads, since we are using the POSIX threads version of MinGW)
MATLAB_LDFLAGS_NOMAP="-static-libgcc -static-libstdc++ -static-libgfortran -Wl,-Bstatic,--whole-archive -lquadmath -Wl,-Bdynamic,--no-whole-archive -shared -L$MATLAB/bin/win64 -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,-Bdynamic,--no-whole-archive"
MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP \$(abs_top_srcdir)/mex.def"
MATLAB_LIBS="-lmex -lmx -lmat -lmwlapack -lmwblas"
# Hack for libssp, which is pulled in by -fstack-protector
# (curiously only on some MEX files), see windows/build.sh.
# Note that the link against libssp should not happen with compilers
# from MSYS2, see:
# https://www.msys2.org/news/#2022-10-10-libssp-is-no-longer-required
# But it happens with Debians cross compilers (as of Debian “bookworm” 12).
# Also note that the -lssp must come by the end of the link command
# (otherwise it will have to be enclosed within --whole-archive).
MATLAB_LIBS="-lmex -lmx -lmat -lmwlapack -lmwblas -Wl,-Bstatic -lssp -Wl,-Bdynamic"
# Hack for static linking of libgomp, needed for OpenMP
OPENMP_LDFLAGS="-Wl,-Bstatic,--whole-archive -lgomp -Wl,-Bdynamic,--no-whole-archive"
ax_mexopts_ok="yes"