Skip to content

acados: relative rpath #35624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jul 11, 2025
Merged

acados: relative rpath #35624

merged 18 commits into from
Jul 11, 2025

Conversation

Armandpl
Copy link
Contributor

@Armandpl Armandpl commented Jul 2, 2025

No description provided.

@maxime-desroches
Copy link
Contributor

You will probably also need to change the paths for these kernels:

for pathdef, fn in {'TRANSFORM': 'transforms/transform.cl', 'LOADYUV': 'transforms/loadyuv.cl'}.items():
for xenv in (lenv, lenvCython):
xenv['CXXFLAGS'].append(f'-D{pathdef}_PATH=\\"{File(fn).abspath}\\"')

@Armandpl Armandpl changed the title make build portable acados: use rpath Jul 3, 2025
@Armandpl Armandpl changed the title acados: use rpath acados: relative rpath Jul 3, 2025
@Armandpl Armandpl marked this pull request as ready for review July 10, 2025 02:04
@Armandpl
Copy link
Contributor Author

on macos

master:
pytest -n 0 controls/tests/test_lateral_mpc.py

_____________________________________ ERROR collecting selfdrive/controls/tests/test_lateral_mpc.py _____________________________________
ImportError while importing test module '/Users/armand/openpilot/selfdrive/controls/tests/test_lateral_mpc.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
controls/tests/test_lateral_mpc.py:3: in <module>
    from openpilot.selfdrive.controls.lib.lateral_mpc_lib.lat_mpc import LateralMpc
../openpilot/selfdrive/controls/lib/lateral_mpc_lib/lat_mpc.py:13: in <module>
    from openpilot.selfdrive.controls.lib.lateral_mpc_lib.c_generated_code.acados_ocp_solver_pyx import AcadosOcpSolverCython
E   ImportError: dlopen(/Users/armand/openpilot/openpilot/selfdrive/controls/lib/lateral_mpc_lib/c_generated_code/acados_ocp_solver_pyx.so, 0x0002): Library not loaded: selfdrive/controls/lib/lateral_mpc_lib/c_generated_code/libacados_ocp_solver_lat.dylib
E     Referenced from: <F1121830-F6B3-339F-B440-76B75BA0E82A> /Users/armand/openpilot/selfdrive/controls/lib/lateral_mpc_lib/c_generated_code/acados_ocp_solver_pyx.so
E     Reason: tried: 'selfdrive/controls/lib/lateral_mpc_lib/c_generated_code/libacados_ocp_solver_lat.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSselfdrive/controls/lib/lateral_mpc_lib/c_generated_code/libacados_ocp_solver_lat.dylib' (no such file), 'selfdrive/controls/lib/lateral_mpc_lib/c_generated_code/libacados_ocp_solver_lat.dylib' (no such file)
======================================================== short test summary info ========================================================
ERROR controls/tests/test_lateral_mpc.py

pytest -n 0 car/tests/test_cruise_speed.py

========================================================== test session starts ==========================================================
platform darwin -- Python 3.12.9, pytest-8.3.4, pluggy-1.5.0
Using --randomly-seed=2445063021
rootdir: /Users/armand/openpilot
configfile: pyproject.toml
plugins: randomly-3.16.0, cov-6.0.0, cpp-2.6.0, subtests-0.14.1, repeat-0.9.3, asyncio-0.25.3, hypothesis-6.47.5, timeout-2.3.1, mock-3.14.0, xdist-3.6.1
asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=function
collected 17 items

car/tests/test_cruise_speed.py Fatal Python error: Aborted

Current thread 0x00000001fcaec840 (most recent call first):
  File "/Users/armand/openpilot/msgq/__init__.py", line 30 in pub_sock
  File "/Users/armand/openpilot/openpilot/selfdrive/test/longitudinal_maneuvers/plant.py", line 22 in __init__
  File "/Users/armand/openpilot/openpilot/selfdrive/test/longitudinal_maneuvers/maneuver.py", line 32 in evaluate
  File "/Users/armand/openpilot/selfdrive/car/tests/test_cruise_speed.py", line 29 in run_cruise_simulation
  File "/Users/armand/openpilot/selfdrive/car/tests/test_cruise_speed.py", line 43 in test_cruise_speed
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/python.py", line 159 in pytest_pyfunc_call
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/python.py", line 1627 in runtest
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 174 in pytest_runtest_call
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 242 in <lambda>
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 341 in from_call
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 241 in call_and_report
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 132 in runtestprotocol
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 113 in pytest_runtest_protocol
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/main.py", line 362 in pytest_runtestloop
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/main.py", line 337 in _main
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/main.py", line 283 in wrap_session
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/main.py", line 330 in pytest_cmdline_main
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 175 in main
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 201 in console_main
  File "/Users/armand/openpilot/.venv/bin/pytest", line 10 in <module>

Extension modules: numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, common.params_pyx, openpilot.common.params_pyx, capnp.lib.capnp, msgq.ipc_pyx, zstandard.backend_c, _cffi_backend, charset_normalizer.md, requests.packages.charset_normalizer.md, requests.packages.chardet.md, zmq.backend.cython._zmq, setproctitle._setproctitle, common.transformations.transformations, openpilot.common.transformations.transformations, opendbc.can.parser_pyx, acados_template.acados_ocp_solver_pyx, openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.c_generated_code.acados_ocp_solver_pyx, casadi._casadi (total: 30)
zsh: abort      pytest -n 0 car/tests/test_cruise_speed.py

this branch:
pytest -n 0 controls/tests/test_lateral_mpc.py

collected 7 items

controls/tests/test_lateral_mpc.py .......                                                                                        [100%]

========================================================= slowest 10 durations ==========================================================
0.03s call     selfdrive/controls/tests/test_lateral_mpc.py::TestLateralMpc::test_switch_convergence
0.01s teardown selfdrive/controls/tests/test_lateral_mpc.py::TestLateralMpc::test_straight
0.01s call     selfdrive/controls/tests/test_lateral_mpc.py::TestLateralMpc::test_straight

(7 durations < 0.005s hidden.  Use -vv to show these durations.)
=========================================================== 7 passed in 0.41s ===========================================================

pytest -n 0 car/tests/test_cruise_speed.py

========================================================== test session starts ==========================================================
platform darwin -- Python 3.12.9, pytest-8.3.4, pluggy-1.5.0
Using --randomly-seed=410578989
rootdir: /Users/armand/openpilot
configfile: pyproject.toml
plugins: randomly-3.16.0, cov-6.0.0, cpp-2.6.0, subtests-0.14.1, repeat-0.9.3, asyncio-0.25.3, hypothesis-6.47.5, timeout-2.3.1, mock-3.14.0, xdist-3.6.1
asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=function
collected 17 items

car/tests/test_cruise_speed.py Fatal Python error: Aborted

Current thread 0x00000001fcaec840 (most recent call first):
  File "/Users/armand/openpilot/msgq/__init__.py", line 30 in pub_sock
  File "/Users/armand/openpilot/openpilot/selfdrive/test/longitudinal_maneuvers/plant.py", line 22 in __init__
  File "/Users/armand/openpilot/openpilot/selfdrive/test/longitudinal_maneuvers/maneuver.py", line 32 in evaluate
  File "/Users/armand/openpilot/selfdrive/car/tests/test_cruise_speed.py", line 29 in run_cruise_simulation
  File "/Users/armand/openpilot/selfdrive/car/tests/test_cruise_speed.py", line 43 in test_cruise_speed
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/python.py", line 159 in pytest_pyfunc_call
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/python.py", line 1627 in runtest
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 174 in pytest_runtest_call
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 242 in <lambda>
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 341 in from_call
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 241 in call_and_report
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 132 in runtestprotocol
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 113 in pytest_runtest_protocol
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/main.py", line 362 in pytest_runtestloop
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/main.py", line 337 in _main
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/main.py", line 283 in wrap_session
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/main.py", line 330 in pytest_cmdline_main
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 175 in main
  File "/Users/armand/openpilot/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 201 in console_main
  File "/Users/armand/openpilot/.venv/bin/pytest", line 10 in <module>

Extension modules: numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, common.params_pyx, openpilot.common.params_pyx, capnp.lib.capnp, msgq.ipc_pyx, zstandard.backend_c, _cffi_backend, charset_normalizer.md, requests.packages.charset_normalizer.md, requests.packages.chardet.md, zmq.backend.cython._zmq, setproctitle._setproctitle, common.transformations.transformations, openpilot.common.transformations.transformations, opendbc.can.parser_pyx, acados_template.acados_ocp_solver_pyx, openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.c_generated_code.acados_ocp_solver_pyx, casadi._casadi (total: 30)
zsh: abort      pytest -n 0 car/tests/test_cruise_speed.py

@Armandpl Armandpl requested review from Copilot and sshane July 10, 2025 21:17
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the build system to use relative runtime paths (rpath) for acados library dependencies instead of hardcoded absolute paths. The changes improve portability by making the built libraries locate their dependencies relative to their installation location rather than relying on environment variables.

  • Replaces absolute LD_LIBRARY_PATH/DYLD_LIBRARY_PATH environment variables with relative $ORIGIN-based rpath settings
  • Updates both longitudinal and lateral MPC library build configurations to use consistent relative pathing
  • Modifies linking approach for Cython modules to use LIBPATH and explicit library names instead of absolute paths

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
SConstruct Removes hardcoded LD_LIBRARY_PATH and DYLD_LIBRARY_PATH, initializes empty rpath list
selfdrive/controls/lib/longitudinal_mpc_lib/SConscript Adds relative rpath configuration for acados dependencies and updates Cython linking
selfdrive/controls/lib/lateral_mpc_lib/SConscript Adds relative rpath configuration and Darwin-specific linking flags for lateral MPC

@Armandpl Armandpl merged commit 3c43a00 into master Jul 11, 2025
16 checks passed
@Armandpl Armandpl deleted the portable-build branch July 11, 2025 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants