From 5a85a0e167311eb1fba7fe3a79ceb449a2f11610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 21 Oct 2024 12:48:41 +0200 Subject: [PATCH 1/2] build: sort objects in link commands Build logs are easier to compare if the commands don't change. This shouldn't have any effect on the build result. --- setup/build.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup/build.py b/setup/build.py index e9aa2757e5..a99107b0f5 100644 --- a/setup/build.py +++ b/setup/build.py @@ -577,15 +577,16 @@ class Build(Command): cmd = [linker] elib = env.lib_dirs_to_ldflags(ext.lib_dirs) xlib = env.libraries_to_ldflags(ext.libraries) + all_objects = sorted(objects + ext.extra_objs) if iswindows or env is self.windows_cross_env: pre_ld_flags = [] if ext.uses_icu: # windows has its own ICU libs that dont work pre_ld_flags = elib cmd += pre_ld_flags + env.ldflags + ext.ldflags + elib + xlib + \ - ['/EXPORT:' + init_symbol_name(ext.name)] + objects + ext.extra_objs + ['/OUT:'+dest] + ['/EXPORT:' + init_symbol_name(ext.name)] + all_objects + ['/OUT:'+dest] else: - cmd += objects + ext.extra_objs + ['-o', dest] + env.ldflags + ext.ldflags + elib + xlib + cmd += all_objects + ['-o', dest] + env.ldflags + ext.ldflags + elib + xlib return LinkCommand(cmd, objects, dest) env = self.env_for_compilation_db(ext) From f51b20e5d913bb78541a8093750ddae677382cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 21 Oct 2024 13:41:04 +0200 Subject: [PATCH 2/2] build: sort headers and sources in plugin builds I'd observe a difference in the debuginfo data for the plugins in rebuilds. Various /usr/lib64/calibre/calibre/plugins/*.so files would be different, but the source of the difference was in the link to debuginfo data, which in turn appears to be caused by differences in sort order in various tables, caused by the object files being listed in different order. setup/build.py writes out pyproject.toml, which is turned into *.pro, which is turned into a Makefile. Sorting the object files by name seems to fix this particular issue. This makes local rebuilds reproducible for me. --- setup/build.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup/build.py b/setup/build.py index a99107b0f5..a92f5e5127 100644 --- a/setup/build.py +++ b/setup/build.py @@ -696,8 +696,8 @@ qmake-settings = [ ] [tool.sip.bindings.{ext.name}] -headers = {ext.headers} -sources = {ext.sources} +headers = {sorted(ext.headers)} +sources = {sorted(ext.sources)} exceptions = {needs_exceptions} include-dirs = {ext.inc_dirs} qmake-QT = {ext.qt_modules}