go icon indicating copy to clipboard operation
go copied to clipboard

Make crypto/olm package optional: separate module, or build constraints

Open 08d2 opened this issue 2 years ago • 0 comments

This was previously reported in #17, where @tulir responded that

[crypto/olm] already is optional: the crypto module isn't imported from any other module

crypto and crypto/olm are not modules themselves, they're packages within the mautrix/go module, and the rules which govern which packages get compiled are a bit subtle. There are some "tree-shaking" style optimizations at the compilation stage which can elide packages within a module that don't get directly imported, but they're more or less implementation details, so authors can't rely on them to manage optionality in this way.

In short: every package in a module is "part" of that module. Optionality has to be expressed at the module level — i.e. make crypto/olm a separate module altogether — or, if it works, as build constraints in the package — i.e. no-op implementations for unsupported architectures.

08d2 avatar Mar 11 '22 20:03 08d2