Windows package: improve hack for statically linking libgomp into MEX files

Link only the needed parts, instead of embedding the whole library.
silicon
Sébastien Villemot 2023-03-15 17:35:25 +01:00
parent 62f608eb80
commit 6dbc7c2a17
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
5 changed files with 9 additions and 8 deletions

View File

@ -60,8 +60,10 @@ case ${MATLAB_ARCH} in
# 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"
# Hack for static linking of libgomp, needed for OpenMP.
# Should come by the end of the link command
# (otherwise it will have to be enclosed within --whole-archive).
OPENMP_LIBS="-Wl,-Bstatic -lgomp -Wl,-Bdynamic"
ax_mexopts_ok="yes"
;;
maci64)
@ -129,5 +131,5 @@ AC_SUBST([MATLAB_CXXFLAGS])
AC_SUBST([MATLAB_FCFLAGS])
AC_SUBST([MATLAB_LDFLAGS])
AC_SUBST([MATLAB_LIBS])
AC_SUBST([OPENMP_LDFLAGS])
AC_SUBST([OPENMP_LIBS])
])

View File

@ -4,7 +4,7 @@ nodist_sparse_hessian_times_B_kronecker_C_SOURCES = sparse_hessian_times_B_krone
nodist_A_times_B_kronecker_C_SOURCES = A_times_B_kronecker_C.f08 matlab_mex.F08 blas_lapack.F08
sparse_hessian_times_B_kronecker_C_CXXFLAGS = $(AM_CXXFLAGS) -fopenmp
sparse_hessian_times_B_kronecker_C_LDFLAGS = $(AM_LDFLAGS) $(OPENMP_LDFLAGS)
sparse_hessian_times_B_kronecker_C_LDADD = $(OPENMP_LIBS)
BUILT_SOURCES = $(nodist_sparse_hessian_times_B_kronecker_C_SOURCES) $(nodist_A_times_B_kronecker_C_SOURCES)
CLEANFILES = $(nodist_sparse_hessian_times_B_kronecker_C_SOURCES) $(nodist_A_times_B_kronecker_C_SOURCES)

View File

@ -5,7 +5,7 @@ nodist_local_state_space_iteration_3_SOURCES = local_state_space_iteration_3.f08
nodist_local_state_space_iteration_k_SOURCES = local_state_space_iteration_k.f08
local_state_space_iteration_2_CXXFLAGS = $(AM_CXXFLAGS) -fopenmp
local_state_space_iteration_2_LDFLAGS = $(AM_LDFLAGS) $(OPENMP_LDFLAGS)
local_state_space_iteration_2_LDADD = $(OPENMP_LIBS)
local_state_space_iteration_3_FCFLAGS = $(AM_FCFLAGS) -I../libkordersim -pthread
local_state_space_iteration_3_LDADD = ../libkordersim/libkordersim.a

View File

@ -6,8 +6,7 @@ nodist_perfect_foresight_problem_SOURCES = perfect_foresight_problem.cc DynamicM
perfect_foresight_problem_CPPFLAGS = $(AM_CPPFLAGS) -I$(TOPDIR)
perfect_foresight_problem_CXXFLAGS = $(AM_CXXFLAGS) -fopenmp
perfect_foresight_problem_LDFLAGS = $(AM_LDFLAGS) $(OPENMP_LDFLAGS)
perfect_foresight_problem_LDADD = $(LIBADD_DLOPEN)
perfect_foresight_problem_LDADD = $(LIBADD_DLOPEN) $(OPENMP_LIBS)
BUILT_SOURCES = $(nodist_perfect_foresight_problem_SOURCES)
CLEANFILES = $(nodist_perfect_foresight_problem_SOURCES)

View File

@ -4,7 +4,7 @@ TOPDIR = $(top_srcdir)/../../sources/sobol
qmc_sequence_CPPFLAGS = $(AM_CPPFLAGS) -I$(TOPDIR)
qmc_sequence_CXXFLAGS = $(AM_CXXFLAGS) -fopenmp
qmc_sequence_LDFLAGS = $(AM_LDFLAGS) $(OPENMP_LDFLAGS)
qmc_sequence_LDADD = $(OPENMP_LIBS)
nodist_qmc_sequence_SOURCES = qmc_sequence.cc