hubcio commented on code in PR #3578:
URL: https://github.com/apache/iggy/pull/3578#discussion_r3509380706


##########
core/shard_allocator/build.rs:
##########
@@ -0,0 +1,43 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// Vendored `hwloc` references `cbrt`, which makes the linker pull in a

Review Comment:
   the stub is the right fix, but the comment's root cause is off - the 
vendored hwloc (2.14.0) has no `cbrt` in it. its only libm usage is 
`fabsf`/`modff`, and that is exactly what makes hwloc's configure put `-lm` 
into `Libs.private` of `hwloc.pc`; the build script then probes it statically 
via pkg-config, so `-lm -lpthread` get emitted into every downstream link. the 
`cbrt` references come from rust deps instead (`num-bigint`/`num-integer` via 
the jsonwebtoken/rsa chain, `quinn-proto` cubic congestion control) - any math 
symbol still unresolved when ld reaches `-lm` triggers the glibc static libm 
pull. worth rewording so the next person debugging a musl link isn't chasing 
hwloc sources for cube roots.



##########
core/cpu_allocation/Cargo.toml:
##########
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[package]
+name = "cpu_allocation"

Review Comment:
   this leaf crate only exists to keep hwloc out of `configs`, but with the 
allocator in `server_common` that concern is handled the same way - `configs` 
already depends on `server_common` (no cycle), so the types can live there and 
`configs::sharding` re-exports keep the paths stable.



##########
core/shard_allocator/Cargo.toml:
##########
@@ -0,0 +1,38 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[package]
+name = "shard_allocator"

Review Comment:
   the crate extraction itself didn't fix the musl build - the CI run on 
8d5e471 (after `shard_allocator` already existed) still failed linking 
`iggy-server`: `s_cbrt.o: undefined reference to __frexp/__ldexp`. only the 
libm.a stub commit made CI green, and the stub works no matter where the 
allocator lives. whether a given binary breaks is decided by rlib order at the 
`-lm` position, so master passing today looks like link-order luck rather than 
a property of the crate layout.
   
   given that, we'd rather not add two crates: move the allocator plus 
`CpuAllocation`/`NumaConfig` into `server_common` (essentially your first 
commit, with the `configs::sharding` re-exports) and put the stub build.rs on 
`server_common` - its `rustc-link-search` propagates to every dependent binary, 
simulator included. i verified this locally on x86_64-musl: without the stub 
the simulator link fails with the same failure class as CI 
(`libm-2.43.a(math_err.o): undefined reference to errno`), with the stub on 
`server_common` it links clean.
   
   bigger picture: `server_common` is slated to be folded into `core/server-ng` 
once the legacy `core/server` is removed (after vsr lands, `server-ng` then 
becomes `core/server`), so a standalone allocator crate would just get folded 
again later. hwloc becoming a transitive dep of `server_common`'s dependents is 
an accepted trade-off for the same reason.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to