From: Philippe Gerum <rpm@xenomai.org>
To: Julien Blanc <julien.blanc@sprinte.eu>
Cc: "xenomai@lists.linux.dev" <xenomai@lists.linux.dev>
Subject: Re: [RFC] symbol wrapping for libcobalt
Date: Tue, 24 Nov 2026 12:12:51 +0100 [thread overview]
Message-ID: <87wlq24h58.fsf@xenomai.org> (raw)
In-Reply-To: <bb6109e28cbd8d8d90a9638644041980e731a22b.camel@sprinte.eu> (Julien Blanc's message of "Tue, 24 Nov 2026 07:58:11 +0000")
Julien Blanc <julien.blanc@sprinte.eu> writes:
> Le lundi 23 novembre 2026 à 21:33 +0100, Philippe Gerum a écrit :
>>
>> Since its very inception, the POSIX API in xenomai3 enables automatic
>> wrapping of POSIX calls to their libcobalt counterpart using a linker
>> trick (-Wl,--wrap), so that applications can use the pristine POSIX
>> routine names to invoke Xenomai services. For instance, the following
>> snippet:
>>
>> ret = pthread_create(&tid, &attr, foo_routine, NULL);
>>
>> would translate internally to:
>>
>> ret = __wrap_pthread_create(&tid, &attr, foo_routine, NULL);
>>
>> which is a weak symbol alias to:
>>
>> ret = __cobalt_pthread_create(&tid, &attr, foo_routine, NULL);
>>
>> The significant part of this wrapping is that we go from symbol_x in the
>> source code to __cobalt_symbol_x at link time, with libcobalt
>> implementing the latter.
>>
>> Over the years, we noticed several issues with this scheme:
>
>> [Snip]
>
> Just saying that as a xenomai user, we share all of these concerns. Another
> issue is interop with eg rust code : i have no idea what happens when a rust
> static lib is linked onto the executable regarding the calls it may do to the
> pthread api (this one is actually a big concern for us for rust code integration
> into the rt domain, and even the non-rt domain as it's unsure how it will
> behave).
>
Rust's rlib format is basically a static ar(chive) in disguise, storing
one object file which contains some build metadata, and any number of
so-called "Rust codegen units", optionally with additional files
generated from other languages (C/C++), so we may assume that wrapping
is applicable. This said, you are likely going through other crates
which call the *libc eventually (e.g. std, libc, nix, rustix et al),
your own crates are unlikely to emit references to these symbols
directly, but to mangled Rust names implementing some FFI. For some of
the reasons explained in my RFC about link stage issues, I would not
expect wrapping to work out of the box in this case, especially with the
cargo toolchain in the loop, at least not in any intuitive and POLA
fashion.
This is why v4 comes with the 'revl' crate, which provides the bindings
required to leverage the libevl (original) API calls in Rust
abstractions. Extending revl to introduce abstractions covering the
portions of the POSIX API which were made oob-aware like syslog support
is a non-issue: these portions are based on the libevl intrinsics, which
are plain custom C functions, we'd need no wrapping there.
> We've gradually migrated to explicit calls everywhere, with the goal to get rid
> of wrapping entirely. It looks to me that the wrapping process is too fragile
> indeed. For us completely dropping the wrapping would be fine, as it's on our
> roadmap anyway.
>
> Actually, there's one feature that we rely upon : being able to compile for both
> an RT core and a standard kernel. But that is quite easy to do by just
> redifining the __RT and __STD macros, wrapping is not really relevant here.
We are on the same page. Wrapping may have been a good idea on paper; v4
should provide complete support for it and even beyond what v3 is
capable of today (i.e. with guardrails and checkers), but only as an
opt-in feature I believe, because this is too much of a footgun.
--
Philippe.
next prev parent reply other threads:[~2026-11-24 11:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 20:33 [RFC] symbol wrapping for libcobalt Philippe Gerum
2026-11-24 7:58 ` Julien Blanc
2026-11-24 11:12 ` Philippe Gerum [this message]
2026-11-24 12:30 ` Jan Kiszka
2026-11-24 15:56 ` Philippe Gerum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wlq24h58.fsf@xenomai.org \
--to=rpm@xenomai.org \
--cc=julien.blanc@sprinte.eu \
--cc=xenomai@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.