Bug#962474: CMAKE_SKIP_RPATH=ON improves reproducibility of CMake builds
Niels Thykier
niels at thykier.net
Mon Jun 29 18:54:49 BST 2020
Vagrant Cascadian:
> On 2020-06-29, Vagrant Cascadian wrote:
>> On 2020-06-29, Vagrant Cascadian wrote:
>>> On 2020-06-29, Timo Röhling wrote:
>>>>>> By default, CMake adds an RPATH entry to ELF binaries and deletes it
>>>>>> again at install time. However, due to the limitations of some
>>>>>> platforms, CMake will actually zero out the RPATH entry in the binary,
>>>>>> leaking the original path length and thus making the build not
>>>>>> reproducible (see the attached diffoscope output for an example).
>>>>>>
>>>>>> CMAKE_SKIP_RPATH disables the RPATH machinery and fixes the issue, and
>>>>>> since most package won't ever ship with an RPATH entry anyway, I propose
>>>>>> adding -DCMAKE_SKIP_RPATH=ON to the default build options.
>>>>> Thanks for the suggestion.
>>>
>>> Thanks for identifying the issue!
>>>
>>>
>>>>> Has this proposal been tested on an archive-wide rebuild test to see how
>>>>> much breaks with this option set?
>>>> I don't know, but I don't think so. I'm not directly involved with the
>>>> Reproducible Builds Team, I just pinged them on IRC after I filed this
>>>> bug. Cc'ing them now.
>>>
>>> There is currently only one package tagged with:
>>>
>>> https://tests.reproducible-builds.org/debian/issues/unstable/cmake_rpath_contains_build_path_issue.html
>>
>> Also worth mentioning the upstream issue:
>>
>> https://gitlab.kitware.com/cmake/cmake/-/issues/18413
>
> And BUILD_RPATH_USE_ORIGIN:
>
> https://gitlab.kitware.com/cmake/cmake/-/blob/master/Help/prop_tgt/BUILD_RPATH_USE_ORIGIN.rst
>
>
> live well,
> vagrant
>
Ok, I will add a temporary undocumented variable for you to test this.
It accepts any space separated list of "key-value pairs", which can be
used to override -D flags passed to cmake. An example being:
export DH_INTERNAL_RB_TEST_BUG962474="CMAKE_SKIP_RPATH=ON"
But you can substitute it with other flags if you also want or need to
experiment with other flags, such as:
export DH_INTERNAL_RB_TEST_BUG962474="CMAKE_SKIP_RPATH=OFF \
BUILD_RPATH_USE_ORIGIN=ON"
For the ease of debugging, debhelper will be verbal about this feature
being used.
It will be available with the next upload and be removed once your tests
have concluded.
~Niels
More information about the Reproducible-bugs
mailing list