Skip to content

Conversation

@cfrantz
Copy link
Contributor

@cfrantz cfrantz commented Oct 23, 2025

Opentitantool depends on libudev which can cause portability issues
between different runtime environments.

  1. Add a flag which permits statically linking host tools.
  2. Supply libudev-zero which is a no-dependencies replacement for
    libudev.
  3. Add some flags machinery for controlling whether opentitantool is
    statically linked (default: no).
  4. Deliver statically linked opentitantool and hsmtool in the devbundle.

@cfrantz cfrantz requested review from jwnrt and pamaury October 23, 2025 20:36
Opentitantool depends on libudev which can cause portability issues
between different runtime environments.

1. Add a flag which permits statically linking host tools.
2. Supply `libudev-zero` which is a no-dependencies replacement for
   libudev.
3. Add some flags machinery for controlling whether opentitantool is
   statically linked (default: no).
4. Deliver statically linked opentitantool and hsmtool in the devbundle.

Signed-off-by: Chris Frantz <[email protected]>
@cfrantz cfrantz changed the title [devbundle] Statically link opentitantool [devbundle] Statically link opentitantool & hsmtool Nov 3, 2025

def _flags_transition_impl(settings, attr):
result = {}
for label, value in attr.flags.items():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested locally but I think the most reliable way to avoid the issue with @@/ is to convert every label-string to its canonical form by doing str(Label(s)). If you do the same in the definition of _FLAG_CONVERSIONS, I think you can avoid the hack.

It might also be a good idea to fail in the rule if you get a flag which is not in _FLAG_CONVERSIONS?


def _build_with_flags_impl(ctx):
# Start with DefaultInfo and then forward on any other providers we know about.
result = [ctx.attr.target[DefaultInfo]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised that this works, bazel often complains if you try to copy a DefaultInfo and forces you to recreate it in the rule. Maybe it depends on the content?

configure_make(
name = "libelf",
args = ["-j"],
#autoreconf = True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this commented on purpose?

Copy link
Contributor

@pamaury pamaury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it makes sense to me. I didn't know about libudev-zero and I don't know how well it plays with opentitantool, I guess the main user would be libusb?

@nbdd0121
Copy link
Contributor

nbdd0121 commented Nov 4, 2025

Yes, libusb is my question too. On my machine OT-tool binary depends on (apart from libssl,libcrypto and glibc libraries), libftdi1/libusb-1.0/libudev. (It does not depend on libelf)

In order to run in foreign CI environments, we need to statically link
verilator to avoid glibc versioning issues.  Worse, the current
debian/ubuntu package for `libelf` has an error that prevents static
linking.

- Include the latest upstream libelf which corrects the linking error.
- Set the CFLAGS and LDFLAGS environment variables during the build of
  the simulator to statically link and include the upstream libelf.

Signed-off-by: Chris Frantz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants