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

doesn't compile with cpupower 4.9.0 #238

Closed
skoehler opened this issue Mar 26, 2017 · 20 comments · Fixed by #413
Closed

doesn't compile with cpupower 4.9.0 #238

skoehler opened this issue Mar 26, 2017 · 20 comments · Fixed by #413

Comments

@skoehler
Copy link

skoehler commented Mar 26, 2017

On Gentoo, I'm forced to downgrade cpupower 4.5.0 because of mate-applets.
When trying to compile mate-applets with cpupower 4.9.0 installed, I get the following error message:

libtool: link: x86_64-pc-linux-gnu-gcc -O2 -pipe -mtune=native -march=haswell -Wl,-O1 -o mate-cpufreq-applet cpufreq-applet.o cpufreq-utils.o cpufreq-prefs.o cpufreq-selector.o cpufreq-popup.o cpufreq-monitor.o cpufreq-monitor-factory.o cpufreq-monitor-procfs.o cpufreq-monitor-sysfs.o cpufreq-monitor-libcpufreq.o cpufreq-monitor-cpuinfo.o  -Wl,--as-needed -lmate-panel-applet-4 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lcpupower -ldbus-glib-1 -ldbus-1 -lgobject-2.0 -lglib-2.0
cpufreq-monitor-libcpufreq.o: In function `cpufreq_monitor_libcpufreq_run':
cpufreq-monitor-libcpufreq.c:(.text+0x333): undefined reference to `cpufreq_cpu_exists'
collect2: error: ld returned 1 exit status

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@monsta
Copy link
Contributor

monsta commented Mar 27, 2017

@kajzersoze: could it be related to the patch that you posted in the first comment at a708224?

Yeah, I know we need to solve this properly. 😞
I just noticed cpufreq_cpu_exists in the log above, and it shouldn't be there.

@muktupavels
Copy link
Contributor

Are you doing code reviews before merging something, or just test if code compiles and still runs? Your existing fix have two problems:

  • fix pretends that -lcpupower is only lib used with cpufreq applet. -lcpufreq has only cpufreq_cpu_exists function and it does not depend on kernel version. same was true for -lcpupower until kernel 4.7 where cpufreq_cpu_exists was removed and cpupower_is_cpu_online added.
  • cpupower_is_cpu_online can return 1 if cpu is online, 0 if cpu is offline and negative errno values in error case. I doubt that you want set cpu monitor offline when cpu is actually online. Though I don't know when cpufreq_get_policy can fail and if in that case cpu can be really still online.

Pull request #217 is wrong. HAVE_LIBCPUFREQ is defined when cpufreq.h is found, it does not tell if -lcpupower or -lcpufreq is used...

Pull request #277 is better, but still wrong. What if someone has that header installed, but tries to build with -lcpufreq? What if someone will try to build with -lcpupower and older kernel that does not install header? That patch might be good for downstreams that do install that header and builds with -lcpupower...

@muktupavels
Copy link
Contributor

@lukefromdc
Copy link
Member

I have libcpupower1 4.14-7-1 in Debian Unstable and have not had any trouble compiling mate-applets including the cpufreq applet. Using these build options:

--prefix=/usr libdir=/usr/lib/x86_64-linux-gnu --sysconfdir=/etc --enable-shared=yes --disable-maintainer-mode --disable-schemas-compile

Last one so Checkinstall does not pick up the compiled schemas, they are compiled in postinst

@lukefromdc
Copy link
Member

I DO get these two errors in config.log, but configuration then continues:

configure:17272: result: no
configure:17272: checking cpufreq.h presence
configure:17272: gcc -E  conftest.c
conftest.c:38:10: fatal error: cpufreq.h: No such file or directory
 #include <cpufreq.h>
          ^~~~~~~~~~~
compilation terminated.
configure:17272: $? = 1

 #include <cpufreq.h>
