Skip to contentSkip to conversation

cpupower: fix lib default installation path

PATCH Superseded Roman Storozhenko 2 participants 4 messages Jun 23, 2024 – Jul 1, 2024 CPU power monitoring

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpupower: fix lib default installation path

Invocation the tool built with the default settings fails:

$ cpupower
cpupower: error while loading shared libraries: libcpupower.so.1: cannot
open shared object file: No such file or directory

The issue is that Makefile puts the library to "/usr/lib64" dir for a 64 bit machine. This is wrong. According to the "File hierarchy standard specification:
https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.pdf

"/usr/lib<qual>" dirs are intended for alternative-format libraries (e.g., "/usr/lib32" for 32-bit libraries on a 64-bit machine (optional)).

The utility is built for the current machine and doesn't change bit depth.
Fix the issue by changing library destination dir to "/usr/lib".

---
 tools/power/cpupower/Makefile | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
tools/power/cpupower/Makefile +1 -9
index cd0225a312b4..6c02f401069e 100644
@@ -67,6 +67,7 @@ LANGUAGES = 			de fr it cs pt ka
 bindir ?=	/usr/bin
 sbindir ?=	/usr/sbin
 mandir ?=	/usr/man
+libdir ?=	/usr/lib
 includedir ?=	/usr/include
 localedir ?=	/usr/share/locale
 docdir ?=       /usr/share/doc/packages/cpupower
@@ -94,15 +95,6 @@ RANLIB = $(CROSS)ranlib
 HOSTCC = gcc
 MKDIR = mkdir
 
-# 64bit library detection
-include ../../scripts/Makefile.arch
-
-ifeq ($(IS_64_BIT), 1)
-libdir ?=	/usr/lib64
-else
-libdir ?=	/usr/lib
-endif
-
 # Now we set up the build system
 #
 

---
base-commit: f76698bd9a8ca01d3581236082d786e9a6b72bb7
change-id: 20240623-fix-lib-install-3b7dccdbdf45

Best regards,

Signature · 1 line
Roman Storozhenko <[email protected]>
maintainer
#1 lore raw
Quoted 34 lines · Roman Storozhenko

Invocation the tool built with the default settings fails:

$ cpupower
cpupower: error while loading shared libraries: libcpupower.so.1: cannot
open shared object file: No such file or directory> The issue is that Makefile puts the library to "/usr/lib64" dir for a 64
bit machine. This is wrong. According to the "File hierarchy standard
specification:
https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.pdf

"/usr/lib<qual>" dirs are intended for alternative-format libraries (e.g., "/usr/lib32" for 32-bit libraries on a 64-bit machine (optional)).

The utility is built for the current machine and doesn't change bit depth.
Fix the issue by changing library destination dir to "/usr/lib".

---
  tools/power/cpupower/Makefile | 10 +---------
  1 file changed, 1 insertion(+), 9 deletions(-)
tools/power/cpupower/Makefile +1 -0
index cd0225a312b4..6c02f401069e 100644
@@ -67,6 +67,7 @@ LANGUAGES = 			de fr it cs pt ka
  bindir ?=	/usr/bin
  sbindir ?=	/usr/sbin
  mandir ?=	/usr/man
+libdir ?=	/usr/lib
  includedir ?=	/usr/include
  localedir ?=	/usr/share/locale
  docdir ?=       /usr/share/doc/packages/cpupower

tools/power/cpupower/Makefile RANLIB = $(CROSS)ranlib · line 96

Quoted 2 lines
tools/power/cpupower/Makefile +0 -0
@@ -94,15 +95,6 @@ RANLIB = $(CROSS)ranlib
  HOSTCC = gcc
  MKDIR = mkdir

These are set when make invoked from the kernel main Makefile - see "make tools" option in main Makefile

tools/power/cpupower/Makefile RANLIB = $(CROSS)ranlib · line 98

Quoted 3 lines
tools/power/cpupower/Makefile +0 -2
-# 64bit library detection
-include ../../scripts/Makefile.arch

This does the 64-librray detection based on arch.

Quoted 15 lines
tools/power/cpupower/Makefile +0 -8
-
-ifeq ($(IS_64_BIT), 1)
-libdir ?=	/usr/lib64
-else
-libdir ?=	/usr/lib
-endif
-
  # Now we set up the build system
  #
 
 
---

base-commit: f76698bd9a8ca01d3581236082d786e9a6b72bb7
change-id: 20240623-fix-lib-install-3b7dccdbdf45

Quoted 1 line

Best regards,

What happens if you cross-compile with this patch? Take a look at this commit that fixed cross-compile:

a73f6e2fbe8077811ea9546e0d44a7533111f0ba

This makefile has to be in sync with the rest of the tools - see "make tools" in the kernel main Makefile.

thanks,
-- Shuah

#2 lore raw
Quoted 66 lines · Shuah Khan
Quoted 34 lines · Roman Storozhenko

Invocation the tool built with the default settings fails:

$ cpupower
cpupower: error while loading shared libraries: libcpupower.so.1: cannot
open shared object file: No such file or directory> The issue is that Makefile puts the library to "/usr/lib64" dir for a 64
bit machine. This is wrong. According to the "File hierarchy standard
specification:
https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.pdf

"/usr/lib<qual>" dirs are intended for alternative-format libraries (e.g., "/usr/lib32" for 32-bit libraries on a 64-bit machine (optional)).

The utility is built for the current machine and doesn't change bit depth.
Fix the issue by changing library destination dir to "/usr/lib".

---
  tools/power/cpupower/Makefile | 10 +---------
  1 file changed, 1 insertion(+), 9 deletions(-)
tools/power/cpupower/Makefile +1 -0
index cd0225a312b4..6c02f401069e 100644
@@ -67,6 +67,7 @@ LANGUAGES =                         de fr it cs pt ka
  bindir ?=   /usr/bin
  sbindir ?=  /usr/sbin
  mandir ?=   /usr/man
+libdir ?=    /usr/lib
  includedir ?=       /usr/include
  localedir ?=        /usr/share/locale
  docdir ?=       /usr/share/doc/packages/cpupower

tools/power/cpupower/Makefile RANLIB = $(CROSS)ranlib · line 96

Quoted 2 lines
tools/power/cpupower/Makefile +0 -0
@@ -94,15 +95,6 @@ RANLIB = $(CROSS)ranlib
  HOSTCC = gcc
  MKDIR = mkdir

These are set when make invoked from the kernel main Makefile - see "make tools" option in main Makefile

tools/power/cpupower/Makefile RANLIB = $(CROSS)ranlib · line 98

Quoted 3 lines
tools/power/cpupower/Makefile +0 -2
-# 64bit library detection
-include ../../scripts/Makefile.arch

This does the 64-librray detection based on arch.

Quoted 15 lines
tools/power/cpupower/Makefile +0 -8
-
-ifeq ($(IS_64_BIT), 1)
-libdir ?=    /usr/lib64
-else
-libdir ?=    /usr/lib
-endif
-
  # Now we set up the build system
  #
 
 
---

base-commit: f76698bd9a8ca01d3581236082d786e9a6b72bb7
change-id: 20240623-fix-lib-install-3b7dccdbdf45

Quoted 1 line

Best regards,

What happens if you cross-compile with this patch? Take a look at this commit that fixed cross-compile:

Quoted 4 lines

a73f6e2fbe8077811ea9546e0d44a7533111f0ba

This makefile has to be in sync with the rest of the tools - see "make tools" in the kernel main Makefile.

I have done this using "make tools" method mainline kernel and the patch for x86_64 and risc-v:
1) x86_64
$make cpupower

$ sudo make cpupower_install -j8
$ cpupower
cpupower: error while loading shared libraries: libcpupower.so.1:
cannot open shared object file: No such file or directory

Works with my patch, and doesn't work with the mainline.

2) RISC-V:

$ make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- cpupower -j8
$ sudo make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- cpupower_install -j8
$ cpupower
cpupower: error while loading shared libraries: libcpupower.so.1:
cannot open shared object file: No such file or directory

Works with my patch, and doesn't work with the mainline.

By the way - the cpupower makefile handles neither 'CROSS_COMPILE' nor 'ARCH' variables.
So the result is always the same - binary for x86_64 architecture.

Let me try to rephrase what I wrote in the initial patch message:
The current lib target dir is based on architecture bit width, and this is wrong.
The library should be put in the '/usr/lib' dir regardless of whether it is x86_32 or x86_64 .
This is the case for all the distros that comply with the 'File Hierarchy Standard 3.0"
by Linux Foundation. Most of the distros comply with it. You can check this by examining the "/usr/lb64" dir on debian-based distros and find
that it contains only "/usr/lib64/ld-linux-x86-64.so.2" And examine that "/usr/lib" contains both 32 and 64 bit code:

find /usr/lib -name "*.so*" -type f | xargs file | grep 32-bit
find /usr/lib -name "*.so*" -type f | xargs file | grep 64-bit
Quoted 5 lines

thanks,
-- Shuah

Signature · 2 lines
Kind regards,
Roman Storozhenko
maintainer
#3 lore raw
Quoted 81 lines · Roman Storozhenko
Quoted 66 lines · Shuah Khan
Quoted 34 lines · Roman Storozhenko

Invocation the tool built with the default settings fails:

$ cpupower
cpupower: error while loading shared libraries: libcpupower.so.1: cannot
open shared object file: No such file or directory> The issue is that Makefile puts the library to "/usr/lib64" dir for a 64
bit machine. This is wrong. According to the "File hierarchy standard
specification:
https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.pdf

"/usr/lib<qual>" dirs are intended for alternative-format libraries (e.g., "/usr/lib32" for 32-bit libraries on a 64-bit machine (optional)).

The utility is built for the current machine and doesn't change bit depth.
Fix the issue by changing library destination dir to "/usr/lib".

---
   tools/power/cpupower/Makefile | 10 +---------
   1 file changed, 1 insertion(+), 9 deletions(-)
tools/power/cpupower/Makefile +1 -0
index cd0225a312b4..6c02f401069e 100644
@@ -67,6 +67,7 @@ LANGUAGES =                         de fr it cs pt ka
   bindir ?=   /usr/bin
   sbindir ?=  /usr/sbin
   mandir ?=   /usr/man
+libdir ?=    /usr/lib
   includedir ?=       /usr/include
   localedir ?=        /usr/share/locale
   docdir ?=       /usr/share/doc/packages/cpupower

tools/power/cpupower/Makefile RANLIB = $(CROSS)ranlib · line 96

Quoted 2 lines
tools/power/cpupower/Makefile +0 -0
@@ -94,15 +95,6 @@ RANLIB = $(CROSS)ranlib
   HOSTCC = gcc
   MKDIR = mkdir

These are set when make invoked from the kernel main Makefile - see "make tools" option in main Makefile

tools/power/cpupower/Makefile RANLIB = $(CROSS)ranlib · line 98

Quoted 3 lines
tools/power/cpupower/Makefile +0 -2
-# 64bit library detection
-include ../../scripts/Makefile.arch

This does the 64-librray detection based on arch.

Quoted 15 lines
tools/power/cpupower/Makefile +0 -8
-
-ifeq ($(IS_64_BIT), 1)
-libdir ?=    /usr/lib64
-else
-libdir ?=    /usr/lib
-endif
-
   # Now we set up the build system
   #
 
 
---

base-commit: f76698bd9a8ca01d3581236082d786e9a6b72bb7
change-id: 20240623-fix-lib-install-3b7dccdbdf45

Quoted 1 line

Best regards,

What happens if you cross-compile with this patch? Take a look at this commit that fixed cross-compile:

Quoted 4 lines

a73f6e2fbe8077811ea9546e0d44a7533111f0ba

This makefile has to be in sync with the rest of the tools - see "make tools" in the kernel main Makefile.

I have done this using "make tools" method mainline kernel and the patch for x86_64 and risc-v:
1) x86_64
$make cpupower

$ sudo make cpupower_install -j8
$ cpupower
cpupower: error while loading shared libraries: libcpupower.so.1:
cannot open shared object file: No such file or directory
Quoted 9 lines

Works with my patch, and doesn't work with the mainline.

2) RISC-V:

$ make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- cpupower -j8
$ sudo make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- cpupower_install -j8
$ cpupower
cpupower: error while loading shared libraries: libcpupower.so.1:
cannot open shared object file: No such file or directory
Quoted 1 line

Works with my patch, and doesn't work with the mainline.

Please update the change log with the information you provided above and send me v2.

thanks,
-- Shuah