Skip to content

Commit

Permalink
MAINT: Reduce PRIMA binary size and suppress warning
Browse files Browse the repository at this point in the history
Incorporate changes to PRIMA that allow us to not compile the other
solvers. This reduces the binary from about 1.2MB to 840kB.

Also the warning about compact unwind is suppressed. It comes from using
AppleClang to link code compiled with gfortran. In theory it impacts
exception handling but tests with exception in the objective function,
constraint function, and in the C++ have shown no adverse effects.
  • Loading branch information
nbelakovski committed Nov 20, 2024
1 parent 25bd6ba commit 28aa2ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 32 deletions.
41 changes: 10 additions & 31 deletions scipy/optimize/_prima/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,6 @@ prima_f = static_library('prima_f',
'../../_lib/prima/fortran/cobyla/initialize.f90',
'../../_lib/prima/fortran/cobyla/trustregion.f90',
'../../_lib/prima/fortran/cobyla/update.f90',
'../../_lib/prima/fortran/bobyqa/bobyqa.f90',
'../../_lib/prima/fortran/bobyqa/bobyqb.f90',
'../../_lib/prima/fortran/bobyqa/geometry.f90',
'../../_lib/prima/fortran/bobyqa/initialize.f90',
'../../_lib/prima/fortran/bobyqa/trustregion.f90',
'../../_lib/prima/fortran/bobyqa/rescue.f90',
'../../_lib/prima/fortran/bobyqa/update.f90',
'../../_lib/prima/fortran/lincoa/update.f90',
'../../_lib/prima/fortran/lincoa/initialize.f90',
'../../_lib/prima/fortran/lincoa/getact.f90',
'../../_lib/prima/fortran/lincoa/trustregion.f90',
'../../_lib/prima/fortran/lincoa/geometry.f90',
'../../_lib/prima/fortran/lincoa/lincob.f90',
'../../_lib/prima/fortran/lincoa/lincoa.f90',
'../../_lib/prima/fortran/newuoa/initialize.f90',
'../../_lib/prima/fortran/newuoa/trustregion.f90',
'../../_lib/prima/fortran/newuoa/geometry.f90',
'../../_lib/prima/fortran/newuoa/update.f90',
'../../_lib/prima/fortran/newuoa/newuob.f90',
'../../_lib/prima/fortran/newuoa/newuoa.f90',
'../../_lib/prima/fortran/uobyqa/initialize.f90',
'../../_lib/prima/fortran/uobyqa/update.f90',
'../../_lib/prima/fortran/uobyqa/geometry.f90',
'../../_lib/prima/fortran/uobyqa/trustregion.f90',
'../../_lib/prima/fortran/uobyqa/uobyqb.f90',
'../../_lib/prima/fortran/uobyqa/uobyqa.f90',
]
)

Expand All @@ -73,28 +47,33 @@ prima_f_c = static_library('prima_f_c',
'-DPRIMAC_STATIC',
'-DPRIMA_REAL_PRECISION=64',
'-DPRIMA_INTEGER_KIND=0',
'-DDONT_COMPILE_BOBYQA',
'-DDONT_COMPILE_LINCOA',
'-DDONT_COMPILE_NEWUOA',
'-DDONT_COMPILE_UOBYQA',
],
include_directories: [ '../../_lib/prima/c/include', ],
link_language: 'fortran',
link_with: prima_f,
sources: [
'../../_lib/prima/c/cintrf.f90',
'../../_lib/prima/c/cobyla_c.f90',
'../../_lib/prima/c/lincoa_c.f90',
'../../_lib/prima/c/bobyqa_c.f90',
'../../_lib/prima/c/newuoa_c.f90',
'../../_lib/prima/c/uobyqa_c.f90',
'../../_lib/prima/c/prima.c'
],
)

prima_link_args = version_link_args
if host_machine.system() == 'darwin'
prima_link_args += ['-Wl,-no_compact_unwind']
endif


_prima_wrapper = py3.extension_module('_prima',
cpp_args: ['-DPRIMAC_STATIC'],
dependencies: [pybind11_dep],
include_directories: [ '../../_lib/prima/c/include'],
install: true,
link_args: version_link_args,
link_args: prima_link_args,
link_with: [prima_f_c],
sources: [ '../../_lib/prima/python/_prima.cpp'],
subdir: 'scipy/optimize/_prima'
Expand Down

0 comments on commit 28aa2ee

Please sign in to comment.