configure:17272: result: no
configure:17272: checking for cpufreq.h
configure:17272: result: no
configure:17358: checking for libiw >= 28pre9
configure:17375: gcc -c -g -O2  conftest.c >&5
conftest.c:39:26: fatal error: iwlib.h: No such file or directory
                 #include <iwlib.h>
                          ^~~~~~~~~

I get
ac_cv_header_cpufreq_h=no

BUILD_CPUFREQ_APPLET_FALSE='#'
BUILD_CPUFREQ_APPLET_TRUE=''
BUILD_CPUFREQ_SELECTOR_FALSE='#'
BUILD_CPUFREQ_SELECTOR_TRUE=''

CPUFREQ_SELECTOR_CFLAGS='-I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include'
CPUFREQ_SELECTOR_LIBS='-lgobject-2.0 -lglib-2.0'
CPUFREQ_SELECTOR_SUID_FALSE=''
CPUFREQ_SELECTOR_SUID_TRUE='#'


HAVE_LIBCPUFREQ_FALSE=''
HAVE_LIBCPUFREQ_TRUE='#'
and 
LIBCPUFREQ_LIBS=''

@muktupavels
Copy link
Contributor

muktupavels commented Jan 8, 2018

MATE applets defaults to cpupower lib according to configure.ac, try to build with --with-cpufreq-lib=cpufreq. It will fail if you have kernel 4.7.0 or newer since that lib does not have cpupower_is_cpu_online function.

EDIT:
fatal error: cpufreq.h: No such file or directory probably just shows that you have not required dep installed!?

@muktupavels
Copy link
Contributor

P.S.S. even if you don`t care about build failures you have problem:

if (cpupower_is_cpu_online (cpu)) {

Do you really want to mark CPU as offline when it is ONLINE? cpupower_is_cpu_online (cpu) returns 1 when cpu is online so if reads as when cpu is online do this...

@lukefromdc
Copy link
Member

That "fatal error" report is odd, because configuration and build do not actually stop, and the cpufreq applet works fine. Note that I am using AMD desktops and an old Intel Atom netbook, I do not have any recent Intel stuff so I might not be seeing runtime errors.

Using
--with-cpufreq-lib=cpufreq
didn't change anything at all in the test I just ran with git master (1.19)

@lukefromdc
Copy link
Member

I did get an odd runtime result with --with-cpufreq-lib=cpufreq though: the applet's UI works fine and shows selected speeds, but they don't actually change. Compiles, builds-but does not actually work, only appears to

@lukefromdc
Copy link
Member

Also, not sure if any of the (cpupower_is_cpu_online (cpu)) stuff even works with AMD. The Intel Atom netbook is a single core, the older AMD Phenom II boxes don't support core parking, and the AMD Bulldozer setup does supposedly support it but I've never once seen a core not shown as in use. I have conky showing load on all 8 threads of 4 bulldozer modules. I have no multicore Intel boxes at all.

@muktupavels
Copy link
Contributor

Can you attach somewhere full build log and maybe generated config.h file? I guess build does not fail, because HAVE_LIBCPUFREQ is not defined and you have cpufreq applet compiled without cpufreq part:
https://github.com/mate-desktop/mate-applets/blob/master/cpufreq/src/Makefile.am#L15

There is definitely problem if you build with cpufreq. For example, in Ubuntu, it is only option. Your build should fail because cpupower_is_cpu_online does not exist in cpufreq library. Probably Ubuntu is only reason why we still need cpufreq support, it is deprecated and unmaintained.

Just checked, ubuntu has patch that reverts / removes kernel version check.

Then as I already said, if (cpupower_is_cpu_online (cpu)) is wrong. There is comment Check whether it failed because cpu is not online., bet if checks if cpu is online. See return values:
https://github.com/torvalds/linux/blob/master/tools/power/cpupower/lib/cpupower.c#L39

@lukefromdc
Copy link
Member

lukefromdc commented Jan 9, 2018

Here is a configuration log from a "successful" build with --with-cpufreq-lib=cpufreq :

config.log

And config.h (could not attach):

/* config.h.  Generated from config.h.in by configure.  */
/* config.h.in.  Generated from configure.ac by autoheader.  */

/* datadir */
#define DATADIR "/usr/share"

/* Define if system is IPv6 enabled */
#define ENABLE_IPV6 1

/* always defined to indicate that i18n is enabled */
#define ENABLE_NLS 1

/* Gettext Package */
#define GETTEXT_PACKAGE "mate-applets"

/* GtkBuilder Resources Directory */
#define GTK_BUILDERDIR "/usr/share/mate-applets/builder"

/* Define if acpiio.h exists on the system */
/* #undef HAVE_ACPIIO */

/* Define to 1 if you have the `bind_textdomain_codeset' function. */
#define HAVE_BIND_TEXTDOMAIN_CODESET 1

/* Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the
   CoreFoundation framework. */
/* #undef HAVE_CFLOCALECOPYCURRENT */

/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in
   the CoreFoundation framework. */
/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */

/* Define to 1 if you have the `dcgettext' function. */
#define HAVE_DCGETTEXT 1

/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1

/* Define to 1 if you have the <err.h> header file. */
#define HAVE_ERR_H 1

/* Define if getaddrinfo() exists on the system */
#define HAVE_GETADDRINFO 1

/* Define if the GNU gettext() function is already present or preinstalled. */
#define HAVE_GETTEXT 1

/* Gucharmap Available */
/* #undef HAVE_GUCHARMAP */

/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

/* Defined if you have libiw/wireless-tools (depends on the distro) */
/* #undef HAVE_IW */

/* Define if your <locale.h> file defines LC_MESSAGES. */
#define HAVE_LC_MESSAGES 1

/* Have libcpufreq. */
/* #undef HAVE_LIBCPUFREQ */

/* libnotify available */
#define HAVE_LIBNOTIFY 1

/* Define to 1 if you have the <locale.h> header file. */
#define HAVE_LOCALE_H 1

/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1

/* PolicyKit available */
#define HAVE_POLKIT 1

/* Define to 1 if you have the <pty.h> header file. */
#define HAVE_PTY_H 1

/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1

/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1

/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1

/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1

/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1

/* Define to 1 if you have the <sys/sysctl.h> header file. */
#define HAVE_SYS_SYSCTL_H 1

/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1

/* Have timezone */
/* #undef HAVE_TIMEZONE */

/* Have the tm.tm_gmtoff member. */
#define HAVE_TM_TM_GMOFF 1

/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1

/* UPOWER available */
#define HAVE_UPOWER 1

/* Define to 1 if you have the <values.h> header file. */
#define HAVE_VALUES_H 1

/* Define if _NL_MEASUREMENT_MEASUREMENT is available */
#define HAVE__NL_MEASUREMENT_MEASUREMENT 1

/* libdir */
#define LIBDIR "/usr/lib/x86_64-linux-gnu"

/* Define to the sub-directory where libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"

/* locale directory */
#define MATELOCALEDIR "/usr/share/locale"

/* Mate Icon Directory */
#define MATE_ICONDIR "/usr/share/icons"

/* Mate Pixmaps Directory */
#define MATE_PIXMAPSDIR "/usr/share/pixmaps"

/* Name of package */
#define PACKAGE "mate-applets"

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""

/* Define to the full name of this package. */
#define PACKAGE_NAME "mate-applets"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "mate-applets 1.19.3"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "mate-applets"

/* Define to the home page for this package. */
#define PACKAGE_URL ""

/* Define to the version of this package. */
#define PACKAGE_VERSION "1.19.3"

/* Mate Applets Directory */
#define PKGDATADIR "/usr/share/mate-applets"

/* pkgdatadir */
#define PKG_DATA_DIR "/usr/share/mate-applets"

/* install prefix */
#define PREFIX "/usr"

/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1

/* sysconfdir */
#define SYSCONFDIR "/etc"

/* Version number of package */
#define VERSION "1.19.3"

/* Define to 1 if the X Window System is missing or not being used. */
/* #undef X_DISPLAY_MISSING */


Didn't get any kind of build log

