Skip to content

meson: link libm into wallpaper-collections/gallery/rotator tests (fixes aarch64 build) - #36

Open
mateoalfaro wants to merge 1 commit into
singularityos-lab:mainfrom
mateoalfaro:fix/wallpaper-test-libm
Open

mateoalfaro wants to merge 1 commit into
singularityos-lab:mainfrom
mateoalfaro:fix/wallpaper-test-libm

Conversation

@mateoalfaro

Copy link
Copy Markdown
Contributor

Generative AI assistance

AI assistance: disclosed

The commit on this branch carries the required Assisted-by/AI-Scope trailers per AGENTS.md; the patch and report text were validated by the submitter.

Root cause

At commit aef0f372529fb69cbf38f64a427aabdfc0b4a555 (pinned by singularity-desktop master
0ba791f512908c69a03396ae0e05965439187d91), building singularity-desktop on aarch64-linux
fails at the end of the build (all ~2000 targets compile fine) linking exactly three test
executables that share src/core/dynamic_wallpaper.vala:

FAILED: subprojects/singularity-shell/wallpaper-collections-test
FAILED: subprojects/singularity-shell/wallpaper-gallery-test
FAILED: subprojects/singularity-shell/wallpaper-rotator-test

subprojects/singularity-shell/wallpaper-collections-test.p/meson-generated_src_core_dynamic_wallpaper.c.o:
in function `singularity_dynamic_wallpaper_sun_day_terms.constprop.0':
dynamic_wallpaper.c:(.text+0x139c): undefined reference to `sincos'
dynamic_wallpaper.c:(.text+0x4088): undefined reference to `sincos'
dynamic_wallpaper.c:(.text+0x40a0): undefined reference to `cos'
dynamic_wallpaper.c:(.text+0x40cc): undefined reference to `acos'
dynamic_wallpaper.c:(.text+0x42bc): undefined reference to `fmod'
dynamic_wallpaper.c:(.text+0x44bc): undefined reference to `sincos'
dynamic_wallpaper.c:(.text+0x44dc): undefined reference to `sin'
dynamic_wallpaper.c:(.text+0x4510): undefined reference to `acos'
collect2: error: ld returned 1 exit status

Mechanism:

  • GCC folds paired sin(x)/cos(x) calls into sincos() at -O2. sincos, sin, cos, acos,
    fmod live in libm, which POSIX requires linking explicitly — they are not in libc.
  • These three targets are the only math-using targets in meson.build that don't declare
    cc.find_library('m'). The file already uses this exact pattern elsewhere, e.g.
    the main shell target (line ~660) and recorder_plan_test (line ~748).
  • On x86_64 the link succeeds by accident: some dependency carries libm in its DT_NEEDED
    chain and the linker resolves the undefined symbols transitively. On aarch64 (observed on
    NixOS aarch64-linux, glibc, GCC 15) no library in the link closure provides libm, so the
    three links fail.

Fix: add cc.find_library('m') to the three targets' dependency lists, consistent with the
rest of the file.

Reference file view: https://github.com/singularityos-lab/singularity-shell/blob/aef0f372529fb69cbf38f64a427aabdfc0b4a555/meson.build (lines 905–928)


The patch

diff --git a/meson.build b/meson.build
index 65b37ac..5789d22 100644
--- a/meson.build
+++ b/meson.build
@@ -904,7 +904,7 @@ install_data('data/icons/singularity-account-secure-mail.svg',
 
 wallpaper_collections_test = executable('wallpaper-collections-test',
   sources: ['src/core/wallpaper_collections.vala', 'src/core/dynamic_wallpaper.vala', 'tests/wallpaper_collections_test.vala'],
-  dependencies: [dependency('gobject-2.0'), dependency('glib-2.0'), dependency('gio-2.0'), gee_dep, json_dep],
+  dependencies: [dependency('gobject-2.0'), dependency('glib-2.0'), dependency('gio-2.0'), gee_dep, json_dep, cc.find_library('m')],
 )
 test('wallpaper-collections', wallpaper_collections_test)
 
@@ -916,14 +916,14 @@ test('wallpaper-rotation-state', wallpaper_rotation_state_test)
 
 wallpaper_gallery_test = executable('wallpaper-gallery-test',
   sources: ['src/core/wallpaper_gallery.vala', 'src/core/dynamic_wallpaper.vala', 'tests/wallpaper_gallery_test.vala'],
-  dependencies: [dependency('gobject-2.0'), dependency('gio-2.0'), gee_dep, json_dep],
+  dependencies: [dependency('gobject-2.0'), dependency('gio-2.0'), gee_dep, json_dep, cc.find_library('m')],
 )
 test('wallpaper-gallery', wallpaper_gallery_test)
 wallpaper_rotator_test = executable('wallpaper-rotator-test',
   sources: ['src/core/wallpaper_collections.vala', 'src/core/wallpaper_gallery.vala', 'src/core/dynamic_wallpaper.vala',
             'src/core/wallpaper_rotation_state.vala', 'src/core/wallpaper_rotator.vala',
             'tests/wallpaper_rotator_test.vala'],
-  dependencies: [dependency('gobject-2.0'), dependency('glib-2.0'), dependency('gio-2.0'), gee_dep, json_dep],
+  dependencies: [dependency('gobject-2.0'), dependency('glib-2.0'), dependency('gio-2.0'), gee_dep, json_dep, cc.find_library('m')],
 )
 test('wallpaper-rotator', wallpaper_rotator_test)
 

dynamic_wallpaper.vala's sun-elevation math gets sin(x)+cos(x) pairs folded
into sincos() by GCC at -O2. sincos/sin/cos/acos/fmod are in libm, which
these targets didn't link. On x86_64 some dependency's DT_NEEDED chain
resolves them transitively, but on aarch64-linux the closure provides no
libm and the three links fail with "undefined reference to `sincos'".

Add cc.find_library('m'), matching the other math-using targets in this
file (recorder-plan-test, the main shell binary).

Assisted-by: opencode:GLM-5.3-Flash
AI-Scope: Applied the validated arm-libm.patch from the upstream fix report (adds cc.find_library('m') to the three wallpaper test executables in meson.build); patch and suggested commit message provided by the report at the user's request.
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.

1 participant