简体   繁体   English

如何使Linux与Linux打包一起运行良好?

[英]How to make libraries work well with Linux packaging?

I'm the author of a C++ library that is being distributed in multiple Linux packaging distributions. 我是一个C ++库的作者,该库分布在多个Linux打包发行版中。 The library includes headers and source; 该库包括标题和来源; Linux packages distribute it as headers + shared library (.so). Linux软件包将其分发为标头+共享库(.so)。

I'm looking for guidelines that would make the life of Linux package maintainers easier. 我正在寻找能够让Linux软件包维护者的生活更轻松的指导方针。

Things I'm interested in include: 我感兴趣的东西包括:

  • API compatibility (eg changing function signatures). API兼容性(例如更改功能签名)。 Obviously maintaining compatibility across minor releases is crucial. 显然,维护次要版本之间的兼容性至关重要。 What about major version changes? 主要版本更改怎么样?

  • Binary compatibility (eg changing sizes of externally visible data structures). 二进制兼容性(例如,改变外部可见数据结构的大小)。 How important is it to be ABI-compatible across minor releases? 在次要版本中兼容ABI有多重要? Are there any issues with breaking that in major releases? 在主要版本中是否有任何问题?

  • Build versioning advice. 构建版本控制建议。 I'm currently using CMake - any specific settings that I should set to maximize the chance that package maintainers can just use my CMakeLists.txt? 我目前正在使用CMake - 我应该设置的任何特定设置,以最大限度地提高包维护者可以使用我的CMakeLists.txt的机会?

If there is anything else that I'm missing I'd be glad to hear about it as well. 如果还有其他我想念的东西,我也很高兴听到它。

Let me tackle the ABI part. 让我来解决ABI问题。 It depends a lot on if you will provide a pre-built binary that will work everywhere, or if you are relying on distributors to build it for you. 这在很大程度上取决于您是否会提供可在任何地方使用的预构建二进制文件,或者您是否依赖分销商为您构建它。

Consider Debian: once a package is in Debian, the build hosts recompile every update on every supported platform. 考虑Debian:一旦包在Debian中,构建主机就会在每个支持的平台上重新编译每个更新。 The C ABI rarely changes but the C++ ABI requires special attention (as mentioned in this 2005 message to debian developers: http://lwn.net/Articles/139810/ ) C ABI很少改变,但C ++ ABI需要特别注意(如2005年给debian开发人员的消息中所提到的: http//lwn.net/Articles/139810/

I don't think its reasonable to provide a C++ package that will work everywhere. 我认为提供一个可以在任何地方使用的C ++包是不合理的。 ABI is too site-specific: https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html ABI过于特定于网站: https//gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html

As a Linux maintainer I can say that both backward binary (ABI) and source (API) compatibility of your library is very important for us. 作为一个Linux维护者,我可以说你的库的后向二进制(ABI)和源(API)兼容性对我们来说非常重要。

API changes may break rebuild of some applications (or other libraries) in the distribution that depend on your library. API更改可能会破坏依赖于您的库的分发中的某些应用程序(或其他库)的重建。 This may break mass-rebuild of the distribution. 这可能会破坏分布的大规模重建。

ABI changes may break particular binary updates. ABI更改可能会破坏特定的二进制更新。 We need to verify ABI changes in updated libraries and rebuild all dependent applications if some dangerous changes are detected. 我们需要验证更新库中的ABI更改,并在检测到某些危险更改时重建所有相关应用程序。 In this case the user should download the update package for the library and for all dependent applications too. 在这种情况下,用户应该下载库的更新包以及所有相关应用程序。 If library is backward API and ABI stable then we can update the library package only. 如果库是后向API和ABI稳定的,那么我们只能更新库包。

If you break ABI then please change SONAME of your library (bump version). 如果您打破ABI,请更改您的库的SONAME (凹凸版本)。 And please do not introduce API/ABI changes in micro/patch releases. 请不要在微/补丁版本中引入API / ABI更改。

I recommend you to use the abi-compliance-checker tool to verify your library for API/ABI backward compatibility. 我建议您使用abi-compliance-checker工具验证库是否具有API / ABI向后兼容性。 See sample reports of the tool for the Qt library: http://abi-laboratory.pro/tracker/timeline/qt/ 请参阅Qt库工具的示例报告: http//abi-laboratory.pro/tracker/timeline/qt/

You need to compile debug version of your library with addition -g -Og options and dump ABI of your library with the help of the abi-dumper tool. 您需要使用-g -Og选项编译库的调试版本,并在abi-dumper工具的帮助下转储库的ABI。 And then compare two ABI dumps of different versions to generate ABI changes report. 然后比较两个不同版本的ABI转储以生成ABI更改报告。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM