From 63e6ea3207fafa9f1996f96b3d93721d3a919fbe Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Sat, 3 May 2025 17:57:55 +0200 Subject: [PATCH 1/6] update to released servicepoint version --- Cargo.lock | 202 ++++++++++++++++++++++++++++---------------------- Cargo.toml | 8 +- src/bitvec.rs | 10 +-- src/lib.rs | 8 +- src/udp.rs | 26 +++---- 5 files changed, 135 insertions(+), 119 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 968bfeb..a44d39c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,19 +49,20 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.6" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", + "once_cell", "windows-sys", ] [[package]] name = "bitflags" -version = "2.7.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be3f42a67d6d345ecd59f675f3f012d6974981560836e938c22b424b85ce1be" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "bitvec" @@ -77,22 +78,20 @@ dependencies = [ [[package]] name = "bzip2" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bafdbf26611df8c14810e268ddceda071c297570a5fb360ceddf617fe417ef58" +checksum = "49ecfb22d906f800d4fe833b6282cf4dc1c298f5057ca0b5445e5c209735ca47" dependencies = [ "bzip2-sys", - "libc", ] [[package]] name = "bzip2-sys" -version = "0.1.11+1.0.8" +version = "0.1.13+1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +checksum = "225bff33b2141874fe80d71e07d6eec4f85c5c216453dd96388240f96e1acc14" dependencies = [ "cc", - "libc", "pkg-config", ] @@ -117,9 +116,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.9" +version = "1.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8293772165d9345bdaaa39b45b2109591e63fe5e6fbc23c6ff930a048aa310b" +checksum = "8691782945451c1c383942c4874dbe63814f61cb57ef773cda2972682b7bb3c0" dependencies = [ "jobserver", "libc", @@ -134,18 +133,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.26" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8eb5e908ef3a6efbe1ed62520fb7287959888c88485abe072543190ecc66783" +checksum = "eccb054f56cbd38340b380d4a8e69ef1f02f1af43db2f0cc817a4774d80ae071" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.26" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b01801b5fc6a0a232407abc821660c9c6d25a1cafc0d4f85f29fb8d9afc121" +checksum = "efd9466fac8543255d3b1fcad4762c5e116ffe808c8a3043d4263cd4fd4862a2" dependencies = [ "anstream", "anstyle", @@ -176,15 +175,15 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" dependencies = [ "libc", "windows-sys", @@ -198,9 +197,9 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "flate2" -version = "1.0.35" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" +checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" dependencies = [ "crc32fast", "miniz_oxide", @@ -214,20 +213,21 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "getrandom" -version = "0.2.15" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" dependencies = [ "cfg-if", "libc", + "r-efi", "wasi", ] [[package]] name = "hashbrown" -version = "0.15.2" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" [[package]] name = "heck" @@ -237,9 +237,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "indexmap" -version = "2.7.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", "hashbrown", @@ -253,36 +253,37 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jobserver" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" dependencies = [ + "getrandom", "libc", ] [[package]] name = "libc" -version = "0.2.169" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "linux-raw-sys" -version = "0.4.15" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" [[package]] name = "log" -version = "0.4.22" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "memchr" @@ -292,43 +293,49 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miniz_oxide" -version = "0.8.2" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" +checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" dependencies = [ "adler2", ] [[package]] name = "once_cell" -version = "1.20.2" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "pkg-config" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + [[package]] name = "radium" version = "0.7.0" @@ -347,9 +354,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.43" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" +checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" dependencies = [ "bitflags", "errno", @@ -360,24 +367,24 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "serde" -version = "1.0.217" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.217" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -386,9 +393,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.135" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", @@ -407,8 +414,9 @@ dependencies = [ [[package]] name = "servicepoint" -version = "0.13.2" -source = "git+https://git.berlin.ccc.de/servicepoint/servicepoint/?branch=next#114385868af03f8cba7c87a630b501bb0106d140" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce70bae3641ccafdeb9832ac367efd51243e0708ef35151ad8c2c4ee578aa4a" dependencies = [ "bitvec", "bzip2", @@ -442,9 +450,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.96" +version = "2.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" +checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" dependencies = [ "proc-macro2", "quote", @@ -459,11 +467,10 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.15.0" +version = "3.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" +checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" dependencies = [ - "cfg-if", "fastrand", "getrandom", "once_cell", @@ -473,18 +480,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", @@ -493,9 +500,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.19" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae" dependencies = [ "serde", "serde_spanned", @@ -505,31 +512,38 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.22" +version = "0.22.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", + "toml_write", "winnow", ] [[package]] -name = "unicode-ident" -version = "1.0.14" +name = "toml_write" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" +checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076" + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "utf8parse" @@ -545,9 +559,12 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] [[package]] name = "windows-sys" @@ -624,13 +641,22 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.24" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" +checksum = "d9fb597c990f03753e08d3c29efbfcf2019a003b4bf4ba19225c158e1549f0f3" dependencies = [ "memchr", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags", +] + [[package]] name = "wyz" version = "0.5.1" @@ -642,27 +668,27 @@ dependencies = [ [[package]] name = "zstd" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "7.2.1" +version = "7.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059" +checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" dependencies = [ "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.13+zstd.1.5.6" +version = "2.0.15+zstd.1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" +checksum = "eb81183ddd97d0c74cedf1d50d85c8d08c1b8b68ee863bdee9e706eedba1a237" dependencies = [ "cc", "pkg-config", diff --git a/Cargo.toml b/Cargo.toml index cc7b596..a6b0075 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,16 +19,12 @@ cbindgen = "0.28.0" [dependencies.servicepoint] package = "servicepoint" -version = "0.13.2" +version = "0.14.0" default-features = false -features = ["protocol_udp"] -git = "https://git.berlin.ccc.de/servicepoint/servicepoint/" -branch = "next" [features] -protocol_udp = ["servicepoint/protocol_udp"] all_compressions = ["servicepoint/all_compressions"] -default = ["all_compressions", "servicepoint/default", "protocol_udp"] +default = ["all_compressions", "servicepoint/default"] [lints.rust] missing-docs = "warn" diff --git a/src/bitvec.rs b/src/bitvec.rs index 82c0fbe..3cd5abb 100644 --- a/src/bitvec.rs +++ b/src/bitvec.rs @@ -1,7 +1,5 @@ use crate::{heap_drop, heap_move, heap_move_nonnull, heap_remove, ByteSlice}; -use servicepoint::{ - BinaryOperation, BitVecCommand, BitVecU8Msb0, CompressionCode, Packet, -}; +use servicepoint::{BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Packet}; use std::ptr::NonNull; /// A vector of bits @@ -12,7 +10,7 @@ use std::ptr::NonNull; /// sp_bitvec_set(vec, 5, true); /// sp_bitvec_free(vec); /// ``` -pub struct SPBitVec(pub(crate) BitVecU8Msb0); +pub struct SPBitVec(pub(crate) DisplayBitVec); impl Clone for SPBitVec { fn clone(&self) -> Self { @@ -33,7 +31,7 @@ impl Clone for SPBitVec { /// - when `size` is not divisible by 8. #[no_mangle] pub unsafe extern "C" fn sp_bitvec_new(size: usize) -> NonNull { - heap_move_nonnull(SPBitVec(BitVecU8Msb0::repeat(false, size))) + heap_move_nonnull(SPBitVec(DisplayBitVec::repeat(false, size))) } /// Interpret the data as a series of bits and load then into a new [SPBitVec] instance. @@ -42,7 +40,7 @@ pub unsafe extern "C" fn sp_bitvec_new(size: usize) -> NonNull { #[no_mangle] pub unsafe extern "C" fn sp_bitvec_load(data: ByteSlice) -> NonNull { let data = unsafe { data.as_slice() }; - heap_move_nonnull(SPBitVec(BitVecU8Msb0::from_slice(data))) + heap_move_nonnull(SPBitVec(DisplayBitVec::from_slice(data))) } /// Clones a [SPBitVec]. diff --git a/src/lib.rs b/src/lib.rs index 57192e0..db6361b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,7 +34,8 @@ pub use crate::cp437_grid::*; pub use crate::packet::*; pub use servicepoint::CommandCode; use std::ptr::NonNull; -pub use typed_command::*; +pub use crate::typed_command::*; +pub use crate::udp::*; mod bitmap; mod bitvec; @@ -44,13 +45,8 @@ mod char_grid; mod cp437_grid; mod packet; mod typed_command; - -#[cfg(feature = "protocol_udp")] mod udp; -#[cfg(feature = "protocol_udp")] -pub use udp::*; - use std::time::Duration; /// Actual hardware limit is around 28-29ms/frame. Rounded up for less dropped packets. diff --git a/src/udp.rs b/src/udp.rs index 93e0a21..bb04454 100644 --- a/src/udp.rs +++ b/src/udp.rs @@ -1,7 +1,7 @@ use crate::{heap_drop, heap_move, heap_remove}; -use servicepoint::{Connection, Header, Packet, TypedCommand, UdpConnection}; +use servicepoint::{Header, Packet, TypedCommand, UdpSocketExt}; use std::ffi::{c_char, CStr}; -use std::net::{Ipv4Addr, SocketAddrV4}; +use std::net::{Ipv4Addr, SocketAddrV4, UdpSocket}; use std::ptr::NonNull; /// Creates a new instance of [UdpConnection]. @@ -18,11 +18,11 @@ use std::ptr::NonNull; #[no_mangle] pub unsafe extern "C" fn sp_udp_open( host: NonNull, -) -> *mut UdpConnection { +) -> *mut UdpSocket { let host = unsafe { CStr::from_ptr(host.as_ptr()) } .to_str() .expect("Bad encoding"); - let connection = match UdpConnection::open(host) { + let connection = match UdpSocket::bind_connect(host) { Err(_) => return std::ptr::null_mut(), Ok(value) => value, }; @@ -48,9 +48,9 @@ pub unsafe extern "C" fn sp_udp_open_ipv4( ip3: u8, ip4: u8, port: u16, -) -> *mut UdpConnection { +) -> *mut UdpSocket { let addr = SocketAddrV4::new(Ipv4Addr::from([ip1, ip2, ip3, ip4]), port); - let connection = match UdpConnection::open(addr) { + let connection = match UdpSocket::bind_connect(addr) { Err(_) => return std::ptr::null_mut(), Ok(value) => value, }; @@ -64,11 +64,11 @@ pub unsafe extern "C" fn sp_udp_open_ipv4( /// returns: true in case of success #[no_mangle] pub unsafe extern "C" fn sp_udp_send_packet( - connection: NonNull, + connection: NonNull, packet: NonNull, ) -> bool { let packet = unsafe { heap_remove(packet) }; - unsafe { connection.as_ref().send(packet) }.is_ok() + unsafe { connection.as_ref().send(&Vec::from(packet)) }.is_ok() } /// Sends a [TypedCommand] to the display using the [UdpConnection]. @@ -84,11 +84,11 @@ pub unsafe extern "C" fn sp_udp_send_packet( /// ``` #[no_mangle] pub unsafe extern "C" fn sp_udp_send_command( - connection: NonNull, + connection: NonNull, command: NonNull, ) -> bool { let command = unsafe { heap_remove(command) }; - unsafe { connection.as_ref().send(command) }.is_ok() + unsafe { connection.as_ref().send_command(command) }.is_some() } /// Sends a [Header] to the display using the [UdpConnection]. @@ -102,18 +102,18 @@ pub unsafe extern "C" fn sp_udp_send_command( /// ``` #[no_mangle] pub unsafe extern "C" fn sp_udp_send_header( - udp_connection: NonNull, + udp_connection: NonNull, header: Header, ) -> bool { let packet = Packet { header, payload: vec![], }; - unsafe { udp_connection.as_ref() }.send(packet).is_ok() + unsafe { udp_connection.as_ref() }.send(&Vec::from(packet)).is_ok() } /// Closes and deallocates a [UdpConnection]. #[no_mangle] -pub unsafe extern "C" fn sp_udp_free(connection: NonNull) { +pub unsafe extern "C" fn sp_udp_free(connection: NonNull) { unsafe { heap_drop(connection) } } From 1fc4f7f49750cbc5f5ab3712c4bc29195e0c00b2 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Thu, 24 Apr 2025 22:47:27 +0200 Subject: [PATCH 2/6] a bunch of options for the Makefile --- example/Makefile | 150 ++++++++++++++++---------- example/{ => src}/announce.c | 10 +- example/{ => src}/brightness_tester.c | 4 +- example/{ => src}/random_stuff.c | 5 +- flake.nix | 20 ++-- include/servicepoint.h | 35 +++--- src/lib.rs | 3 + 7 files changed, 133 insertions(+), 94 deletions(-) rename example/{ => src}/announce.c (82%) rename example/{ => src}/brightness_tester.c (84%) rename example/{ => src}/random_stuff.c (72%) diff --git a/example/Makefile b/example/Makefile index 7e5bfe7..a35aa5c 100644 --- a/example/Makefile +++ b/example/Makefile @@ -1,85 +1,119 @@ -CC := gcc -CARGO := rustup run nightly cargo +CARGO ?= cargo +STRIP ?= strip -TARGET := x86_64-unknown-linux-musl -PROFILE := size-optimized -FEATURES := protocol_udp +FEATURES := THIS_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) -REPO_ROOT := $(THIS_DIR)/.. -RUST_TARGET_DIR := $(REPO_ROOT)/target/$(TARGET)/$(PROFILE) +REPO_ROOT := $(realpath $(THIS_DIR)/..) export SERVICEPOINT_HEADER_OUT := $(REPO_ROOT)/include -RUSTFLAGS := -Zlocation-detail=none \ - -Zfmt-debug=none \ - -C linker=musl-gcc \ - -C link-arg=-s \ - -C link-arg=--gc-sections \ - -C link-arg=-z,norelro \ - -C link-arg=--hash-style=gnu \ - --crate-type=staticlib \ - -C panic=abort +override CFG_MUSL := $(if $(CFG_MUSL),$(CFG_MUSL),$(if $(MUSL),$(MUSL),0)) +override CFG_PROFILE := $(if $(CFG_PROFILE),$(CFG_PROFILE),$(if $(PROFILE),$(PROFILE),release)) -CARGOFLAGS := --manifest-path=$(REPO_ROOT)/Cargo.toml \ - --profile=$(PROFILE) \ +CCFLAGS += -Wall -fwhole-program + +STRIPFLAGS := -s --strip-unneeded -R .comment -R .gnu.version -R .note -R .note.gnu.build-id -R .note.ABI-tag + +ifeq ($(CFG_MUSL), 1) + TARGET ?= x86_64-unknown-linux-musl + CC ?= musl-gcc + CCFLAGS += -static -lservicepoint_binding_c + RUSTFLAGS += --crate-type=staticlib +else + TARGET ?= x86_64-unknown-linux-gnu + CC ?= gcc + #CCFLAGS += -shared + CCFLAGS += -Wl,-Bstatic -lservicepoint_binding_c -Wl,-Bdynamic +endif + +#ifeq ($(CFG_PROFILE), size-optimized) +# CCFLAGS += -nodefaultlibs -lc +#endif + +RUST_TARGET_DIR := $(REPO_ROOT)/target/$(TARGET)/$(CFG_PROFILE) +OUT_DIR := $(realpath $(THIS_DIR)/out/) + +ifeq ($(CFG_PROFILE), size-optimized) + CARGO_PROFILE := size-optimized + CCFLAGS += -Oz \ + -fwrapv -fomit-frame-pointer -fno-stack-protector\ + -fno-unroll-loops \ + -fno-unwind-tables -fno-asynchronous-unwind-tables \ + -fmerge-all-constants \ + -Wl,-z,norelro \ + -Wl,--hash-style=gnu \ + -fvisibility=hidden \ + -Bsymbolic \ + -Wl,--exclude-libs,ALL \ + -fno-ident \ + -fno-exceptions + CARGOFLAGS += -Zbuild-std="core,std,alloc,proc_macro,panic_abort" \ + -Zbuild-std-features="panic_immediate_abort" + RUSTFLAGS += -Zlocation-detail=none \ + -Zfmt-debug=none \ + -C link-arg=-z,norelro \ + -C panic=abort + #-C link-arg=--hash-style=gnu +else ifeq ($(CFG_PROFILE), release) + CARGO_PROFILE := release + CCFLAGS += -O2 +else ifeq ($(CFG_PROFILE), debug) + CCFLAGS += -Og + CARGO_PROFILE := dev +else + CFG_PROFILE := $(error "PROFILE has to be set to one of: debug, release, size-optimized") +endif + +CARGOFLAGS += --manifest-path=$(REPO_ROOT)/Cargo.toml \ + --profile=$(CARGO_PROFILE) \ --no-default-features \ --features=$(FEATURES) \ - --target=$(TARGET) \ - -Zbuild-std="core,std,alloc,proc_macro,panic_abort" \ - -Zbuild-std-features="panic_immediate_abort" \ + --target=$(TARGET) -CCFLAGS := -static -Os \ - -ffunction-sections -fdata-sections \ - -fwrapv -fomit-frame-pointer -fno-stack-protector\ - -fwhole-program \ - -nodefaultlibs -lservicepoint_binding_c -lc \ - -Wl,--gc-sections \ - -fno-unroll-loops \ - -fno-unwind-tables -fno-asynchronous-unwind-tables \ - -fmerge-all-constants \ - -Wl,-z,norelro \ - -Wl,--hash-style=gnu \ - -fvisibility=hidden \ - -Bsymbolic \ - -Wl,--exclude-libs,ALL \ - -fno-ident \ - -Wall - #-fuse-ld=gold \ - -fno-exceptions - #-Wl,--icf=all \ +ifneq ($(CFG_PROFILE), debug) + CCFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections + RUSTFLAGS += -C link-arg=-s -C link-arg=-Wl,--gc-sections +endif -STRIPFLAGS := -s --strip-unneeded -R .comment -R .gnu.version -R .comment -R .note -R .note.gnu.build-id -R .note.ABI-tag +ifeq ($(LTO), 1) + CCFLAGS += -flto +endif -_c_src := $(wildcard *.c) -_programs := $(basename $(_c_src)) +_c_src := $(wildcard ./src/*.c) +_programs := $(basename $(notdir $(_c_src))) _bins := $(addprefix out/, $(_programs)) _unstripped_bins := $(addsuffix _unstripped, $(_bins)) _run_programs := $(addprefix run_, $(_programs)) _rs_src := $(wildcard ../src/**.rs) ../Cargo.lock ../Cargo.toml ../cbindgen.toml +_sp_artifacts := $(SERVICEPOINT_HEADER_OUT)/servicepoint.h $(RUST_TARGET_DIR)/libservicepoint_binding_c.a $(RUST_TARGET_DIR)/libservicepoint_binding_c.so all: $(_bins) -clean: - rm -r out || true - rm include/servicepoint.h || true +clean: clean-c clean-rust + +clean-c: + rm -r $(OUT_DIR) || true + +clean-rust: + rm $(SERVICEPOINT_HEADER_OUT)/servicepoint.h || true cargo clean -PHONY: all clean sizes $(_run_programs) +.PHONY: all clean sizes $(_run_programs) clean-c clean-rust -$(_unstripped_bins): out/%_unstripped: %.c $(SERVICEPOINT_HEADER_OUT)/servicepoint.h $(RUST_TARGET_DIR)/libservicepoint_binding_c.a +$(_unstripped_bins): out/%_unstripped: src/%.c $(SERVICEPOINT_HEADER_OUT)/servicepoint.h $(_sp_artifacts) mkdir -p out || true - ${CC} $^ \ + ${CC} $< \ -I $(SERVICEPOINT_HEADER_OUT) \ - -L $(RUST_TARGET_DIR)\ + -L $(RUST_TARGET_DIR) \ $(CCFLAGS) \ -o $@ $(_bins): out/%: out/%_unstripped - strip $(STRIPFLAGS) $^ -o $@ + $(STRIP) $(STRIPFLAGS) $^ -o $@ -$(SERVICEPOINT_HEADER_OUT)/servicepoint.h $(RUST_TARGET_DIR)/libservicepoint_binding_c.a: $(_rs_src) - mkdir -p include || true - # generate servicepoint header and binary to link against +$(_sp_artifacts): $(_rs_src) + mkdir -p $(SERVICEPOINT_HEADER_OUT) || true + # generate servicepoint header and library to link against ${CARGO} rustc $(CARGOFLAGS) -- $(RUSTFLAGS) $(_run_programs): run_%: out/% FORCE @@ -88,9 +122,9 @@ $(_run_programs): run_%: out/% FORCE sizes: $(_bins) ls -lB out -#analyze-size: out/example_unstripped -# nm --print-size --size-sort --reverse-sort --radix=d --demangle out/example_unstripped \ -# | awk '{size=$$2+0; print size "\t" $$4}' \ -# | less +analyze-size: out/$(BIN)_unstripped + nm --print-size --size-sort --reverse-sort --radix=d --demangle $(OUT_DIR)/$(BIN)_unstripped \ + | awk '{size=$$2+0; print size "\t" $$4}' \ + | less FORCE: ; diff --git a/example/announce.c b/example/src/announce.c similarity index 82% rename from example/announce.c rename to example/src/announce.c index 737eff5..d256cff 100644 --- a/example/announce.c +++ b/example/src/announce.c @@ -1,8 +1,12 @@ +#include #include "servicepoint.h" + int main(void) { - //UdpConnection *connection = sp_udp_open_ipv4(172, 23, 42, 29, 2342); - UdpConnection *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342); + printf("test\n"); + + UdpSocket *connection = sp_udp_open_ipv4(172, 23, 42, 29, 2342); + //UdpSocket *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342); if (connection == NULL) return 1; @@ -11,7 +15,7 @@ int main(void) { CharGrid *grid = sp_char_grid_new(5, 2); if (grid == NULL) return 1; - + sp_char_grid_set(grid, 0, 0, 'H'); sp_char_grid_set(grid, 1, 0, 'e'); sp_char_grid_set(grid, 2, 0, 'l'); diff --git a/example/brightness_tester.c b/example/src/brightness_tester.c similarity index 84% rename from example/brightness_tester.c rename to example/src/brightness_tester.c index d06d30d..c3e42ba 100644 --- a/example/brightness_tester.c +++ b/example/src/brightness_tester.c @@ -1,8 +1,8 @@ #include "servicepoint.h" int main(void) { - // UdpConnection *connection = sp_udp_open_ipv4(172, 23, 42, 29, 2342); - UdpConnection *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342); + UdpSocket *connection = sp_udp_open_ipv4(172, 23, 42, 29, 2342); + //UdpSocket *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342); if (connection == NULL) return -1; diff --git a/example/random_stuff.c b/example/src/random_stuff.c similarity index 72% rename from example/random_stuff.c rename to example/src/random_stuff.c index ca5a14d..96beefb 100644 --- a/example/random_stuff.c +++ b/example/src/random_stuff.c @@ -1,8 +1,7 @@ -#include #include "servicepoint.h" int main(void) { - UdpConnection *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342); + UdpSocket *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342); if (connection == NULL) return 1; @@ -17,7 +16,7 @@ int main(void) { return 1; Header *header = sp_packet_get_header(packet); - printf("[%d, %d, %d, %d, %d]\n", header->command_code, header->a, header->b, header->c, header->d); + // printf("[%d, %d, %d, %d, %d]\n", header->command_code, header->a, header->b, header->c, header->d); sp_udp_send_packet(connection, packet); diff --git a/flake.nix b/flake.nix index b4f874f..9d67ae9 100644 --- a/flake.nix +++ b/flake.nix @@ -33,16 +33,17 @@ { pkgs, system }: { default = pkgs.mkShell rec { - buildInputs = with pkgs;[ + buildInputs = with pkgs; [ xe xz - libgcc - #glibc.static - musl - libunwind - ]; + #libgcc + #glibc + pkgsStatic.musl + # libunwind - nativeBuildInputs = with pkgs;[ + ]; + + nativeBuildInputs = with pkgs; [ (pkgs.symlinkJoin { name = "rust-toolchain"; paths = with pkgs; [ @@ -57,11 +58,14 @@ ]; }) gcc + gdb + pkgsStatic.gcc gnumake pkg-config ]; - RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + #RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + CARGO = "rustup run nightly cargo"; }; } ); diff --git a/include/servicepoint.h b/include/servicepoint.h index 77d2e36..5863ef5 100644 --- a/include/servicepoint.h +++ b/include/servicepoint.h @@ -226,13 +226,9 @@ typedef struct SPBitVec SPBitVec; typedef struct TypedCommand TypedCommand; /** - * A connection using the UDP protocol. - * - * Use this when sending commands directly to the display. - * - * Requires the feature "`protocol_udp`" which is enabled by default. + * This is a type only used by cbindgen to have a type for pointers. */ -typedef struct UdpConnection UdpConnection; +typedef struct UdpSocket UdpSocket; /** * A 2D grid of values. @@ -298,7 +294,7 @@ typedef struct { * grid.set(1, 1, Brightness::MIN); * * # let connection = FakeConnection; - * connection.send(BrightnessGridCommand { + * connection.send_command(BrightnessGridCommand { * origin: Origin::new(3, 7), * grid * }).unwrap() @@ -318,7 +314,7 @@ typedef ValueGrid_Brightness BrightnessGrid; * * let b = Brightness::try_from(7).unwrap(); * # let connection = FakeConnection; - * let result = connection.send(GlobalBrightnessCommand::from(b)); + * let result = connection.send_command(GlobalBrightnessCommand::from(b)); * ``` */ typedef uint8_t Brightness; @@ -347,7 +343,7 @@ typedef uint8_t Brightness; * * # let connection = FakeConnection; * let command = CharGridCommand { origin: Origin::ZERO, grid }; - * connection.send(command).unwrap() + * connection.send_command(command).unwrap() * ``` */ typedef ValueGrid_char CharGrid; @@ -1220,7 +1216,7 @@ bool sp_u16_to_command_code(uint16_t code, /** * Closes and deallocates a [UdpConnection]. */ -void sp_udp_free(UdpConnection */*notnull*/ connection); +void sp_udp_free(UdpSocket */*notnull*/ connection); /** * Creates a new instance of [UdpConnection]. @@ -1235,7 +1231,7 @@ void sp_udp_free(UdpConnection */*notnull*/ connection); * sp_udp_send_command(connection, sp_command_clear()); * ``` */ -UdpConnection *sp_udp_open(char */*notnull*/ host); +UdpSocket *sp_udp_open(char */*notnull*/ host); /** * Creates a new instance of [UdpConnection]. @@ -1250,11 +1246,11 @@ UdpConnection *sp_udp_open(char */*notnull*/ host); * sp_udp_send_command(connection, sp_command_clear()); * ``` */ -UdpConnection *sp_udp_open_ipv4(uint8_t ip1, - uint8_t ip2, - uint8_t ip3, - uint8_t ip4, - uint16_t port); +UdpSocket *sp_udp_open_ipv4(uint8_t ip1, + uint8_t ip2, + uint8_t ip3, + uint8_t ip4, + uint16_t port); /** * Sends a [TypedCommand] to the display using the [UdpConnection]. @@ -1269,7 +1265,7 @@ UdpConnection *sp_udp_open_ipv4(uint8_t ip1, * sp_udp_send_command(connection, sp_command_brightness(5)); * ``` */ -bool sp_udp_send_command(UdpConnection */*notnull*/ connection, +bool sp_udp_send_command(UdpSocket */*notnull*/ connection, TypedCommand */*notnull*/ command); /** @@ -1283,8 +1279,7 @@ bool sp_udp_send_command(UdpConnection */*notnull*/ connection, * sp_udp_send_header(connection, sp_command_brightness(5)); * ``` */ -bool sp_udp_send_header(UdpConnection */*notnull*/ udp_connection, - Header header); +bool sp_udp_send_header(UdpSocket */*notnull*/ udp_connection, Header header); /** * Sends a [Packet] to the display using the [UdpConnection]. @@ -1293,7 +1288,7 @@ bool sp_udp_send_header(UdpConnection */*notnull*/ udp_connection, * * returns: true in case of success */ -bool sp_udp_send_packet(UdpConnection */*notnull*/ connection, +bool sp_udp_send_packet(UdpSocket */*notnull*/ connection, Packet */*notnull*/ packet); #ifdef __cplusplus diff --git a/src/lib.rs b/src/lib.rs index db6361b..47b21d5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,3 +67,6 @@ pub(crate) unsafe fn heap_drop(x: NonNull) { pub(crate) unsafe fn heap_remove(x: NonNull) -> T { unsafe { *Box::from_raw(x.as_ptr()) } } + +/// This is a type only used by cbindgen to have a type for pointers. +pub struct UdpSocket; \ No newline at end of file From 8808dc3c6b977a8f834b3fa46cd9abbf3095532d Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Thu, 24 Apr 2025 23:31:34 +0200 Subject: [PATCH 3/6] build all variations in CI to keep track of what works --- .github/workflows/rust.yml | 73 ++++++++++++++++++++++++++++++-------- example/Makefile | 6 ++-- 2 files changed, 62 insertions(+), 17 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9089694..fcd39ad 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -13,32 +13,77 @@ env: RUSTFLAGS: "-Dwarnings" jobs: - build: - + build-gnu-apt: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - name: Update repos run: sudo apt-get update -qq - - name: Install rust toolchain - run: sudo apt-get install -qy cargo rust-clippy - - name: install lzma - run: sudo apt-get install -qy liblzma-dev - - name: install gcc - run: sudo apt-get install -qy gcc make + - name: Install toolchain + run: sudo apt-get install -qy cargo rust-clippy liblzma-dev gcc make pkgconf - name: Run Clippy run: cargo clippy + - name: build + run: cargo build + - name: generate bindings run: ./generate-binding.sh - name: check that generated files did not change run: output=$(git status --porcelain) && [ -z "$output" ] - - - name: build - run: cargo build - - name: build example - run: cd example && make + - name: build example -- glibc release + run: cd example && make clean && make TARGET=aarch64-unknown-linux-gnu PROFILE=release + - name: build example -- glibc debug + run: cd example && make clean && make TARGET=aarch64-unknown-linux-gnu PROFILE=debug + + # this _should_ have been -stable, but there is a bug when running in the container ("Invalid cross-device link") + build-musl-beta: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Update repos + run: sudo apt-get update -qq + - name: Install toolchain + run: sudo apt-get install -qy liblzma-dev gcc make pkgconf musl-dev musl-tools rustup + - name: install rust target + run: rustup default beta && rustup target add aarch64-unknown-linux-musl && rustup component add rust-src && rustup update + + - name: build example -- musl release + run: cd example && make clean && make TARGET=aarch64-unknown-linux-musl PROFILE=release MUSL=1 CARGO="rustup run beta cargo" + - name: build example -- musl debug + run: cd example && make clean && make TARGET=aarch64-unknown-linux-musl PROFILE=debug MUSL=1 CARGO="rustup run beta cargo" + + build-size-gnu-unstable: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Update repos + run: sudo apt-get update -qq + - name: Install toolchain + run: sudo apt-get install -qy liblzma-dev gcc make pkgconf rustup + - name: install rust targets + run: rustup toolchain install nightly -t aarch64-unknown-linux-gnu -c rust-src --no-self-update + + - name: build example -- glibc size-optimized + run: cd example && make clean && make TARGET=aarch64-unknown-linux-gnu PROFILE=size-optimized CARGO="rustup run nightly cargo" + + + build-size-musl-unstable: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Update repos + run: sudo apt-get update -qq + - name: Install toolchain + run: sudo apt-get install -qy liblzma-dev gcc make pkgconf musl-dev musl-tools rustup + - name: install rust targets + run: rustup toolchain install nightly -t aarch64-unknown-linux-musl -c rust-src --no-self-update + + - name: build example -- musl size-optimized + run: cd example && make clean && make TARGET=aarch64-unknown-linux-musl PROFILE=size-optimized MUSL=1 LTO=1 CARGO="rustup run nightly cargo" diff --git a/example/Makefile b/example/Makefile index a35aa5c..353e298 100644 --- a/example/Makefile +++ b/example/Makefile @@ -1,7 +1,7 @@ CARGO ?= cargo STRIP ?= strip -FEATURES := +FEATURES := "" THIS_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) REPO_ROOT := $(realpath $(THIS_DIR)/..) @@ -10,7 +10,7 @@ export SERVICEPOINT_HEADER_OUT := $(REPO_ROOT)/include override CFG_MUSL := $(if $(CFG_MUSL),$(CFG_MUSL),$(if $(MUSL),$(MUSL),0)) override CFG_PROFILE := $(if $(CFG_PROFILE),$(CFG_PROFILE),$(if $(PROFILE),$(PROFILE),release)) -CCFLAGS += -Wall -fwhole-program +CCFLAGS += -Wall -fwhole-program -fPIE -pie STRIPFLAGS := -s --strip-unneeded -R .comment -R .gnu.version -R .note -R .note.gnu.build-id -R .note.ABI-tag @@ -18,7 +18,7 @@ ifeq ($(CFG_MUSL), 1) TARGET ?= x86_64-unknown-linux-musl CC ?= musl-gcc CCFLAGS += -static -lservicepoint_binding_c - RUSTFLAGS += --crate-type=staticlib + RUSTFLAGS += --crate-type=staticlib -Ctarget-feature=-crt-static else TARGET ?= x86_64-unknown-linux-gnu CC ?= gcc From c4ccc85e6e450eb260bffa42b188c6579a946ceb Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Sat, 3 May 2025 17:57:55 +0200 Subject: [PATCH 4/6] update to released servicepoint version --- Cargo.lock | 202 ++++++++++++++++++++++++++++---------------------- Cargo.toml | 8 +- src/bitvec.rs | 10 +-- src/lib.rs | 8 +- src/udp.rs | 26 +++---- 5 files changed, 135 insertions(+), 119 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 968bfeb..46f05cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,19 +49,20 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.6" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", + "once_cell", "windows-sys", ] [[package]] name = "bitflags" -version = "2.7.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be3f42a67d6d345ecd59f675f3f012d6974981560836e938c22b424b85ce1be" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "bitvec" @@ -77,22 +78,20 @@ dependencies = [ [[package]] name = "bzip2" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bafdbf26611df8c14810e268ddceda071c297570a5fb360ceddf617fe417ef58" +checksum = "49ecfb22d906f800d4fe833b6282cf4dc1c298f5057ca0b5445e5c209735ca47" dependencies = [ "bzip2-sys", - "libc", ] [[package]] name = "bzip2-sys" -version = "0.1.11+1.0.8" +version = "0.1.13+1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +checksum = "225bff33b2141874fe80d71e07d6eec4f85c5c216453dd96388240f96e1acc14" dependencies = [ "cc", - "libc", "pkg-config", ] @@ -117,9 +116,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.9" +version = "1.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8293772165d9345bdaaa39b45b2109591e63fe5e6fbc23c6ff930a048aa310b" +checksum = "8691782945451c1c383942c4874dbe63814f61cb57ef773cda2972682b7bb3c0" dependencies = [ "jobserver", "libc", @@ -134,18 +133,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.26" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8eb5e908ef3a6efbe1ed62520fb7287959888c88485abe072543190ecc66783" +checksum = "eccb054f56cbd38340b380d4a8e69ef1f02f1af43db2f0cc817a4774d80ae071" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.26" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b01801b5fc6a0a232407abc821660c9c6d25a1cafc0d4f85f29fb8d9afc121" +checksum = "efd9466fac8543255d3b1fcad4762c5e116ffe808c8a3043d4263cd4fd4862a2" dependencies = [ "anstream", "anstyle", @@ -176,15 +175,15 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" dependencies = [ "libc", "windows-sys", @@ -198,9 +197,9 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "flate2" -version = "1.0.35" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" +checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" dependencies = [ "crc32fast", "miniz_oxide", @@ -214,20 +213,21 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "getrandom" -version = "0.2.15" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" dependencies = [ "cfg-if", "libc", + "r-efi", "wasi", ] [[package]] name = "hashbrown" -version = "0.15.2" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" [[package]] name = "heck" @@ -237,9 +237,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "indexmap" -version = "2.7.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", "hashbrown", @@ -253,36 +253,37 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jobserver" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" dependencies = [ + "getrandom", "libc", ] [[package]] name = "libc" -version = "0.2.169" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "linux-raw-sys" -version = "0.4.15" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" [[package]] name = "log" -version = "0.4.22" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "memchr" @@ -292,43 +293,49 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miniz_oxide" -version = "0.8.2" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" +checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" dependencies = [ "adler2", ] [[package]] name = "once_cell" -version = "1.20.2" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "pkg-config" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + [[package]] name = "radium" version = "0.7.0" @@ -347,9 +354,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.43" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" +checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" dependencies = [ "bitflags", "errno", @@ -360,24 +367,24 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "serde" -version = "1.0.217" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.217" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -386,9 +393,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.135" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", @@ -407,8 +414,9 @@ dependencies = [ [[package]] name = "servicepoint" -version = "0.13.2" -source = "git+https://git.berlin.ccc.de/servicepoint/servicepoint/?branch=next#114385868af03f8cba7c87a630b501bb0106d140" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6bd5cfa49c73aeecb344680ffbf697abf73e0563a441b93b9723ae43867500f" dependencies = [ "bitvec", "bzip2", @@ -442,9 +450,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.96" +version = "2.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" +checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" dependencies = [ "proc-macro2", "quote", @@ -459,11 +467,10 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.15.0" +version = "3.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" +checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" dependencies = [ - "cfg-if", "fastrand", "getrandom", "once_cell", @@ -473,18 +480,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", @@ -493,9 +500,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.19" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae" dependencies = [ "serde", "serde_spanned", @@ -505,31 +512,38 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.22" +version = "0.22.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", + "toml_write", "winnow", ] [[package]] -name = "unicode-ident" -version = "1.0.14" +name = "toml_write" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" +checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076" + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "utf8parse" @@ -545,9 +559,12 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] [[package]] name = "windows-sys" @@ -624,13 +641,22 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.24" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" +checksum = "d9fb597c990f03753e08d3c29efbfcf2019a003b4bf4ba19225c158e1549f0f3" dependencies = [ "memchr", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags", +] + [[package]] name = "wyz" version = "0.5.1" @@ -642,27 +668,27 @@ dependencies = [ [[package]] name = "zstd" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "7.2.1" +version = "7.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059" +checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" dependencies = [ "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.13+zstd.1.5.6" +version = "2.0.15+zstd.1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" +checksum = "eb81183ddd97d0c74cedf1d50d85c8d08c1b8b68ee863bdee9e706eedba1a237" dependencies = [ "cc", "pkg-config", diff --git a/Cargo.toml b/Cargo.toml index cc7b596..0a6e289 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,16 +19,12 @@ cbindgen = "0.28.0" [dependencies.servicepoint] package = "servicepoint" -version = "0.13.2" +version = "0.14.1" default-features = false -features = ["protocol_udp"] -git = "https://git.berlin.ccc.de/servicepoint/servicepoint/" -branch = "next" [features] -protocol_udp = ["servicepoint/protocol_udp"] all_compressions = ["servicepoint/all_compressions"] -default = ["all_compressions", "servicepoint/default", "protocol_udp"] +default = ["all_compressions", "servicepoint/default"] [lints.rust] missing-docs = "warn" diff --git a/src/bitvec.rs b/src/bitvec.rs index 82c0fbe..3cd5abb 100644 --- a/src/bitvec.rs +++ b/src/bitvec.rs @@ -1,7 +1,5 @@ use crate::{heap_drop, heap_move, heap_move_nonnull, heap_remove, ByteSlice}; -use servicepoint::{ - BinaryOperation, BitVecCommand, BitVecU8Msb0, CompressionCode, Packet, -}; +use servicepoint::{BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Packet}; use std::ptr::NonNull; /// A vector of bits @@ -12,7 +10,7 @@ use std::ptr::NonNull; /// sp_bitvec_set(vec, 5, true); /// sp_bitvec_free(vec); /// ``` -pub struct SPBitVec(pub(crate) BitVecU8Msb0); +pub struct SPBitVec(pub(crate) DisplayBitVec); impl Clone for SPBitVec { fn clone(&self) -> Self { @@ -33,7 +31,7 @@ impl Clone for SPBitVec { /// - when `size` is not divisible by 8. #[no_mangle] pub unsafe extern "C" fn sp_bitvec_new(size: usize) -> NonNull { - heap_move_nonnull(SPBitVec(BitVecU8Msb0::repeat(false, size))) + heap_move_nonnull(SPBitVec(DisplayBitVec::repeat(false, size))) } /// Interpret the data as a series of bits and load then into a new [SPBitVec] instance. @@ -42,7 +40,7 @@ pub unsafe extern "C" fn sp_bitvec_new(size: usize) -> NonNull { #[no_mangle] pub unsafe extern "C" fn sp_bitvec_load(data: ByteSlice) -> NonNull { let data = unsafe { data.as_slice() }; - heap_move_nonnull(SPBitVec(BitVecU8Msb0::from_slice(data))) + heap_move_nonnull(SPBitVec(DisplayBitVec::from_slice(data))) } /// Clones a [SPBitVec]. diff --git a/src/lib.rs b/src/lib.rs index 57192e0..db6361b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,7 +34,8 @@ pub use crate::cp437_grid::*; pub use crate::packet::*; pub use servicepoint::CommandCode; use std::ptr::NonNull; -pub use typed_command::*; +pub use crate::typed_command::*; +pub use crate::udp::*; mod bitmap; mod bitvec; @@ -44,13 +45,8 @@ mod char_grid; mod cp437_grid; mod packet; mod typed_command; - -#[cfg(feature = "protocol_udp")] mod udp; -#[cfg(feature = "protocol_udp")] -pub use udp::*; - use std::time::Duration; /// Actual hardware limit is around 28-29ms/frame. Rounded up for less dropped packets. diff --git a/src/udp.rs b/src/udp.rs index 93e0a21..bb04454 100644 --- a/src/udp.rs +++ b/src/udp.rs @@ -1,7 +1,7 @@ use crate::{heap_drop, heap_move, heap_remove}; -use servicepoint::{Connection, Header, Packet, TypedCommand, UdpConnection}; +use servicepoint::{Header, Packet, TypedCommand, UdpSocketExt}; use std::ffi::{c_char, CStr}; -use std::net::{Ipv4Addr, SocketAddrV4}; +use std::net::{Ipv4Addr, SocketAddrV4, UdpSocket}; use std::ptr::NonNull; /// Creates a new instance of [UdpConnection]. @@ -18,11 +18,11 @@ use std::ptr::NonNull; #[no_mangle] pub unsafe extern "C" fn sp_udp_open( host: NonNull, -) -> *mut UdpConnection { +) -> *mut UdpSocket { let host = unsafe { CStr::from_ptr(host.as_ptr()) } .to_str() .expect("Bad encoding"); - let connection = match UdpConnection::open(host) { + let connection = match UdpSocket::bind_connect(host) { Err(_) => return std::ptr::null_mut(), Ok(value) => value, }; @@ -48,9 +48,9 @@ pub unsafe extern "C" fn sp_udp_open_ipv4( ip3: u8, ip4: u8, port: u16, -) -> *mut UdpConnection { +) -> *mut UdpSocket { let addr = SocketAddrV4::new(Ipv4Addr::from([ip1, ip2, ip3, ip4]), port); - let connection = match UdpConnection::open(addr) { + let connection = match UdpSocket::bind_connect(addr) { Err(_) => return std::ptr::null_mut(), Ok(value) => value, }; @@ -64,11 +64,11 @@ pub unsafe extern "C" fn sp_udp_open_ipv4( /// returns: true in case of success #[no_mangle] pub unsafe extern "C" fn sp_udp_send_packet( - connection: NonNull, + connection: NonNull, packet: NonNull, ) -> bool { let packet = unsafe { heap_remove(packet) }; - unsafe { connection.as_ref().send(packet) }.is_ok() + unsafe { connection.as_ref().send(&Vec::from(packet)) }.is_ok() } /// Sends a [TypedCommand] to the display using the [UdpConnection]. @@ -84,11 +84,11 @@ pub unsafe extern "C" fn sp_udp_send_packet( /// ``` #[no_mangle] pub unsafe extern "C" fn sp_udp_send_command( - connection: NonNull, + connection: NonNull, command: NonNull, ) -> bool { let command = unsafe { heap_remove(command) }; - unsafe { connection.as_ref().send(command) }.is_ok() + unsafe { connection.as_ref().send_command(command) }.is_some() } /// Sends a [Header] to the display using the [UdpConnection]. @@ -102,18 +102,18 @@ pub unsafe extern "C" fn sp_udp_send_command( /// ``` #[no_mangle] pub unsafe extern "C" fn sp_udp_send_header( - udp_connection: NonNull, + udp_connection: NonNull, header: Header, ) -> bool { let packet = Packet { header, payload: vec![], }; - unsafe { udp_connection.as_ref() }.send(packet).is_ok() + unsafe { udp_connection.as_ref() }.send(&Vec::from(packet)).is_ok() } /// Closes and deallocates a [UdpConnection]. #[no_mangle] -pub unsafe extern "C" fn sp_udp_free(connection: NonNull) { +pub unsafe extern "C" fn sp_udp_free(connection: NonNull) { unsafe { heap_drop(connection) } } From ee7d6ac85714bdc1ff2e458e2e973e536070a956 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Thu, 24 Apr 2025 22:47:27 +0200 Subject: [PATCH 5/6] a bunch of options for the Makefile --- example/Makefile | 150 ++++++++++++++++---------- example/{ => src}/announce.c | 10 +- example/{ => src}/brightness_tester.c | 4 +- example/{ => src}/random_stuff.c | 5 +- flake.nix | 20 ++-- include/servicepoint.h | 35 +++--- src/lib.rs | 3 + 7 files changed, 133 insertions(+), 94 deletions(-) rename example/{ => src}/announce.c (82%) rename example/{ => src}/brightness_tester.c (84%) rename example/{ => src}/random_stuff.c (72%) diff --git a/example/Makefile b/example/Makefile index 7e5bfe7..a35aa5c 100644 --- a/example/Makefile +++ b/example/Makefile @@ -1,85 +1,119 @@ -CC := gcc -CARGO := rustup run nightly cargo +CARGO ?= cargo +STRIP ?= strip -TARGET := x86_64-unknown-linux-musl -PROFILE := size-optimized -FEATURES := protocol_udp +FEATURES := THIS_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) -REPO_ROOT := $(THIS_DIR)/.. -RUST_TARGET_DIR := $(REPO_ROOT)/target/$(TARGET)/$(PROFILE) +REPO_ROOT := $(realpath $(THIS_DIR)/..) export SERVICEPOINT_HEADER_OUT := $(REPO_ROOT)/include -RUSTFLAGS := -Zlocation-detail=none \ - -Zfmt-debug=none \ - -C linker=musl-gcc \ - -C link-arg=-s \ - -C link-arg=--gc-sections \ - -C link-arg=-z,norelro \ - -C link-arg=--hash-style=gnu \ - --crate-type=staticlib \ - -C panic=abort +override CFG_MUSL := $(if $(CFG_MUSL),$(CFG_MUSL),$(if $(MUSL),$(MUSL),0)) +override CFG_PROFILE := $(if $(CFG_PROFILE),$(CFG_PROFILE),$(if $(PROFILE),$(PROFILE),release)) -CARGOFLAGS := --manifest-path=$(REPO_ROOT)/Cargo.toml \ - --profile=$(PROFILE) \ +CCFLAGS += -Wall -fwhole-program + +STRIPFLAGS := -s --strip-unneeded -R .comment -R .gnu.version -R .note -R .note.gnu.build-id -R .note.ABI-tag + +ifeq ($(CFG_MUSL), 1) + TARGET ?= x86_64-unknown-linux-musl + CC ?= musl-gcc + CCFLAGS += -static -lservicepoint_binding_c + RUSTFLAGS += --crate-type=staticlib +else + TARGET ?= x86_64-unknown-linux-gnu + CC ?= gcc + #CCFLAGS += -shared + CCFLAGS += -Wl,-Bstatic -lservicepoint_binding_c -Wl,-Bdynamic +endif + +#ifeq ($(CFG_PROFILE), size-optimized) +# CCFLAGS += -nodefaultlibs -lc +#endif + +RUST_TARGET_DIR := $(REPO_ROOT)/target/$(TARGET)/$(CFG_PROFILE) +OUT_DIR := $(realpath $(THIS_DIR)/out/) + +ifeq ($(CFG_PROFILE), size-optimized) + CARGO_PROFILE := size-optimized + CCFLAGS += -Oz \ + -fwrapv -fomit-frame-pointer -fno-stack-protector\ + -fno-unroll-loops \ + -fno-unwind-tables -fno-asynchronous-unwind-tables \ + -fmerge-all-constants \ + -Wl,-z,norelro \ + -Wl,--hash-style=gnu \ + -fvisibility=hidden \ + -Bsymbolic \ + -Wl,--exclude-libs,ALL \ + -fno-ident \ + -fno-exceptions + CARGOFLAGS += -Zbuild-std="core,std,alloc,proc_macro,panic_abort" \ + -Zbuild-std-features="panic_immediate_abort" + RUSTFLAGS += -Zlocation-detail=none \ + -Zfmt-debug=none \ + -C link-arg=-z,norelro \ + -C panic=abort + #-C link-arg=--hash-style=gnu +else ifeq ($(CFG_PROFILE), release) + CARGO_PROFILE := release + CCFLAGS += -O2 +else ifeq ($(CFG_PROFILE), debug) + CCFLAGS += -Og + CARGO_PROFILE := dev +else + CFG_PROFILE := $(error "PROFILE has to be set to one of: debug, release, size-optimized") +endif + +CARGOFLAGS += --manifest-path=$(REPO_ROOT)/Cargo.toml \ + --profile=$(CARGO_PROFILE) \ --no-default-features \ --features=$(FEATURES) \ - --target=$(TARGET) \ - -Zbuild-std="core,std,alloc,proc_macro,panic_abort" \ - -Zbuild-std-features="panic_immediate_abort" \ + --target=$(TARGET) -CCFLAGS := -static -Os \ - -ffunction-sections -fdata-sections \ - -fwrapv -fomit-frame-pointer -fno-stack-protector\ - -fwhole-program \ - -nodefaultlibs -lservicepoint_binding_c -lc \ - -Wl,--gc-sections \ - -fno-unroll-loops \ - -fno-unwind-tables -fno-asynchronous-unwind-tables \ - -fmerge-all-constants \ - -Wl,-z,norelro \ - -Wl,--hash-style=gnu \ - -fvisibility=hidden \ - -Bsymbolic \ - -Wl,--exclude-libs,ALL \ - -fno-ident \ - -Wall - #-fuse-ld=gold \ - -fno-exceptions - #-Wl,--icf=all \ +ifneq ($(CFG_PROFILE), debug) + CCFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections + RUSTFLAGS += -C link-arg=-s -C link-arg=-Wl,--gc-sections +endif -STRIPFLAGS := -s --strip-unneeded -R .comment -R .gnu.version -R .comment -R .note -R .note.gnu.build-id -R .note.ABI-tag +ifeq ($(LTO), 1) + CCFLAGS += -flto +endif -_c_src := $(wildcard *.c) -_programs := $(basename $(_c_src)) +_c_src := $(wildcard ./src/*.c) +_programs := $(basename $(notdir $(_c_src))) _bins := $(addprefix out/, $(_programs)) _unstripped_bins := $(addsuffix _unstripped, $(_bins)) _run_programs := $(addprefix run_, $(_programs)) _rs_src := $(wildcard ../src/**.rs) ../Cargo.lock ../Cargo.toml ../cbindgen.toml +_sp_artifacts := $(SERVICEPOINT_HEADER_OUT)/servicepoint.h $(RUST_TARGET_DIR)/libservicepoint_binding_c.a $(RUST_TARGET_DIR)/libservicepoint_binding_c.so all: $(_bins) -clean: - rm -r out || true - rm include/servicepoint.h || true +clean: clean-c clean-rust + +clean-c: + rm -r $(OUT_DIR) || true + +clean-rust: + rm $(SERVICEPOINT_HEADER_OUT)/servicepoint.h || true cargo clean -PHONY: all clean sizes $(_run_programs) +.PHONY: all clean sizes $(_run_programs) clean-c clean-rust -$(_unstripped_bins): out/%_unstripped: %.c $(SERVICEPOINT_HEADER_OUT)/servicepoint.h $(RUST_TARGET_DIR)/libservicepoint_binding_c.a +$(_unstripped_bins): out/%_unstripped: src/%.c $(SERVICEPOINT_HEADER_OUT)/servicepoint.h $(_sp_artifacts) mkdir -p out || true - ${CC} $^ \ + ${CC} $< \ -I $(SERVICEPOINT_HEADER_OUT) \ - -L $(RUST_TARGET_DIR)\ + -L $(RUST_TARGET_DIR) \ $(CCFLAGS) \ -o $@ $(_bins): out/%: out/%_unstripped - strip $(STRIPFLAGS) $^ -o $@ + $(STRIP) $(STRIPFLAGS) $^ -o $@ -$(SERVICEPOINT_HEADER_OUT)/servicepoint.h $(RUST_TARGET_DIR)/libservicepoint_binding_c.a: $(_rs_src) - mkdir -p include || true - # generate servicepoint header and binary to link against +$(_sp_artifacts): $(_rs_src) + mkdir -p $(SERVICEPOINT_HEADER_OUT) || true + # generate servicepoint header and library to link against ${CARGO} rustc $(CARGOFLAGS) -- $(RUSTFLAGS) $(_run_programs): run_%: out/% FORCE @@ -88,9 +122,9 @@ $(_run_programs): run_%: out/% FORCE sizes: $(_bins) ls -lB out -#analyze-size: out/example_unstripped -# nm --print-size --size-sort --reverse-sort --radix=d --demangle out/example_unstripped \ -# | awk '{size=$$2+0; print size "\t" $$4}' \ -# | less +analyze-size: out/$(BIN)_unstripped + nm --print-size --size-sort --reverse-sort --radix=d --demangle $(OUT_DIR)/$(BIN)_unstripped \ + | awk '{size=$$2+0; print size "\t" $$4}' \ + | less FORCE: ; diff --git a/example/announce.c b/example/src/announce.c similarity index 82% rename from example/announce.c rename to example/src/announce.c index 737eff5..d256cff 100644 --- a/example/announce.c +++ b/example/src/announce.c @@ -1,8 +1,12 @@ +#include #include "servicepoint.h" + int main(void) { - //UdpConnection *connection = sp_udp_open_ipv4(172, 23, 42, 29, 2342); - UdpConnection *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342); + printf("test\n"); + + UdpSocket *connection = sp_udp_open_ipv4(172, 23, 42, 29, 2342); + //UdpSocket *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342); if (connection == NULL) return 1; @@ -11,7 +15,7 @@ int main(void) { CharGrid *grid = sp_char_grid_new(5, 2); if (grid == NULL) return 1; - + sp_char_grid_set(grid, 0, 0, 'H'); sp_char_grid_set(grid, 1, 0, 'e'); sp_char_grid_set(grid, 2, 0, 'l'); diff --git a/example/brightness_tester.c b/example/src/brightness_tester.c similarity index 84% rename from example/brightness_tester.c rename to example/src/brightness_tester.c index d06d30d..c3e42ba 100644 --- a/example/brightness_tester.c +++ b/example/src/brightness_tester.c @@ -1,8 +1,8 @@ #include "servicepoint.h" int main(void) { - // UdpConnection *connection = sp_udp_open_ipv4(172, 23, 42, 29, 2342); - UdpConnection *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342); + UdpSocket *connection = sp_udp_open_ipv4(172, 23, 42, 29, 2342); + //UdpSocket *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342); if (connection == NULL) return -1; diff --git a/example/random_stuff.c b/example/src/random_stuff.c similarity index 72% rename from example/random_stuff.c rename to example/src/random_stuff.c index ca5a14d..96beefb 100644 --- a/example/random_stuff.c +++ b/example/src/random_stuff.c @@ -1,8 +1,7 @@ -#include #include "servicepoint.h" int main(void) { - UdpConnection *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342); + UdpSocket *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342); if (connection == NULL) return 1; @@ -17,7 +16,7 @@ int main(void) { return 1; Header *header = sp_packet_get_header(packet); - printf("[%d, %d, %d, %d, %d]\n", header->command_code, header->a, header->b, header->c, header->d); + // printf("[%d, %d, %d, %d, %d]\n", header->command_code, header->a, header->b, header->c, header->d); sp_udp_send_packet(connection, packet); diff --git a/flake.nix b/flake.nix index b4f874f..9d67ae9 100644 --- a/flake.nix +++ b/flake.nix @@ -33,16 +33,17 @@ { pkgs, system }: { default = pkgs.mkShell rec { - buildInputs = with pkgs;[ + buildInputs = with pkgs; [ xe xz - libgcc - #glibc.static - musl - libunwind - ]; + #libgcc + #glibc + pkgsStatic.musl + # libunwind - nativeBuildInputs = with pkgs;[ + ]; + + nativeBuildInputs = with pkgs; [ (pkgs.symlinkJoin { name = "rust-toolchain"; paths = with pkgs; [ @@ -57,11 +58,14 @@ ]; }) gcc + gdb + pkgsStatic.gcc gnumake pkg-config ]; - RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + #RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + CARGO = "rustup run nightly cargo"; }; } ); diff --git a/include/servicepoint.h b/include/servicepoint.h index 77d2e36..5863ef5 100644 --- a/include/servicepoint.h +++ b/include/servicepoint.h @@ -226,13 +226,9 @@ typedef struct SPBitVec SPBitVec; typedef struct TypedCommand TypedCommand; /** - * A connection using the UDP protocol. - * - * Use this when sending commands directly to the display. - * - * Requires the feature "`protocol_udp`" which is enabled by default. + * This is a type only used by cbindgen to have a type for pointers. */ -typedef struct UdpConnection UdpConnection; +typedef struct UdpSocket UdpSocket; /** * A 2D grid of values. @@ -298,7 +294,7 @@ typedef struct { * grid.set(1, 1, Brightness::MIN); * * # let connection = FakeConnection; - * connection.send(BrightnessGridCommand { + * connection.send_command(BrightnessGridCommand { * origin: Origin::new(3, 7), * grid * }).unwrap() @@ -318,7 +314,7 @@ typedef ValueGrid_Brightness BrightnessGrid; * * let b = Brightness::try_from(7).unwrap(); * # let connection = FakeConnection; - * let result = connection.send(GlobalBrightnessCommand::from(b)); + * let result = connection.send_command(GlobalBrightnessCommand::from(b)); * ``` */ typedef uint8_t Brightness; @@ -347,7 +343,7 @@ typedef uint8_t Brightness; * * # let connection = FakeConnection; * let command = CharGridCommand { origin: Origin::ZERO, grid }; - * connection.send(command).unwrap() + * connection.send_command(command).unwrap() * ``` */ typedef ValueGrid_char CharGrid; @@ -1220,7 +1216,7 @@ bool sp_u16_to_command_code(uint16_t code, /** * Closes and deallocates a [UdpConnection]. */ -void sp_udp_free(UdpConnection */*notnull*/ connection); +void sp_udp_free(UdpSocket */*notnull*/ connection); /** * Creates a new instance of [UdpConnection]. @@ -1235,7 +1231,7 @@ void sp_udp_free(UdpConnection */*notnull*/ connection); * sp_udp_send_command(connection, sp_command_clear()); * ``` */ -UdpConnection *sp_udp_open(char */*notnull*/ host); +UdpSocket *sp_udp_open(char */*notnull*/ host); /** * Creates a new instance of [UdpConnection]. @@ -1250,11 +1246,11 @@ UdpConnection *sp_udp_open(char */*notnull*/ host); * sp_udp_send_command(connection, sp_command_clear()); * ``` */ -UdpConnection *sp_udp_open_ipv4(uint8_t ip1, - uint8_t ip2, - uint8_t ip3, - uint8_t ip4, - uint16_t port); +UdpSocket *sp_udp_open_ipv4(uint8_t ip1, + uint8_t ip2, + uint8_t ip3, + uint8_t ip4, + uint16_t port); /** * Sends a [TypedCommand] to the display using the [UdpConnection]. @@ -1269,7 +1265,7 @@ UdpConnection *sp_udp_open_ipv4(uint8_t ip1, * sp_udp_send_command(connection, sp_command_brightness(5)); * ``` */ -bool sp_udp_send_command(UdpConnection */*notnull*/ connection, +bool sp_udp_send_command(UdpSocket */*notnull*/ connection, TypedCommand */*notnull*/ command); /** @@ -1283,8 +1279,7 @@ bool sp_udp_send_command(UdpConnection */*notnull*/ connection, * sp_udp_send_header(connection, sp_command_brightness(5)); * ``` */ -bool sp_udp_send_header(UdpConnection */*notnull*/ udp_connection, - Header header); +bool sp_udp_send_header(UdpSocket */*notnull*/ udp_connection, Header header); /** * Sends a [Packet] to the display using the [UdpConnection]. @@ -1293,7 +1288,7 @@ bool sp_udp_send_header(UdpConnection */*notnull*/ udp_connection, * * returns: true in case of success */ -bool sp_udp_send_packet(UdpConnection */*notnull*/ connection, +bool sp_udp_send_packet(UdpSocket */*notnull*/ connection, Packet */*notnull*/ packet); #ifdef __cplusplus diff --git a/src/lib.rs b/src/lib.rs index db6361b..47b21d5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,3 +67,6 @@ pub(crate) unsafe fn heap_drop(x: NonNull) { pub(crate) unsafe fn heap_remove(x: NonNull) -> T { unsafe { *Box::from_raw(x.as_ptr()) } } + +/// This is a type only used by cbindgen to have a type for pointers. +pub struct UdpSocket; \ No newline at end of file From 4206dcc54303cb116ab8317dc744c3d49f537180 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Thu, 24 Apr 2025 23:31:34 +0200 Subject: [PATCH 6/6] build all variations in CI to keep track of what works --- .github/workflows/rust.yml | 73 ++++++++++++++++++++++++++++++-------- example/Makefile | 6 ++-- 2 files changed, 62 insertions(+), 17 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9089694..fcd39ad 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -13,32 +13,77 @@ env: RUSTFLAGS: "-Dwarnings" jobs: - build: - + build-gnu-apt: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - name: Update repos run: sudo apt-get update -qq - - name: Install rust toolchain - run: sudo apt-get install -qy cargo rust-clippy - - name: install lzma - run: sudo apt-get install -qy liblzma-dev - - name: install gcc - run: sudo apt-get install -qy gcc make + - name: Install toolchain + run: sudo apt-get install -qy cargo rust-clippy liblzma-dev gcc make pkgconf - name: Run Clippy run: cargo clippy + - name: build + run: cargo build + - name: generate bindings run: ./generate-binding.sh - name: check that generated files did not change run: output=$(git status --porcelain) && [ -z "$output" ] - - - name: build - run: cargo build - - name: build example - run: cd example && make + - name: build example -- glibc release + run: cd example && make clean && make TARGET=aarch64-unknown-linux-gnu PROFILE=release + - name: build example -- glibc debug + run: cd example && make clean && make TARGET=aarch64-unknown-linux-gnu PROFILE=debug + + # this _should_ have been -stable, but there is a bug when running in the container ("Invalid cross-device link") + build-musl-beta: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Update repos + run: sudo apt-get update -qq + - name: Install toolchain + run: sudo apt-get install -qy liblzma-dev gcc make pkgconf musl-dev musl-tools rustup + - name: install rust target + run: rustup default beta && rustup target add aarch64-unknown-linux-musl && rustup component add rust-src && rustup update + + - name: build example -- musl release + run: cd example && make clean && make TARGET=aarch64-unknown-linux-musl PROFILE=release MUSL=1 CARGO="rustup run beta cargo" + - name: build example -- musl debug + run: cd example && make clean && make TARGET=aarch64-unknown-linux-musl PROFILE=debug MUSL=1 CARGO="rustup run beta cargo" + + build-size-gnu-unstable: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Update repos + run: sudo apt-get update -qq + - name: Install toolchain + run: sudo apt-get install -qy liblzma-dev gcc make pkgconf rustup + - name: install rust targets + run: rustup toolchain install nightly -t aarch64-unknown-linux-gnu -c rust-src --no-self-update + + - name: build example -- glibc size-optimized + run: cd example && make clean && make TARGET=aarch64-unknown-linux-gnu PROFILE=size-optimized CARGO="rustup run nightly cargo" + + + build-size-musl-unstable: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Update repos + run: sudo apt-get update -qq + - name: Install toolchain + run: sudo apt-get install -qy liblzma-dev gcc make pkgconf musl-dev musl-tools rustup + - name: install rust targets + run: rustup toolchain install nightly -t aarch64-unknown-linux-musl -c rust-src --no-self-update + + - name: build example -- musl size-optimized + run: cd example && make clean && make TARGET=aarch64-unknown-linux-musl PROFILE=size-optimized MUSL=1 LTO=1 CARGO="rustup run nightly cargo" diff --git a/example/Makefile b/example/Makefile index a35aa5c..353e298 100644 --- a/example/Makefile +++ b/example/Makefile @@ -1,7 +1,7 @@ CARGO ?= cargo STRIP ?= strip -FEATURES := +FEATURES := "" THIS_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) REPO_ROOT := $(realpath $(THIS_DIR)/..) @@ -10,7 +10,7 @@ export SERVICEPOINT_HEADER_OUT := $(REPO_ROOT)/include override CFG_MUSL := $(if $(CFG_MUSL),$(CFG_MUSL),$(if $(MUSL),$(MUSL),0)) override CFG_PROFILE := $(if $(CFG_PROFILE),$(CFG_PROFILE),$(if $(PROFILE),$(PROFILE),release)) -CCFLAGS += -Wall -fwhole-program +CCFLAGS += -Wall -fwhole-program -fPIE -pie STRIPFLAGS := -s --strip-unneeded -R .comment -R .gnu.version -R .note -R .note.gnu.build-id -R .note.ABI-tag @@ -18,7 +18,7 @@ ifeq ($(CFG_MUSL), 1) TARGET ?= x86_64-unknown-linux-musl CC ?= musl-gcc CCFLAGS += -static -lservicepoint_binding_c - RUSTFLAGS += --crate-type=staticlib + RUSTFLAGS += --crate-type=staticlib -Ctarget-feature=-crt-static else TARGET ?= x86_64-unknown-linux-gnu CC ?= gcc