From 1f1c684f38114a850587ffde161ac93311e7e3bb Mon Sep 17 00:00:00 2001 From: "Nicole C." <48625123+nicolecheetham@users.noreply.github.com> Date: Wed, 4 Dec 2024 19:26:40 -0500 Subject: [PATCH] [workspace] Upgrade nlopt_internal to latest release v2.9.1 (#22257) * [workspace] Upgrade nlopt_internal to latest release v2.9.1 --------- Co-authored-by: Rick Poyner --- .../nlopt_internal/package.BUILD.bazel | 4 ++ .../nlopt_internal/patches/gen_enums.patch | 3 +- .../patches/remove_luksan.patch | 41 ------------------- .../upstream/repair_luksan_config.patch | 24 +++++++++++ tools/workspace/nlopt_internal/repository.bzl | 6 +-- 5 files changed, 32 insertions(+), 46 deletions(-) delete mode 100644 tools/workspace/nlopt_internal/patches/remove_luksan.patch create mode 100644 tools/workspace/nlopt_internal/patches/upstream/repair_luksan_config.patch diff --git a/tools/workspace/nlopt_internal/package.BUILD.bazel b/tools/workspace/nlopt_internal/package.BUILD.bazel index 6896cd9ecb0a..d4a1875fd9a8 100644 --- a/tools/workspace/nlopt_internal/package.BUILD.bazel +++ b/tools/workspace/nlopt_internal/package.BUILD.bazel @@ -37,6 +37,10 @@ cmake_configure_file( "SIZEOF_UNSIGNED_INT=", "SIZEOF_UNSIGNED_LONG=", ], + undefines = [ + # Avoid incompatible licensed luksan. + "NLOPT_LUKSAN", + ], ) # Make the config header available as a private library. diff --git a/tools/workspace/nlopt_internal/patches/gen_enums.patch b/tools/workspace/nlopt_internal/patches/gen_enums.patch index 33e822e267d7..44ca7a6275b1 100644 --- a/tools/workspace/nlopt_internal/patches/gen_enums.patch +++ b/tools/workspace/nlopt_internal/patches/gen_enums.patch @@ -8,7 +8,7 @@ Reasoning for not upstreaming this patch: Drake-specific build hack. --- src/api/nlopt-in.hpp.orig +++ src/api/nlopt-in.hpp -@@ -46,6 +46,68 @@ +@@ -46,4 +46,65 @@ // nlopt::* namespace versions of the C enumerated types // AUTOMATICALLY GENERATED, DO NOT EDIT // GEN_ENUMS_HERE @@ -23,7 +23,6 @@ Reasoning for not upstreaming this patch: Drake-specific build hack. + GN_ORIG_DIRECT_L, + GD_STOGO, + GD_STOGO_RAND, -+ LD_LBFGS_NOCEDAL, + LD_LBFGS, + LN_PRAXIS, + LD_VAR1, diff --git a/tools/workspace/nlopt_internal/patches/remove_luksan.patch b/tools/workspace/nlopt_internal/patches/remove_luksan.patch deleted file mode 100644 index d04958ce9f75..000000000000 --- a/tools/workspace/nlopt_internal/patches/remove_luksan.patch +++ /dev/null @@ -1,41 +0,0 @@ -Remove NLopt's dependency on its internal luksan algorithm library. - -That library is licensed under LGPL-2.1+ but the rest of NLopt is -licensed under MIT or similar notice-only licenses, and we really -don't want to distribute this code using dynamic linking. - -Reasoning for not upstreaming this patch: Drake-specific build option. - ---- src/api/optimize.c.orig -+++ src/api/optimize.c -@@ -40,7 +40,9 @@ - - #include "cdirect.h" - -+#if 0 - #include "luksan.h" -+#endif - - #include "crs.h" - -@@ -573,18 +575,18 @@ - return praxis_(nlopt_get_param(opt, "t0_tol", 0.0), DBL_EPSILON, step, ni, x, f_bound, opt, &stop, minf); - } - -+#if 0 - case NLOPT_LD_LBFGS: - return luksan_plis(ni, f, f_data, lb, ub, x, minf, &stop, opt->vector_storage); -- - case NLOPT_LD_VAR1: - case NLOPT_LD_VAR2: - return luksan_plip(ni, f, f_data, lb, ub, x, minf, &stop, opt->vector_storage, algorithm == NLOPT_LD_VAR1 ? 1 : 2); -- - case NLOPT_LD_TNEWTON: - case NLOPT_LD_TNEWTON_RESTART: - case NLOPT_LD_TNEWTON_PRECOND: - case NLOPT_LD_TNEWTON_PRECOND_RESTART: - return luksan_pnet(ni, f, f_data, lb, ub, x, minf, &stop, opt->vector_storage, 1 + (algorithm - NLOPT_LD_TNEWTON) % 2, 1 + (algorithm - NLOPT_LD_TNEWTON) / 2); -+#endif - - case NLOPT_GN_CRS2_LM: - if (!finite_domain(n, lb, ub)) diff --git a/tools/workspace/nlopt_internal/patches/upstream/repair_luksan_config.patch b/tools/workspace/nlopt_internal/patches/upstream/repair_luksan_config.patch new file mode 100644 index 000000000000..f6ebd9b65fc7 --- /dev/null +++ b/tools/workspace/nlopt_internal/patches/upstream/repair_luksan_config.patch @@ -0,0 +1,24 @@ +Repair NLopt's configuration scheme for the Luksan dependency. + +That library is licensed under LGPL-2.1+ but the rest of NLopt is +licensed under MIT or similar notice-only licenses, and we really +don't want to distribute this code using dynamic linking. + +Recent versions of NLopt offer a configuration setting to remove Luksan, +but the piece shown below is missing. + +This patch should probably be upstreamed. + + +--- nlopt_config.h.in ++++ nlopt_config.h.in +@@ -129,6 +129,9 @@ + /* Define if compiled including C++-based routines */ + #cmakedefine NLOPT_CXX + ++/* Define if using LGPL Luksan solvers */ ++#cmakedefine NLOPT_LUKSAN ++ + /* Define to empty if `const' does not conform to ANSI C. */ + #undef const + diff --git a/tools/workspace/nlopt_internal/repository.bzl b/tools/workspace/nlopt_internal/repository.bzl index 223e4cdf14ad..d0aaa7fa7cfa 100644 --- a/tools/workspace/nlopt_internal/repository.bzl +++ b/tools/workspace/nlopt_internal/repository.bzl @@ -6,11 +6,11 @@ def nlopt_internal_repository( github_archive( name = name, repository = "stevengj/nlopt", - commit = "v2.8.0", - sha256 = "e02a4956a69d323775d79fdaec7ba7a23ed912c7d45e439bc933d991ea3193fd", # noqa + commit = "v2.9.1", + sha256 = "1e6c33f8cbdc4138d525f3326c231f14ed50d99345561e85285638c49b64ee93", # noqa build_file = ":package.BUILD.bazel", patches = [ - ":patches/remove_luksan.patch", + ":patches/upstream/repair_luksan_config.patch", ":patches/vendor.patch", ], mirrors = mirrors,