Skip to content

glib2: fix builds by explicitly disabling libelf#28524

Open
exludai wants to merge 1 commit intoopenwrt:masterfrom
exludai:glib2-disable-libelf
Open

glib2: fix builds by explicitly disabling libelf#28524
exludai wants to merge 1 commit intoopenwrt:masterfrom
exludai:glib2-disable-libelf

Conversation

@exludai
Copy link

@exludai exludai commented Feb 7, 2026

glib2 compile randomly failed due to

../gio/gresource-tool.c:34:10: fatal error: libelf.h: No such file or directory
   34 | #include <libelf.h>
      |          ^~~~~~~~~~
compilation terminated.

mechanism is unclear yet. the direct reason is:
1, meson detected dependency libelf (refer to glib2/gio/meson.build rules)
2, but the libelf.h is not in the staging directory

although the mechanism is unclear, here in glib2/makefile something can be fixed.
1, commit e1d8f4f disabled the libelf feature
2, commit 71b7b44 deleted that, to avoid setting default meson options

the argument is: libelf feature is not "disabled" by default in glib2 meson options, it is "auto", and "auto" is not equivalent to "disabled". based on the argument, suggest to disable glib2 feature explicitly.

fixes: #23459

📦 Package Details

Maintainer: @neheb @Ansuel @GeorgeSapkin

Description:


🧪 Run Testing Details

  • OpenWrt Version: openwrt-24.10
  • OpenWrt Target/Subtarget: mediatek/filogic
  • OpenWrt Device: Mozart V2

✅ Formalities

  • [✅] I have reviewed the CONTRIBUTING.md file for detailed contributing guidelines.

If your PR contains a patch:

  • It can be applied using git am
  • It has been refreshed to avoid offsets, fuzzes, etc., using
    make package/<your-package>/refresh V=s
  • It is structured in a way that it is potentially upstreamable
    (e.g., subject line, commit description, etc.)
    We must try to upstream patches to reduce maintenance burden.

@GeorgeSapkin
Copy link
Member

If this fixes an issue introduces in a previous commit, please add it to Fixes: tag.

Also, how did you test this?

@GeorgeSapkin
Copy link
Member

The Fixes: tag should go into the commit message in the form of Fixes: 01234567 ("Another commit's subject").

@exludai exludai force-pushed the glib2-disable-libelf branch from eb77273 to cae6e0c Compare February 9, 2026 07:41
Copy link
Member

@ynezz ynezz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@exludai I would suggest to add more details into the commit description, so everyone knows why is this change needed.

glib2: fix builds by explicitly disabling libelf

The libelf Meson option defaults to auto. Since commit 71b7b4478906 ("glib2: do not set default meson options"),
glib2 can enable libelf support nondeterministically depending on whether libelf.pc is visible during configure.

On failing builders Meson reports:

    Run-time dependency libelf found: YES 0.192

 and gresource later fails with:

    ../gio/gresource-tool.c:34:10: fatal error: libelf.h: No such file or directory

On passing builders we see:

    Run-time dependency libelf found: NO (tried pkgconfig and cmake)

So explicitly disable libelf again to restore deterministic builds.

Fixes: 71b7b4478906 ("glib2: do not set default meson options")

Timeline of failing build

From the failing build log, Meson did enable libelf in openwrt-build.log:64738:

  Configuring config.py using configuration
  Message: Found bash-completion but the .pc file did not set 'completionsdir', fallback to a predefined path
  Run-time dependency libelf found: YES 0.192
  Compiler for C supports arguments -Wno-implicit-fallthrough: YES

Later, the same build fails compiling gresource in openwrt-build.log:75896:

  FAILED: gio/gresource.p/gresource-tool.c.o
  x86_64-openwrt-linux-musl-gcc ... -o gio/gresource.p/gresource-tool.c.o -c ../gio/gresource-tool.c
  ../gio/gresource-tool.c:34:10: fatal error: libelf.h: No such file or directory
     34 | #include <libelf.h>
        |          ^~~~~~~~~~
  compilation terminated.

Only later does elfutils stage the target headers and libelf.pc in openwrt-build.log:88850:

  install -d -m0755 /home/openwrt/openwrt/tmp/stage-elfutils/usr/include
  cp -fpR /home/openwrt/openwrt/build_dir/target-x86_64_musl/elfutils-0.192/ipkg-install/usr/include/* /home/openwrt/openwrt/tmp/
  stage-elfutils/usr/include/
  ...
  cp -fpR /home/openwrt/openwrt/build_dir/target-x86_64_musl/elfutils-0.192/ipkg-install/usr/lib/pkgconfig/libelf.pc /home/openwrt/
  openwrt/tmp/stage-elfutils/usr/lib/pkgconfig/

@ynezz ynezz changed the title glib2: disable libelf glib2: fix builds by explicitly disabling libelf Mar 10, 2026
@exludai exludai force-pushed the glib2-disable-libelf branch from cae6e0c to 89c403c Compare March 14, 2026 21:57
@exludai
Copy link
Author

exludai commented Mar 14, 2026

Hi @GeorgeSapkin thank you for the review

If this fixes an issue introduces in a previous commit, please add it to Fixes: tag.
The Fixes: tag should go into the commit message in the form of Fixes: 01234567 ("Another commit's subject").

added the Fixes tag

Also, how did you test this?

randomly hit in ci job

Hi @ynezz thank you for the detailed review

I would suggest to add more details into the commit description, so everyone knows why is this change needed.

took your writings in the commit message

Copy link
Member

@ynezz ynezz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@feckert
Copy link
Member

feckert commented Mar 16, 2026

Please bump the PKG_RELEASE by one in the makefile with this commit.

The libelf Meson option defaults to auto. Since commit 71b7b44 ("glib2: do not set default meson options"),
glib2 can enable libelf support nondeterministically depending on whether libelf.pc is visible during configure.

On failing builders Meson reports:

    Run-time dependency libelf found: YES 0.192

 and gresource later fails with:

    ../gio/gresource-tool.c:34:10: fatal error: libelf.h: No such file or directory

On passing builders we see:

    Run-time dependency libelf found: NO (tried pkgconfig and cmake)

So explicitly disable libelf again to restore deterministic builds.

Fixes: 71b7b44 ("glib2: do not set default meson options")

Signed-off-by: Lu Dai <lu.dai@mind.be>
@exludai exludai force-pushed the glib2-disable-libelf branch from 89c403c to 8f39593 Compare March 16, 2026 08:03
@exludai
Copy link
Author

exludai commented Mar 16, 2026

Please bump the PKG_RELEASE by one in the makefile with this commit.

increased the PKG_RELEASE. thanks for the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants