Use libmonitor compiled by gnumake #59

Merged
sb10q merged 1 commits from fsagbuya/nix-servo:pyrp3 into master 2024-05-24 11:12:30 +08:00
Collaborator

Description

Use libmonitor compiled in gnumake for pyrp3, since current cpython extension version is causing bus error:

Reference: https://github.com/elhep/Fast-Servo-Firmware/blob/master/OS/scripts/linien_install_requirements.sh#L28

-bash-5.2# linien-server
linien_server.server           INFO     Start server on port 18862
linien_common.influxdb         INFO     Saved InfluxDB credentials to /root/.local/share/linien/influxdb_credentials.json
linien_server.server           DEBUG    ping  1
linien_server.server           DEBUG    ping  2
Bus error

gdb log:

Starting program: /nix/store/935zxbk14vxpril18bm561blhqn1clk2-system-path/bin/python /nix/store/mlkx7iw4ysaa8mhgyzjglbcbpqh0h6lg-python3.11-linien-server-1.0.1-armv7l-unknown-linux-gnueabihf/bin/.linien-server-wrapped

...

Thread 2 "python" hit Catchpoint 1 (signal SIGBUS), 0xa9daacb8 in read_values ()
   from /nix/store/jd1sl7mvdv2b563qvj0pwbpz0bszigg1-python3.11-pyrp3-1.2.0-armv7l-unknown-linux-gnueabihf/lib/python3.11/site-packages/pyrp3/../monitor.cpython-311-arm-linux-gnueabihf.so
### Description Use `libmonitor` compiled in `gnumake` for pyrp3, since current cpython extension version is causing bus error: Reference: https://github.com/elhep/Fast-Servo-Firmware/blob/master/OS/scripts/linien_install_requirements.sh#L28 ``` -bash-5.2# linien-server linien_server.server INFO Start server on port 18862 linien_common.influxdb INFO Saved InfluxDB credentials to /root/.local/share/linien/influxdb_credentials.json linien_server.server DEBUG ping 1 linien_server.server DEBUG ping 2 Bus error ``` gdb log: ``` Starting program: /nix/store/935zxbk14vxpril18bm561blhqn1clk2-system-path/bin/python /nix/store/mlkx7iw4ysaa8mhgyzjglbcbpqh0h6lg-python3.11-linien-server-1.0.1-armv7l-unknown-linux-gnueabihf/bin/.linien-server-wrapped ... Thread 2 "python" hit Catchpoint 1 (signal SIGBUS), 0xa9daacb8 in read_values () from /nix/store/jd1sl7mvdv2b563qvj0pwbpz0bszigg1-python3.11-pyrp3-1.2.0-armv7l-unknown-linux-gnueabihf/lib/python3.11/site-packages/pyrp3/../monitor.cpython-311-arm-linux-gnueabihf.so ```
sb10q reviewed 2024-05-21 18:09:58 +08:00
flake.nix Outdated
@ -103,0 +114,4 @@
buildPhase = ''
cd monitor
make clean
make all
Owner

Can't those two lines be replaced with just "make"?

Can't those two lines be replaced with just "make"?
sb10q reviewed 2024-05-21 18:12:45 +08:00
flake.nix Outdated
@ -112,1 +134,4 @@
};
postPatch = ''
substituteInPlace pyrp3/raw_memory.py \
--replace "cdll.LoadLibrary(libmonitor_file)" "cdll.LoadLibrary(\"${monitor}/libmonitor.so\")"
Owner

So you're basically injecting the binary libmonitor from pyrp3 e6688acf8bd79d2dbe1d192d09c1a1baf1f6c67b into pyrp3 1.2.0.

Why not either:
(1) use exclusively pyrp3 e6688acf8bd79d2dbe1d192d09c1a1baf1f6c67b
(2) patch the libmonitor source from pyrp3 1.2.0 so it becomes like e6688acf8bd79d2dbe1d192d09c1a1baf1f6c67b

Right now you're duplicating code + compiling libmonitor twice and discarding one, isn't it?

So you're basically injecting the binary libmonitor from pyrp3 e6688acf8bd79d2dbe1d192d09c1a1baf1f6c67b into pyrp3 1.2.0. Why not either: (1) use exclusively pyrp3 e6688acf8bd79d2dbe1d192d09c1a1baf1f6c67b (2) patch the libmonitor source from pyrp3 1.2.0 so it becomes like e6688acf8bd79d2dbe1d192d09c1a1baf1f6c67b Right now you're duplicating code + compiling libmonitor twice and discarding one, isn't it?
Author
Collaborator

Understood.

Understood.
fsagbuya force-pushed pyrp3 from e833b1293a to e516117769 2024-05-22 14:49:25 +08:00 Compare
fsagbuya force-pushed pyrp3 from e516117769 to ba41975e2c 2024-05-22 14:50:50 +08:00 Compare
sb10q reviewed 2024-05-22 15:15:07 +08:00
flake.nix Outdated
@ -120,0 +125,4 @@
'';
postFixup = ''
substituteInPlace $out/${pkgs.python3.sitePackages}/pyrp3/raw_memory.py \
--replace "libmonitor.so" "${placeholder "out"}/lib/libmonitor.so"
Author
Collaborator

It seems that installing libmonitor.so via the Makefile alone is not compatible with nix:

cp libmonitor.so /nix/store/sxr2igfkwhxbagri49b8krmcqz168sim-python3-3.11.8/lib
cp: cannot create regular file '/nix/store/sxr2igfkwhxbagri49b8krmcqz168sim-python3-3.11.8/lib/libmonitor.so': Permission denied

I commented it out and have it only build libmonitor.so and have nix install it via postInstall.

It seems that installing `libmonitor.so` via the Makefile alone is not compatible with nix: ``` cp libmonitor.so /nix/store/sxr2igfkwhxbagri49b8krmcqz168sim-python3-3.11.8/lib cp: cannot create regular file '/nix/store/sxr2igfkwhxbagri49b8krmcqz168sim-python3-3.11.8/lib/libmonitor.so': Permission denied ``` I [commented it out](https://git.m-labs.hk/M-Labs/nix-servo/src/commit/ba41975e2c01da4eda0ddb48946debedae346c3c/fast-servo/linien-pyrp3-monitor.patch#L114-L118) and have it only build libmonitor.so and have nix install it via `postInstall`.
sb10q reviewed 2024-05-22 15:19:44 +08:00
flake.nix Outdated
@ -120,0 +125,4 @@
'';
postFixup = ''
substituteInPlace $out/${pkgs.python3.sitePackages}/pyrp3/raw_memory.py \
--replace "libmonitor.so" "${placeholder "out"}/lib/libmonitor.so"
Owner

I think you don't need placeholder? Just $out would work.

I think you don't need placeholder? Just $out would work.
fsagbuya force-pushed pyrp3 from ba41975e2c to db88e5db59 2024-05-22 15:32:41 +08:00 Compare
sb10q merged commit db88e5db59 into master 2024-05-24 11:12:29 +08:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nix-servo#59
No description provided.