Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: 1.15.7 pre-release subproject libglnx build failure in opensuse rpmbuild environment using meson due to flaw in feature detection code #5778

Open
4 tasks done
nerditation opened this issue Apr 18, 2024 · 2 comments · May be fixed by #5799

Comments

@nerditation
Copy link

Checklist

  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.
  • If this is an issue with a particular app, I have tried filing it in the appropriate issue tracker for the app (e.g. under https://github.com/flathub/) and determined that it is an issue with Flatpak itself.
  • This issue is not a report of a security vulnerability (see here if you need to report a security issue).

Flatpak version

1.15.7 pre-release

What Linux distribution are you using?

openSUSE

Linux distribution version

tumbleweed

What architecture are you using?

x86_64

How to reproduce

  1. set CFLAGS as opensuse build service would use, specifically:
    • export CFLAGS='-Werror=return-type'
  2. build flatpak using meson

Expected Behavior

build succeeds

Actual Behavior

build failed. here's an example log file of a failed build:

  • NOTE: this is the log from an empty dummy project with libglnx as its subproject, but flatpak 1.15.7 will give the exact same error message.

https://build.opensuse.org/package/live_build_log/home:nerditation/libglnx-testing/openSUSE_Tumbleweed/x86_64

Additional Information

I was testing the fix for fcitx/fcitx5#1017, which requires a new feature in flatpak 1.15.7. opensuse tumbleweed still has 1.15.6 in it's repository, so I forked it and updated the rpm spec to use the 1.15.7 pre-release tarball as source code.

because 1.15.7 removed support for autotools, I also adapted the spec to use meson. but the build failed when compiling libglnx. so I tried to chroot into the build environment to do some digging, but if I manually call meson setup and meson compile with the same command line flags, it builds just fine.

after going through tons of log messages, I finally figured it out: opensuse's build service wants set some compiler flags before actually building the package, one of such flags is -Werror=return-type. it turns out this flag will change the behavior of libglnx's custom feature detection code snippet in its meson.build:

https://github.com/GNOME/libglnx/blob/202b294e6079e23242e65e0426f8639841d1210b/meson.build#L32-L49

because the return type at line 43 is int, -Werror=return-type will reject such code, thus the detected feature set is incorrect and later compilation fails due to duplicated function definitions.

currently, I managed to work around this with a simple patch, but it's better to be fixed upstream, since 1.15.7 is still in pre-release anyway.

-    int func (void) {
+    void func (void) {

in the long run thoug, I think we should add more feature detections to meson (similar to autoconf) so we can avoid this kind of ad-hoc feature detection in the package.

@smcv
Copy link
Collaborator

smcv commented Apr 18, 2024

it's better to be fixed upstream

The upstream for the libglnx copylib is https://gitlab.gnome.org/GNOME/libglnx.

@smcv
Copy link
Collaborator

smcv commented Apr 19, 2024

Please review/test https://gitlab.gnome.org/GNOME/libglnx/-/merge_requests/57. This is not going to be fixed as a Flatpak-specific change, but it can be fixed by fixing libglnx and then updating Flatpak's copy.

smcv added a commit to smcv/flatpak that referenced this issue May 2, 2024
* Fix function detection when using -Werror=return-type
  (Resolves: flatpak#5778)
* Add a fallback definition for G_PID_FORMAT
* Avoid warnings for g_steal_fd() when targeting older GLib

Signed-off-by: Simon McVittie <[email protected]>
@smcv smcv linked a pull request May 2, 2024 that will close this issue
smcv added a commit to smcv/flatpak that referenced this issue May 2, 2024
  * Fix function detection when using -Werror=return-type
    (Resolves: flatpak#5778)
  * Add a fallback definition for G_PID_FORMAT
  * Avoid warnings for g_steal_fd() when targeting older GLib

This commit was created via:

    git remote add --no-tags libglnx https://gitlab.gnome.org/GNOME/libglnx.git
    git fetch libglnx
    git diff HEAD:subprojects/libglnx libglnx/master
    git subtree merge -P subprojects/libglnx libglnx/master
    git commit --amend -s

Signed-off-by: Simon McVittie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants