FeralInteractive / gamemode

Optimise Linux system performance on demand
BSD 3-Clause "New" or "Revised" License
4.69k stars 185 forks source link

cannot build due to multiple errors #410

Closed airidassimanskis closed 9 months ago

airidassimanskis commented 1 year ago

Describe the bug Gamemode does not build and stops the build due to multiple errors

To Reproduce ./bootstrap.sh

Expected behavior should build

System Info (please complete the following information):

+ meson builddir --prefix=/usr --buildtype debugoptimized -Dwith-systemd-user-unit-dir=/etc/systemd/user
Directory already configured.

Just run your build command (e.g. ninja) and Meson will regenerate as necessary.
If ninja fails, run "ninja reconfigure" or "meson setup --reconfigure"
to force Meson to regenerate.

If build failures persist, run "meson setup --wipe" to rebuild from scratch
using the same options as passed when configuring the build.
To change option values, run "meson configure" instead.
WARNING: Running the setup command as `meson [options]` instead of `meson setup [options]` is ambiguous and deprecated.
+ ninja -C builddir
ninja: Entering directory `builddir'
[1/8] Compiling C object common/libdaemon-common.a.p/common-pidfds.c.o
FAILED: common/libdaemon-common.a.p/common-pidfds.c.o 
cc -Icommon/libdaemon-common.a.p -Icommon -I../common -I. -I.. -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c11 -O2 -g -fstack-protector -Wstrict-prototypes -Wundef -fno-common -Werror-implicit-function-declaration -Wformat-security -Werror=format-security -Wconversion -Wunreachable-code -Waggregate-return -Wunused -Warray-bounds -Wcast-align -Wclobbered -Wempty-body -Wformat=2 -Wformat-nonliteral -Wformat-signedness -Wignored-qualifiers -Wimplicit-function-declaration -Winit-self -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wmissing-parameter-type -Wnested-externs -Wno-discarded-qualifiers -Wno-missing-field-initializers -Wno-suggest-attribute=format -Wno-unused-parameter -Wold-style-definition -Woverride-init -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wsign-compare -Wstrict-aliasing=3 -Wstrict-prototypes -Wstringop-overflow -Wstringop-truncation -Wtype-limits -Wundef -Wuninitialized -Wunused-but-set-variable -Wwrite-strings -fPIC -MD -MQ common/libdaemon-common.a.p/common-pidfds.c.o -MF common/libdaemon-common.a.p/common-pidfds.c.o.d -o common/libdaemon-common.a.p/common-pidfds.c.o -c ../common/common-pidfds.c
../common/common-pidfds.c: In function ‘open_pidfds’:
../common/common-pidfds.c:70:26: error: implicit declaration of function ‘pidfd_open’; did you mean ‘fdopen’? [-Werror=implicit-function-declaration]
   70 |                 int fd = pidfd_open(pid, 0);
      |                          ^~~~~~~~~~
      |                          fdopen
../common/common-pidfds.c:70:26: warning: nested extern declaration of ‘pidfd_open’ [-Wnested-externs]
cc1: some warnings being treated as errors
[2/8] Compiling C object common/liblib-common.a.p/common-pidfds.c.o
FAILED: common/liblib-common.a.p/common-pidfds.c.o 
cc -Icommon/liblib-common.a.p -Icommon -I../common -I. -I.. -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c11 -O2 -g -fstack-protector -Wstrict-prototypes -Wundef -fno-common -Werror-implicit-function-declaration -Wformat-security -Werror=format-security -Wconversion -Wunreachable-code -Waggregate-return -Wunused -Warray-bounds -Wcast-align -Wclobbered -Wempty-body -Wformat=2 -Wformat-nonliteral -Wformat-signedness -Wignored-qualifiers -Wimplicit-function-declaration -Winit-self -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wmissing-parameter-type -Wnested-externs -Wno-discarded-qualifiers -Wno-missing-field-initializers -Wno-suggest-attribute=format -Wno-unused-parameter -Wold-style-definition -Woverride-init -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wsign-compare -Wstrict-aliasing=3 -Wstrict-prototypes -Wstringop-overflow -Wstringop-truncation -Wtype-limits -Wundef -Wuninitialized -Wunused-but-set-variable -Wwrite-strings -fPIC -MD -MQ common/liblib-common.a.p/common-pidfds.c.o -MF common/liblib-common.a.p/common-pidfds.c.o.d -o common/liblib-common.a.p/common-pidfds.c.o -c ../common/common-pidfds.c
../common/common-pidfds.c: In function ‘open_pidfds’:
../common/common-pidfds.c:70:26: error: implicit declaration of function ‘pidfd_open’; did you mean ‘fdopen’? [-Werror=implicit-function-declaration]
   70 |                 int fd = pidfd_open(pid, 0);
      |                          ^~~~~~~~~~
      |                          fdopen
../common/common-pidfds.c:70:26: warning: nested extern declaration of ‘pidfd_open’ [-Wnested-externs]
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.
ajoseps commented 1 year ago

I took cannot build for branch 1.7: OS:

$ cat /etc/os-release
NAME="Pop!_OS"
VERSION="22.04 LTS"
ID=pop
ID_LIKE="ubuntu debian"
PRETTY_NAME="Pop!_OS 22.04 LTS"
VERSION_ID="22.04"
HOME_URL="https://pop.system76.com"
SUPPORT_URL="https://support.system76.com"
BUG_REPORT_URL="https://github.com/pop-os/pop/issues"
PRIVACY_POLICY_URL="https://system76.com/privacy"
VERSION_CODENAME=jammy
UBUNTU_CODENAME=jammy
LOGO=distributor-logo-pop-os
$ uname -mrs
Linux 6.2.1-060201-generic x86_64
$ ./bootstrap.sh 
+ meson builddir --prefix=/usr --buildtype debugoptimized -Dwith-systemd-user-unit-dir=/etc/systemd/user
Directory already configured.

Just run your build command (e.g. ninja) and Meson will regenerate as necessary.
If ninja fails, run "ninja reconfigure" or "meson --reconfigure"
to force Meson to regenerate.

If build failures persist, run "meson setup --wipe" to rebuild from scratch
using the same options as passed when configuring the build.
To change option values, run "meson configure" instead.
+ ninja -C builddir
ninja: Entering directory `builddir'
[1/10] Compiling C object daemon/gamemoded.p/gamemoded.c.o
FAILED: daemon/gamemoded.p/gamemoded.c.o 
/home/ajoseph/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -Idaemon/gamemoded.p -Idaemon -I../daemon -Ilib -I../lib -I. -I.. -Icommon -I../common -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c11 -O2 -g -fstack-protector -Wstrict-prototypes -Wundef -fno-common -Werror-implicit-function-declaration -Wformat-security -Werror=format-security -Wconversion -Wunreachable-code -Waggregate-return -Wunused -Warray-bounds -Wcast-align -Wclobbered -Wempty-body -Wformat=2 -Wformat-nonliteral -Wformat-signedness -Wignored-qualifiers -Wimplicit-function-declaration -Winit-self -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wmissing-parameter-type -Wnested-externs -Wno-discarded-qualifiers -Wno-missing-field-initializers -Wno-suggest-attribute=format -Wno-unused-parameter -Wold-style-definition -Woverride-init -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wsign-compare -Wstrict-aliasing=3 -Wstrict-prototypes -Wstringop-overflow -Wtype-limits -Wundef -Wuninitialized -Wunused-but-set-variable -Wwrite-strings -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/ajoseph/anaconda3/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/ajoseph/anaconda3/include -pthread -MD -MQ daemon/gamemoded.p/gamemoded.c.o -MF daemon/gamemoded.p/gamemoded.c.o.d -o daemon/gamemoded.p/gamemoded.c.o -c ../daemon/gamemoded.c
../daemon/gamemoded.c:64:10: fatal error: systemd/sd-daemon.h: No such file or directory
 #include <systemd/sd-daemon.h> /* TODO: Move usage to gamemode-dbus.c */
          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[2/10] Compiling C object daemon/gamemoded.p/gamemode-dbus.c.o
