[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

foonathan-memory needs to run binary at compile-time



Hi,

I had this discussion off-list with Helmut already, but I promised him
(a while ago) to post this here, so I'm finally making up on my promise.

I am the maintainer of foonathan-memory, which FTCBFS because of some
detection code that runs at compile time. foonathan-memory is a C++
memory allocator library, and it needs to know the actual internal node
size of some STL container nodes. These nodes are larger than the stored
data because of container-specific overheads.  Unfortunately, the
internal nodes classes are not public, so the obvious solution with
sizeof(Node) does not work.

As a workaround, upstream compiles and runs a small test program that
does a few test allocations with a special debugging allocator, and
deduces the size of the internal objects from the requested size in the
allocation call. The results are put into a generated header file that
is shipped with the library [1].

Sidestepping the issue whether this is a smart thing to do, my question
is: what is the best strategy to handle it in a cross-compiling friendly
way? Ship precomputed values for all architectures? Use hardcoded values
which are sufficiently large but might waste some memory?

Cheers
Timo

[1] /usr/include/$triplet/foonathan-memory/memory/detail/container_node_sizes_impl.hpp

Attachment: signature.asc
Description: PGP signature


Reply to: