2013-08-30 15:18:50

by Sedat Dilek

[permalink] [raw]
Subject: [PATCH] tools: perf: Fix liblk not built when using perf_install target

After a successful Linux-kernel build I wanted to build only perf
as a linux-tools to do some benchmarking of the spinlock-lockref
changes together with a test-case from Linus.

I followed the advices in "tools/Makefile".

[ tools/Makefile ]
...
@echo 'You can do:'
@echo ' $$ make -C tools/ <tool>_install' <--- NOTE THIS ONE!
@echo ''
@echo ' from the kernel command line to build and install one of'
@echo ' the tools above'
...

So, I tried to build perf the "official" way:

$ make -C tools/ perf_install

Unfortunately, my build breaks like this:
...
make[2]: Entering directory
`~/src/linux-kernel/linux/tools/lib/traceevent'
make[2]: Leaving directory
`~/src/linux-kernel/linux/tools/lib/traceevent'
LINK perf
gcc: error: ~/src/linux-kernel/linux/tools/lib/lk/liblk.a: No such file or directory
make[1]: *** [perf] Error 1
make[1]: Leaving directory `~/src/linux-kernel/linux/tools/perf'
make: *** [perf_install] Error 2

After some discussion on IRC with peterz and acme and a closer look at
the targets in "tools/Makefile", I have noticed that the perf_install
target misses liblk to be built beforehand.
On the contrary the perf_clean target invokes to clean liblk when perf
is cleaned.

[ tools/Makefile ]
...
perf_clean: liblk_clean
$(call descend,$(@:_clean=),clean)
...

Fix this by adding liblk target to perf_install target.

For more details see this thread in [1]:
"[3.11-rc7] Building perf-only the "official" way seems to be BROKEN?"

[1] http://marc.info/?t=137786599400001&r=1&w=2

Cc: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Linus Torvalds <[email protected]>
Signed-off-by: Sedat Dilek <[email protected]>
---
tools/Makefile | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/Makefile b/tools/Makefile
index 41067f3..c15f0e7 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -53,7 +53,10 @@ turbostat x86_energy_perf_policy: FORCE
cpupower_install:
$(call descend,power/$(@:_install=),install)

-cgroup_install firewire_install lguest_install perf_install usb_install virtio_install vm_install net_install:
+cgroup_install firewire_install lguest_install usb_install virtio_install vm_install net_install:
+ $(call descend,$(@:_install=),install)
+
+perf_install: liblk
$(call descend,$(@:_install=),install)

selftests_install:
--
1.8.4


2013-08-30 16:49:14

by Robert Richter

[permalink] [raw]
Subject: Re: [PATCH] tools: perf: Fix liblk not built when using perf_install target

On 30.08.13 17:18:36, Sedat Dilek wrote:
> So, I tried to build perf the "official" way:
>
> $ make -C tools/ perf_install
>
> Unfortunately, my build breaks like this:
> ...
> make[2]: Entering directory
> `~/src/linux-kernel/linux/tools/lib/traceevent'
> make[2]: Leaving directory
> `~/src/linux-kernel/linux/tools/lib/traceevent'
> LINK perf
> gcc: error: ~/src/linux-kernel/linux/tools/lib/lk/liblk.a: No such file or directory
> make[1]: *** [perf] Error 1
> make[1]: Leaving directory `~/src/linux-kernel/linux/tools/perf'
> make: *** [perf_install] Error 2
>
> After some discussion on IRC with peterz and acme and a closer look at
> the targets in "tools/Makefile", I have noticed that the perf_install
> target misses liblk to be built beforehand.

There are no build prerequisites on purpose for install targets.
Install targets are intended to be run with root permissions. We don't
want to create/overwrite files in the build directory as root while
running install rules. Thus, you always need to run:

$ make -C tools/ perf

or similar first.

> On the contrary the perf_clean target invokes to clean liblk when perf
> is cleaned.
>
> [ tools/Makefile ]
> ...
> perf_clean: liblk_clean
> $(call descend,$(@:_clean=),clean)
> ...
>
> Fix this by adding liblk target to perf_install target.

So no, this is not the proper fix.

Before installing you *need* to build. You might want to fix the
documenation...

-Robert

2013-09-03 08:48:41

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH] tools: perf: Fix liblk not built when using perf_install target

Hi,

On Fri, 30 Aug 2013 18:49:05 +0200, Robert Richter wrote:
> On 30.08.13 17:18:36, Sedat Dilek wrote:
>> So, I tried to build perf the "official" way:
>>
>> $ make -C tools/ perf_install
>>
>> Unfortunately, my build breaks like this:
>> ...
>> make[2]: Entering directory
>> `~/src/linux-kernel/linux/tools/lib/traceevent'
>> make[2]: Leaving directory
>> `~/src/linux-kernel/linux/tools/lib/traceevent'
>> LINK perf
>> gcc: error: ~/src/linux-kernel/linux/tools/lib/lk/liblk.a: No such file or directory
>> make[1]: *** [perf] Error 1
>> make[1]: Leaving directory `~/src/linux-kernel/linux/tools/perf'
>> make: *** [perf_install] Error 2
>>
>> After some discussion on IRC with peterz and acme and a closer look at
>> the targets in "tools/Makefile", I have noticed that the perf_install
>> target misses liblk to be built beforehand.
>
> There are no build prerequisites on purpose for install targets.
> Install targets are intended to be run with root permissions. We don't
> want to create/overwrite files in the build directory as root while
> running install rules. Thus, you always need to run:
>
> $ make -C tools/ perf
>
> or similar first.

But AFAIK install target usually depends on build targets on many
projects. And perf too already does the same:

[ tools/perf/Makefile ]
install-bin: all
...

install: install-bin


So if you really concern the permission problem, install target should
not build perf itself, right? But in this case, it tried to build perf
but failed to do it on liblk.

>
>> On the contrary the perf_clean target invokes to clean liblk when perf
>> is cleaned.
>>
>> [ tools/Makefile ]
>> ...
>> perf_clean: liblk_clean
>> $(call descend,$(@:_clean=),clean)
>> ...
>>
>> Fix this by adding liblk target to perf_install target.
>
> So no, this is not the proper fix.
>
> Before installing you *need* to build. You might want to fix the
> documenation...

Hmm.. I don't know. What I'm curious about is why it didn't build liblk
during building perf.

Thanks,
Namhyung

2013-09-03 08:56:29

by Sedat Dilek

[permalink] [raw]
Subject: Re: [PATCH] tools: perf: Fix liblk not built when using perf_install target

On Tue, Sep 3, 2013 at 10:48 AM, Namhyung Kim <[email protected]> wrote:
> Hi,
>
> On Fri, 30 Aug 2013 18:49:05 +0200, Robert Richter wrote:
>> On 30.08.13 17:18:36, Sedat Dilek wrote:
>>> So, I tried to build perf the "official" way:
>>>
>>> $ make -C tools/ perf_install
>>>
>>> Unfortunately, my build breaks like this:
>>> ...
>>> make[2]: Entering directory
>>> `~/src/linux-kernel/linux/tools/lib/traceevent'
>>> make[2]: Leaving directory
>>> `~/src/linux-kernel/linux/tools/lib/traceevent'
>>> LINK perf
>>> gcc: error: ~/src/linux-kernel/linux/tools/lib/lk/liblk.a: No such file or directory
>>> make[1]: *** [perf] Error 1
>>> make[1]: Leaving directory `~/src/linux-kernel/linux/tools/perf'
>>> make: *** [perf_install] Error 2
>>>
>>> After some discussion on IRC with peterz and acme and a closer look at
>>> the targets in "tools/Makefile", I have noticed that the perf_install
>>> target misses liblk to be built beforehand.
>>
>> There are no build prerequisites on purpose for install targets.
>> Install targets are intended to be run with root permissions. We don't
>> want to create/overwrite files in the build directory as root while
>> running install rules. Thus, you always need to run:
>>
>> $ make -C tools/ perf
>>
>> or similar first.
>
> But AFAIK install target usually depends on build targets on many
> projects. And perf too already does the same:
>
> [ tools/perf/Makefile ]
> install-bin: all
> ...
>
> install: install-bin
>
>
> So if you really concern the permission problem, install target should
> not build perf itself, right? But in this case, it tried to build perf
> but failed to do it on liblk.
>
>>
>>> On the contrary the perf_clean target invokes to clean liblk when perf
>>> is cleaned.
>>>
>>> [ tools/Makefile ]
>>> ...
>>> perf_clean: liblk_clean
>>> $(call descend,$(@:_clean=),clean)
>>> ...
>>>
>>> Fix this by adding liblk target to perf_install target.
>>
>> So no, this is not the proper fix.
>>
>> Before installing you *need* to build. You might want to fix the
>> documenation...
>
> Hmm.. I don't know. What I'm curious about is why it didn't build liblk
> during building perf.
>

The day I fell over that perf stuff, I created a pile of patches
fixing that unbeloved tools stuff.
Some tools listed in tools/Makefile are not buildable via...

$ make -C tools/ <tool>
$ make -C tools/ <tool>_install

...because some <tool> have no "install" target.

I attach the patchset here. It has no "proper" changelogs.
The series is "incomplete"... needs some more love... eat it carefully.

Regards,
- Sedat -


Attachments:
0001-tools-Improve-and-correct-help-text.patch (1.07 kB)
0002-tools-lguest-Fix-typo-in-Makefile-target.patch (674.00 B)
0003-tools-vm-Consider-liblk-as-a-prerequisite.patch (1.54 kB)
0004-tools-usb-Use-pthread-instead-of-lpthread.patch (696.00 B)
0005-tools-vm-Add-dummy-install-target-to-fix-make-C-tool.patch (647.00 B)
0006-tools-selftests-Fix-selftests_install-target.patch (1.21 kB)
0007-tools-Introduce-an-all-target-to-build-all-tools.patch (0.99 kB)
0008-tools-Reorder-tool-_install-install-and-clean-target.patch (2.58 kB)
Download all attachments

2013-09-03 09:13:55

by Sedat Dilek

[permalink] [raw]
Subject: Re: [PATCH] tools: perf: Fix liblk not built when using perf_install target

On Tue, Sep 3, 2013 at 10:56 AM, Sedat Dilek <[email protected]> wrote:
> On Tue, Sep 3, 2013 at 10:48 AM, Namhyung Kim <[email protected]> wrote:
>> Hi,
>>
>> On Fri, 30 Aug 2013 18:49:05 +0200, Robert Richter wrote:
>>> On 30.08.13 17:18:36, Sedat Dilek wrote:
>>>> So, I tried to build perf the "official" way:
>>>>
>>>> $ make -C tools/ perf_install
>>>>
>>>> Unfortunately, my build breaks like this:
>>>> ...
>>>> make[2]: Entering directory
>>>> `~/src/linux-kernel/linux/tools/lib/traceevent'
>>>> make[2]: Leaving directory
>>>> `~/src/linux-kernel/linux/tools/lib/traceevent'
>>>> LINK perf
>>>> gcc: error: ~/src/linux-kernel/linux/tools/lib/lk/liblk.a: No such file or directory
>>>> make[1]: *** [perf] Error 1
>>>> make[1]: Leaving directory `~/src/linux-kernel/linux/tools/perf'
>>>> make: *** [perf_install] Error 2
>>>>
>>>> After some discussion on IRC with peterz and acme and a closer look at
>>>> the targets in "tools/Makefile", I have noticed that the perf_install
>>>> target misses liblk to be built beforehand.
>>>
>>> There are no build prerequisites on purpose for install targets.
>>> Install targets are intended to be run with root permissions. We don't
>>> want to create/overwrite files in the build directory as root while
>>> running install rules. Thus, you always need to run:
>>>
>>> $ make -C tools/ perf
>>>
>>> or similar first.
>>
>> But AFAIK install target usually depends on build targets on many
>> projects. And perf too already does the same:
>>
>> [ tools/perf/Makefile ]
>> install-bin: all
>> ...
>>
>> install: install-bin
>>
>>
>> So if you really concern the permission problem, install target should
>> not build perf itself, right? But in this case, it tried to build perf
>> but failed to do it on liblk.
>>
>>>
>>>> On the contrary the perf_clean target invokes to clean liblk when perf
>>>> is cleaned.
>>>>
>>>> [ tools/Makefile ]
>>>> ...
>>>> perf_clean: liblk_clean
>>>> $(call descend,$(@:_clean=),clean)
>>>> ...
>>>>
>>>> Fix this by adding liblk target to perf_install target.
>>>
>>> So no, this is not the proper fix.
>>>
>>> Before installing you *need* to build. You might want to fix the
>>> documenation...
>>
>> Hmm.. I don't know. What I'm curious about is why it didn't build liblk
>> during building perf.
>>
>
> The day I fell over that perf stuff, I created a pile of patches
> fixing that unbeloved tools stuff.
> Some tools listed in tools/Makefile are not buildable via...
>
> $ make -C tools/ <tool>
> $ make -C tools/ <tool>_install
>
> ...because some <tool> have no "install" target.
>
> I attach the patchset here. It has no "proper" changelogs.
> The series is "incomplete"... needs some more love... eat it carefully.
>

Attached 0008 v2.

* move cpupower to tools where sources are below power-dir.
* selftests is always last target

- Sedat -


Attachments:
0008-tools-Reorder-tool-_install-install-and-clean-target.patch (3.52 kB)

2013-09-03 09:20:06

by Sedat Dilek

[permalink] [raw]
Subject: Re: [PATCH] tools: perf: Fix liblk not built when using perf_install target

On Tue, Sep 3, 2013 at 11:13 AM, Sedat Dilek <[email protected]> wrote:
> On Tue, Sep 3, 2013 at 10:56 AM, Sedat Dilek <[email protected]> wrote:
>> On Tue, Sep 3, 2013 at 10:48 AM, Namhyung Kim <[email protected]> wrote:
>>> Hi,
>>>
>>> On Fri, 30 Aug 2013 18:49:05 +0200, Robert Richter wrote:
>>>> On 30.08.13 17:18:36, Sedat Dilek wrote:
>>>>> So, I tried to build perf the "official" way:
>>>>>
>>>>> $ make -C tools/ perf_install
>>>>>
>>>>> Unfortunately, my build breaks like this:
>>>>> ...
>>>>> make[2]: Entering directory
>>>>> `~/src/linux-kernel/linux/tools/lib/traceevent'
>>>>> make[2]: Leaving directory
>>>>> `~/src/linux-kernel/linux/tools/lib/traceevent'
>>>>> LINK perf
>>>>> gcc: error: ~/src/linux-kernel/linux/tools/lib/lk/liblk.a: No such file or directory
>>>>> make[1]: *** [perf] Error 1
>>>>> make[1]: Leaving directory `~/src/linux-kernel/linux/tools/perf'
>>>>> make: *** [perf_install] Error 2
>>>>>
>>>>> After some discussion on IRC with peterz and acme and a closer look at
>>>>> the targets in "tools/Makefile", I have noticed that the perf_install
>>>>> target misses liblk to be built beforehand.
>>>>
>>>> There are no build prerequisites on purpose for install targets.
>>>> Install targets are intended to be run with root permissions. We don't
>>>> want to create/overwrite files in the build directory as root while
>>>> running install rules. Thus, you always need to run:
>>>>
>>>> $ make -C tools/ perf
>>>>
>>>> or similar first.
>>>
>>> But AFAIK install target usually depends on build targets on many
>>> projects. And perf too already does the same:
>>>
>>> [ tools/perf/Makefile ]
>>> install-bin: all
>>> ...
>>>
>>> install: install-bin
>>>
>>>
>>> So if you really concern the permission problem, install target should
>>> not build perf itself, right? But in this case, it tried to build perf
>>> but failed to do it on liblk.
>>>
>>>>
>>>>> On the contrary the perf_clean target invokes to clean liblk when perf
>>>>> is cleaned.
>>>>>
>>>>> [ tools/Makefile ]
>>>>> ...
>>>>> perf_clean: liblk_clean
>>>>> $(call descend,$(@:_clean=),clean)
>>>>> ...
>>>>>
>>>>> Fix this by adding liblk target to perf_install target.
>>>>
>>>> So no, this is not the proper fix.
>>>>
>>>> Before installing you *need* to build. You might want to fix the
>>>> documenation...
>>>
>>> Hmm.. I don't know. What I'm curious about is why it didn't build liblk
>>> during building perf.
>>>
>>
>> The day I fell over that perf stuff, I created a pile of patches
>> fixing that unbeloved tools stuff.
>> Some tools listed in tools/Makefile are not buildable via...
>>
>> $ make -C tools/ <tool>
>> $ make -C tools/ <tool>_install
>>
>> ...because some <tool> have no "install" target.
>>
>> I attach the patchset here. It has no "proper" changelogs.
>> The series is "incomplete"... needs some more love... eat it carefully.
>>
>
> Attached 0008 v2.
>
> * move cpupower to tools where sources are below power-dir.
> * selftests is always last target
>

Grrr, space/tabs :-(.

0008 v3 attached.

- Sedat -


Attachments:
0008-tools-Reorder-tool-_install-install-and-clean-target.patch (3.49 kB)