FAILED: daemon/gamemoded.p/gamemode-dbus.c.o 
/home/ajoseph/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -Idaemon/gamemoded.p -Idaemon -I../daemon -Ilib -I../lib -I. -I.. -Icommon -I../common -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c11 -O2 -g -fstack-protector -Wstrict-prototypes -Wundef -fno-common -Werror-implicit-function-declaration -Wformat-security -Werror=format-security -Wconversion -Wunreachable-code -Waggregate-return -Wunused -Warray-bounds -Wcast-align -Wclobbered -Wempty-body -Wformat=2 -Wformat-nonliteral -Wformat-signedness -Wignored-qualifiers -Wimplicit-function-declaration -Winit-self -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wmissing-parameter-type -Wnested-externs -Wno-discarded-qualifiers -Wno-missing-field-initializers -Wno-suggest-attribute=format -Wno-unused-parameter -Wold-style-definition -Woverride-init -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wsign-compare -Wstrict-aliasing=3 -Wstrict-prototypes -Wstringop-overflow -Wtype-limits -Wundef -Wuninitialized -Wunused-but-set-variable -Wwrite-strings -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/ajoseph/anaconda3/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/ajoseph/anaconda3/include -pthread -MD -MQ daemon/gamemoded.p/gamemode-dbus.c.o -MF daemon/gamemoded.p/gamemode-dbus.c.o.d -o daemon/gamemoded.p/gamemode-dbus.c.o -c ../daemon/gamemode-dbus.c
../daemon/gamemode-dbus.c:43:10: fatal error: systemd/sd-bus.h: No such file or directory
 #include <systemd/sd-bus.h>
          ^~~~~~~~~~~~~~~~~~
compilation terminated.
[3/10] Compiling C object daemon/gamemoded.p/gamemode-config.c.o
FAILED: daemon/gamemoded.p/gamemode-config.c.o 
/home/ajoseph/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -Idaemon/gamemoded.p -Idaemon -I../daemon -Ilib -I../lib -I. -I.. -Icommon -I../common -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c11 -O2 -g -fstack-protector -Wstrict-prototypes -Wundef -fno-common -Werror-implicit-function-declaration -Wformat-security -Werror=format-security -Wconversion -Wunreachable-code -Waggregate-return -Wunused -Warray-bounds -Wcast-align -Wclobbered -Wempty-body -Wformat=2 -Wformat-nonliteral -Wformat-signedness -Wignored-qualifiers -Wimplicit-function-declaration -Winit-self -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wmissing-parameter-type -Wnested-externs -Wno-discarded-qualifiers -Wno-missing-field-initializers -Wno-suggest-attribute=format -Wno-unused-parameter -Wold-style-definition -Woverride-init -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wsign-compare -Wstrict-aliasing=3 -Wstrict-prototypes -Wstringop-overflow -Wtype-limits -Wundef -Wuninitialized -Wunused-but-set-variable -Wwrite-strings -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/ajoseph/anaconda3/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/ajoseph/anaconda3/include -pthread -MD -MQ daemon/gamemoded.p/gamemode-config.c.o -MF daemon/gamemoded.p/gamemode-config.c.o.d -o daemon/gamemoded.p/gamemode-config.c.o -c ../daemon/gamemode-config.c
../daemon/gamemode-config.c:41:10: fatal error: ini.h: No such file or directory
 #include <ini.h>
          ^~~~~~~
compilation terminated.
[4/10] Compiling C object daemon/gamemoded.p/gamemode-context.c.o
FAILED: daemon/gamemoded.p/gamemode-context.c.o 
/home/ajoseph/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -Idaemon/gamemoded.p -Idaemon -I../daemon -Ilib -I../lib -I. -I.. -Icommon -I../common -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c11 -O2 -g -fstack-protector -Wstrict-prototypes -Wundef -fno-common -Werror-implicit-function-declaration -Wformat-security -Werror=format-security -Wconversion -Wunreachable-code -Waggregate-return -Wunused -Warray-bounds -Wcast-align -Wclobbered -Wempty-body -Wformat=2 -Wformat-nonliteral -Wformat-signedness -Wignored-qualifiers -Wimplicit-function-declaration -Winit-self -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wmissing-parameter-type -Wnested-externs -Wno-discarded-qualifiers -Wno-missing-field-initializers -Wno-suggest-attribute=format -Wno-unused-parameter -Wold-style-definition -Woverride-init -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wsign-compare -Wstrict-aliasing=3 -Wstrict-prototypes -Wstringop-overflow -Wtype-limits -Wundef -Wuninitialized -Wunused-but-set-variable -Wwrite-strings -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/ajoseph/anaconda3/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/ajoseph/anaconda3/include -pthread -MD -MQ daemon/gamemoded.p/gamemode-context.c.o -MF daemon/gamemoded.p/gamemode-context.c.o.d -o daemon/gamemoded.p/gamemode-context.c.o -c ../daemon/gamemode-context.c
../daemon/gamemode-context.c:52:10: fatal error: systemd/sd-daemon.h: No such file or directory
 #include <systemd/sd-daemon.h> /* TODO: Move usage to gamemode-dbus.c */
          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[5/10] Compiling C object common/libdaemon-common.a.p/common-governors.c.o
FAILED: common/libdaemon-common.a.p/common-governors.c.o 
/home/ajoseph/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -Icommon/libdaemon-common.a.p -Icommon -I../common -I. -I.. -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c11 -O2 -g -fstack-protector -Wstrict-prototypes -Wundef -fno-common -Werror-implicit-function-declaration -Wformat-security -Werror=format-security -Wconversion -Wunreachable-code -Waggregate-return -Wunused -Warray-bounds -Wcast-align -Wclobbered -Wempty-body -Wformat=2 -Wformat-nonliteral -Wformat-signedness -Wignored-qualifiers -Wimplicit-function-declaration -Winit-self -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wmissing-parameter-type -Wnested-externs -Wno-discarded-qualifiers -Wno-missing-field-initializers -Wno-suggest-attribute=format -Wno-unused-parameter -Wold-style-definition -Woverride-init -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wsign-compare -Wstrict-aliasing=3 -Wstrict-prototypes -Wstringop-overflow -Wtype-limits -Wundef -Wuninitialized -Wunused-but-set-variable -Wwrite-strings -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/ajoseph/anaconda3/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/ajoseph/anaconda3/include -fPIC -MD -MQ common/libdaemon-common.a.p/common-governors.c.o -MF common/libdaemon-common.a.p/common-governors.c.o.d -o common/libdaemon-common.a.p/common-governors.c.o -c ../common/common-governors.c
../common/common-governors.c: In function 'fetch_governors':
../common/common-governors.c:88:3: error: implicit declaration of function 'static_assert' [-Werror=implicit-function-declaration]
   static_assert(MAX_GOVERNOR_LENGTH > PATH_MAX, "possible string truncation");
   ^~~~~~~~~~~~~
../common/common-governors.c:88:3: warning: nested extern declaration of 'static_assert' [-Wnested-externs]
cc1: some warnings being treated as errors
[6/10] Compiling C object daemon/gamemoded.p/gamemode-wine.c.o
FAILED: daemon/gamemoded.p/gamemode-wine.c.o 
/home/ajoseph/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -Idaemon/gamemoded.p -Idaemon -I../daemon -Ilib -I../lib -I. -I.. -Icommon -I../common -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c11 -O2 -g -fstack-protector -Wstrict-prototypes -Wundef -fno-common -Werror-implicit-function-declaration -Wformat-security -Werror=format-security -Wconversion -Wunreachable-code -Waggregate-return -Wunused -Warray-bounds -Wcast-align -Wclobbered -Wempty-body -Wformat=2 -Wformat-nonliteral -Wformat-signedness -Wignored-qualifiers -Wimplicit-function-declaration -Winit-self -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wmissing-parameter-type -Wnested-externs -Wno-discarded-qualifiers -Wno-missing-field-initializers -Wno-suggest-attribute=format -Wno-unused-parameter -Wold-style-definition -Woverride-init -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wsign-compare -Wstrict-aliasing=3 -Wstrict-prototypes -Wstringop-overflow -Wtype-limits -Wundef -Wuninitialized -Wunused-but-set-variable -Wwrite-strings -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/ajoseph/anaconda3/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/ajoseph/anaconda3/include -pthread -MD -MQ daemon/gamemoded.p/gamemode-wine.c.o -MF daemon/gamemoded.p/gamemode-wine.c.o.d -o daemon/gamemoded.p/gamemode-wine.c.o -c ../daemon/gamemode-wine.c
../daemon/gamemode-wine.c: In function 'game_mode_lookup_user_home':
../daemon/gamemode-wine.c:122:21: error: implicit declaration of function 'secure_getenv'; did you mean '__secure_getenv'? [-Werror=implicit-function-declaration]
  const char *home = secure_getenv("HOME");
                     ^~~~~~~~~~~~~
                     __secure_getenv
../daemon/gamemode-wine.c:122:21: warning: nested extern declaration of 'secure_getenv' [-Wnested-externs]
../daemon/gamemode-wine.c:122:21: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.
ajoseps commented 1 year ago

The issue is that meson was using the wrong compiler. It picked up my anaconda gcc compiler instead of my system gcc. I updated the following environment variables in my ~/.bashrc:

export GCC=/usr/bin/gcc
export CC=/usr/bin/gcc
export CXX=/usr/bin/g++

I then sourced the updated ~/.bashrc.

I tried running bootstrap.sh again, but it kept picking up the old compiler. Turns out I had to remove the builddir and re-run.

After removing builddir the project built successfully.

SSUPII commented 1 year ago

The issue is that meson was using the wrong compiler. It picked up my anaconda gcc compiler instead of my system gcc. I updated the following environment variables in my ~/.bashrc:

export GCC=/usr/bin/gcc
export CC=/usr/bin/gcc
export CXX=/usr/bin/g++

I then sourced the updated ~/.bashrc.

I tried running bootstrap.sh again, but it kept picking up the old compiler. Turns out I had to remove the builddir and re-run.

After removing builddir the project built successfully.

Setting the environment makes no difference in Debian 12 gcc version 12.2.0 (Debian 12.2.0-14).

What made it compile was the checkout to the master branch, as it contains a relevant fix with https://github.com/8lendzior/gamemode/commit/9b5fb648f0fc850e34f413ce60d6211ea6624621.

afayaz-feral commented 9 months ago

It looks like the build error was due to pidfd_open() being available in glibc 2.36. #379 includes the relevant header, and this is in 1.8.