@muktupavels
Copy link
Contributor

@lukefromdc
Copy link
Member

Nothing more I can do with this at the moment

@muktupavels
Copy link
Contributor

Install build dependency libcpupower-dev and/or libcpufreq-dev...

@lukefromdc
Copy link
Member

A missing build dependency (including one for an explicitly specified option) normally causes configuration to stop on an error. In this case it did not. Will test this though

@lukefromdc
Copy link
Member

OK, here's what I got testing all three ways, noting that libcpupower-dev and libcpufreq-dev have to be installed one or the other as they conflict with each other. I'm using linux 4.15.0-rc4, and it turns out a default build no longer controls the frequency at all. A build with libcpupower finishes and works, a build with libcpufreq errors out. Note that this testing fixed a bug for me...

default build:

build completes
no actual frequency change on select with 4.15-rc4

--with-cpufreq-lib=cpupower
build completes
frequency changes on select with 4.15-rc4
does not actually hold a single value but changes within a narrower range
on a userspace governor (probably a bulldozer feature with this)
the top value governor (4.40 GHZ) and "performance" seem identical in results

--with-cpufreq-lib=cpufreq

Build fails, stops on


cpufreq-monitor-libcpufreq.o: In function `cpufreq_monitor_libcpufreq_run':
/home/luke/Desktop/Development/MATE_Development_Work/mate-applets_1.19.3+git20171230/cpufreq/src/cpufreq-monitor-libcpufreq.c:117: undefined reference to `cpupower_is_cpu_online'
collect2: error: ld returned 1 exit status
Makefile:580: recipe for target 'mate-cpufreq-applet' failed

I noticed that libcpupower-dev is a much larger package than libcpufreq-dev. I don't know if this is a superset of features or what, but maybe the newer kernels simply need cpupower instead of cpufreq at this point?

@muktupavels
Copy link
Contributor

Check the code!

If you build without cpufreq and cpupower you get something that was written for kernel 2.6! No idea if that is supposed to to work these days:
https://github.com/mate-desktop/mate-applets/blob/master/cpufreq/src/cpufreq-monitor-factory.c#L49

Build with cpufreq fails because cpupower_is_cpu_online has never existed in there, it is cpupower lib only function. Code should use cpufreq_cpu_exists when built with cpufreq.

@lukefromdc
Copy link
Member

That's what I had been building until today-and it worked until very recently at least on AMD and on Intel Atom or at least appeared to, with Conky and the applet agreeing on what the CPU frequency was. Fan speeds and temperatures also seemed appropriate to the indicated speeds.

It was just in testing this stuff yesterday that I noticed that frequency changes set by the applet (and shown by it) no longer registered in Conky's frequency monitor. Using cpupower fixed this.

Not sure what kernel version changed this, but well after 4.9 there were more power/frequency handling changes that broke a lot of stuff. Until very recently my default builds with neither library's dev packages seemed to be working fine.

@lukefromdc
Copy link
Member

/sys/devices/system/cpu/cpu0/cpufreq

Still shows up in my filesystem, it's a directory full of files such as /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor and /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

So I think what changed is that the old code lost the ability to write to these files with a recent kernel change-after having worked all the way back to kernel 2.6/

sunweaver added a commit to sunweaver/mate-applets that referenced this issue Aug 10, 2019
  Ported from gnome-applets, see

    git diff e48b2d73~..5882df7f cpufreq/ configure.ac

  on the gnome-applets repository.

  Fixes mate-desktop#238.
@sc0w sc0w closed this as completed in #413 Aug 29, 2019
sc0w pushed a commit that referenced this issue Aug 29, 2019
  Ported from gnome-applets, see

    git diff e48b2d73~..5882df7f cpufreq/ configure.ac

  on the gnome-applets repository.

  Fixes #238.
sc0w pushed a commit that referenced this issue Aug 29, 2019
  Ported from gnome-applets, see

    git diff e48b2d73~..5882df7f cpufreq/ configure.ac

  on the gnome-applets repository.

  Fixes #238.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants