diff mbox series

drm/radeon: Add build directory to include path

Message ID 20220413161450.1854370-1-michel@daenzer.net (mailing list archive)
State New, archived
Headers show
Series drm/radeon: Add build directory to include path | expand

Commit Message

Michel Dänzer April 13, 2022, 4:14 p.m. UTC
From: Michel Dänzer <mdaenzer@redhat.com>

Fixes compile errors with out-of-tree builds, e.g.

../drivers/gpu/drm/radeon/r420.c:38:10: fatal error: r420_reg_safe.h: No such file or directory
   38 | #include "r420_reg_safe.h"
      |          ^~~~~~~~~~~~~~~~~

Signed-off-by: Michel Dänzer <mdaenzer@redhat.com>
---
 drivers/gpu/drm/radeon/Makefile | 2 ++
 1 file changed, 2 insertions(+)

Comments

Christian König April 14, 2022, 6:24 a.m. UTC | #1
Am 13.04.22 um 18:14 schrieb Michel Dänzer:
> From: Michel Dänzer <mdaenzer@redhat.com>
>
> Fixes compile errors with out-of-tree builds, e.g.
>
> ../drivers/gpu/drm/radeon/r420.c:38:10: fatal error: r420_reg_safe.h: No such file or directory
>     38 | #include "r420_reg_safe.h"
>        |          ^~~~~~~~~~~~~~~~~


Well stuff like that usually points to a broken build environment.

Christian.

>
> Signed-off-by: Michel Dänzer <mdaenzer@redhat.com>
> ---
>   drivers/gpu/drm/radeon/Makefile | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/radeon/Makefile b/drivers/gpu/drm/radeon/Makefile
> index 11c97edde54d..37caf5236048 100644
> --- a/drivers/gpu/drm/radeon/Makefile
> +++ b/drivers/gpu/drm/radeon/Makefile
> @@ -3,6 +3,8 @@
>   # Makefile for the drm device driver.  This driver provides support for the
>   # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
>   
> +ccflags-y += -I$(src)
> +
>   hostprogs := mkregtable
>   targets := rn50_reg_safe.h r100_reg_safe.h r200_reg_safe.h rv515_reg_safe.h r300_reg_safe.h r420_reg_safe.h rs600_reg_safe.h r600_reg_safe.h evergreen_reg_safe.h cayman_reg_safe.h
>
Michel Dänzer April 14, 2022, 7:37 a.m. UTC | #2
On 2022-04-14 08:24, Christian König wrote:
> Am 13.04.22 um 18:14 schrieb Michel Dänzer:
>> From: Michel Dänzer <mdaenzer@redhat.com>
>>
>> Fixes compile errors with out-of-tree builds, e.g.
>>
>> ../drivers/gpu/drm/radeon/r420.c:38:10: fatal error: r420_reg_safe.h: No such file or directory
>>     38 | #include "r420_reg_safe.h"
>>        |          ^~~~~~~~~~~~~~~~~
> 
> 
> Well stuff like that usually points to a broken build environment.

Just a separate build directory. Specifically, I'm hitting the errors with

 make -C build-amd64 M=drivers/gpu/drm

Generated headers such as r420_reg_safe.h reside in the build directory, so source files in the source directory can't find them without an explicit search path. Are you saying that should get added automagically somehow?

FWIW, this is pretty common in the kernel according to git grep.
Christian König April 14, 2022, 8:44 a.m. UTC | #3
Am 14.04.22 um 09:37 schrieb Michel Dänzer:
> On 2022-04-14 08:24, Christian König wrote:
>> Am 13.04.22 um 18:14 schrieb Michel Dänzer:
>>> From: Michel Dänzer <mdaenzer@redhat.com>
>>>
>>> Fixes compile errors with out-of-tree builds, e.g.
>>>
>>> ../drivers/gpu/drm/radeon/r420.c:38:10: fatal error: r420_reg_safe.h: No such file or directory
>>>      38 | #include "r420_reg_safe.h"
>>>         |          ^~~~~~~~~~~~~~~~~
>>
>> Well stuff like that usually points to a broken build environment.
> Just a separate build directory. Specifically, I'm hitting the errors with
>
>   make -C build-amd64 M=drivers/gpu/drm
>
> Generated headers such as r420_reg_safe.h reside in the build directory, so source files in the source directory can't find them without an explicit search path.

I'm trying to swap back into my brain how all of this used to work, but 
that's a really long time ago that I tried this as well.

> Are you saying that should get added automagically somehow?

Yes, exactly that. I'm like 95% sure that used to work, but I don't know 
why exactly either.

> FWIW, this is pretty common in the kernel according to git grep.

Maybe Alex or somebody else with some more background in the kernel 
Makefiles could jump in and help here.

Christian.
Michel Dänzer April 14, 2022, 8:56 a.m. UTC | #4
On 2022-04-14 10:44, Christian König wrote:
> Am 14.04.22 um 09:37 schrieb Michel Dänzer:
>> On 2022-04-14 08:24, Christian König wrote:
>>> Am 13.04.22 um 18:14 schrieb Michel Dänzer:
>>>> From: Michel Dänzer <mdaenzer@redhat.com>
>>>>
>>>> Fixes compile errors with out-of-tree builds, e.g.
>>>>
>>>> ../drivers/gpu/drm/radeon/r420.c:38:10: fatal error: r420_reg_safe.h: No such file or directory
>>>>      38 | #include "r420_reg_safe.h"
>>>>         |          ^~~~~~~~~~~~~~~~~
>>>
>>> Well stuff like that usually points to a broken build environment.
>> Just a separate build directory. Specifically, I'm hitting the errors with
>>
>>   make -C build-amd64 M=drivers/gpu/drm
>>
>> Generated headers such as r420_reg_safe.h reside in the build directory, so source files in the source directory can't find them without an explicit search path.
> 
> I'm trying to swap back into my brain how all of this used to work, but that's a really long time ago that I tried this as well.
> 
>> Are you saying that should get added automagically somehow?
> 
> Yes, exactly that. I'm like 95% sure that used to work, but I don't know why exactly either.

Maybe it worked at some point, but regressed in the meantime? I only just switched to a separate build directory (so that I can easily build-test for other architectures).
Alex Deucher April 14, 2022, 1:34 p.m. UTC | #5
On Thu, Apr 14, 2022 at 4:44 AM Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
>
> Am 14.04.22 um 09:37 schrieb Michel Dänzer:
> > On 2022-04-14 08:24, Christian König wrote:
> >> Am 13.04.22 um 18:14 schrieb Michel Dänzer:
> >>> From: Michel Dänzer <mdaenzer@redhat.com>
> >>>
> >>> Fixes compile errors with out-of-tree builds, e.g.
> >>>
> >>> ../drivers/gpu/drm/radeon/r420.c:38:10: fatal error: r420_reg_safe.h: No such file or directory
> >>>      38 | #include "r420_reg_safe.h"
> >>>         |          ^~~~~~~~~~~~~~~~~
> >>
> >> Well stuff like that usually points to a broken build environment.
> > Just a separate build directory. Specifically, I'm hitting the errors with
> >
> >   make -C build-amd64 M=drivers/gpu/drm
> >
> > Generated headers such as r420_reg_safe.h reside in the build directory, so source files in the source directory can't find them without an explicit search path.
>
> I'm trying to swap back into my brain how all of this used to work, but
> that's a really long time ago that I tried this as well.
>
> > Are you saying that should get added automagically somehow?
>
> Yes, exactly that. I'm like 95% sure that used to work, but I don't know
> why exactly either.
>
> > FWIW, this is pretty common in the kernel according to git grep.
>
> Maybe Alex or somebody else with some more background in the kernel
> Makefiles could jump in and help here.

I don't remember either.  I vaguely recall the build support for the
mkregtable stuff being reworked a while ago.  A quick zip through the
git logs shows a series from Masahiro Yamada from 2020.

Alex
Michel Dänzer April 14, 2022, 1:49 p.m. UTC | #6
On 2022-04-14 15:34, Alex Deucher wrote:
> On Thu, Apr 14, 2022 at 4:44 AM Christian König
> <ckoenig.leichtzumerken@gmail.com> wrote:
>> Am 14.04.22 um 09:37 schrieb Michel Dänzer:
>>> On 2022-04-14 08:24, Christian König wrote:
>>>> Am 13.04.22 um 18:14 schrieb Michel Dänzer:
>>>>> From: Michel Dänzer <mdaenzer@redhat.com>
>>>>>
>>>>> Fixes compile errors with out-of-tree builds, e.g.
>>>>>
>>>>> ../drivers/gpu/drm/radeon/r420.c:38:10: fatal error: r420_reg_safe.h: No such file or directory
>>>>>      38 | #include "r420_reg_safe.h"
>>>>>         |          ^~~~~~~~~~~~~~~~~
>>>>
>>>> Well stuff like that usually points to a broken build environment.
>>> Just a separate build directory. Specifically, I'm hitting the errors with
>>>
>>>   make -C build-amd64 M=drivers/gpu/drm
>>>
>>> Generated headers such as r420_reg_safe.h reside in the build directory, so source files in the source directory can't find them without an explicit search path.
>>
>> I'm trying to swap back into my brain how all of this used to work, but
>> that's a really long time ago that I tried this as well.
>>
>>> Are you saying that should get added automagically somehow?
>>
>> Yes, exactly that. I'm like 95% sure that used to work, but I don't know
>> why exactly either.
>>
>>> FWIW, this is pretty common in the kernel according to git grep.
>>
>> Maybe Alex or somebody else with some more background in the kernel
>> Makefiles could jump in and help here.
> 
> I don't remember either.  I vaguely recall the build support for the
> mkregtable stuff being reworked a while ago.  A quick zip through the
> git logs shows a series from Masahiro Yamada from 2020.

Yamada-san, can you help us? :)

See https://patchwork.freedesktop.org/patch/482011/ for my patch.
Masahiro Yamada April 14, 2022, 3:04 p.m. UTC | #7
Hi.

On Thu, Apr 14, 2022 at 10:50 PM Michel Dänzer
<michel.daenzer@mailbox.org> wrote:
>
> On 2022-04-14 15:34, Alex Deucher wrote:
> > On Thu, Apr 14, 2022 at 4:44 AM Christian König
> > <ckoenig.leichtzumerken@gmail.com> wrote:
> >> Am 14.04.22 um 09:37 schrieb Michel Dänzer:
> >>> On 2022-04-14 08:24, Christian König wrote:
> >>>> Am 13.04.22 um 18:14 schrieb Michel Dänzer:
> >>>>> From: Michel Dänzer <mdaenzer@redhat.com>
> >>>>>
> >>>>> Fixes compile errors with out-of-tree builds, e.g.
> >>>>>
> >>>>> ../drivers/gpu/drm/radeon/r420.c:38:10: fatal error: r420_reg_safe.h: No such file or directory
> >>>>>      38 | #include "r420_reg_safe.h"
> >>>>>         |          ^~~~~~~~~~~~~~~~~
> >>>>
> >>>> Well stuff like that usually points to a broken build environment.
> >>> Just a separate build directory. Specifically, I'm hitting the errors with
> >>>
> >>>   make -C build-amd64 M=drivers/gpu/drm


Maybe

        make  O=build-arm64   drivers/gpu/drm/

is the way you were searching for.

It builds only drivers/gpu/drm/
in the separate directory.




> >>>
> >>> Generated headers such as r420_reg_safe.h reside in the build directory, so source files in the source directory can't find them without an explicit search path.
> >>
> >> I'm trying to swap back into my brain how all of this used to work, but
> >> that's a really long time ago that I tried this as well.
> >>
> >>> Are you saying that should get added automagically somehow?


For the kernel tree, yes, it is done automatically.

See the code in scripts/Makefile.lib:

# $(srctree)/$(src) for including checkin headers from generated source files
# $(objtree)/$(obj) for including generated headers from checkin source files
ifeq ($(KBUILD_EXTMOD),)
ifdef building_out_of_srctree
_c_flags   += -I $(srctree)/$(src) -I $(objtree)/$(obj)
_a_flags   += -I $(srctree)/$(src) -I $(objtree)/$(obj)
_cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
endif
endif




But, you used M=drivers/gpu/drm.
So, it did not work.



M= is intended for building external modules.

I do not recommend it for in-tree drivers.






> >>
> >> Yes, exactly that. I'm like 95% sure that used to work, but I don't know
> >> why exactly either.
> >>
> >>> FWIW, this is pretty common in the kernel according to git grep.
> >>
> >> Maybe Alex or somebody else with some more background in the kernel
> >> Makefiles could jump in and help here.
> >
> > I don't remember either.  I vaguely recall the build support for the
> > mkregtable stuff being reworked a while ago.  A quick zip through the
> > git logs shows a series from Masahiro Yamada from 2020.
>
> Yamada-san, can you help us? :)
>
> See https://patchwork.freedesktop.org/patch/482011/ for my patch.
>
>
> --
> Earthling Michel Dänzer            |                  https://redhat.com
> Libre software enthusiast          |         Mesa and Xwayland developer



--
Best Regards
Masahiro Yamada
Michel Dänzer April 14, 2022, 4:57 p.m. UTC | #8
On 2022-04-14 17:04, Masahiro Yamada wrote:
> On Thu, Apr 14, 2022 at 10:50 PM Michel Dänzer
> <michel.daenzer@mailbox.org> wrote:
>> On 2022-04-14 15:34, Alex Deucher wrote:
>>> On Thu, Apr 14, 2022 at 4:44 AM Christian König
>>> <ckoenig.leichtzumerken@gmail.com> wrote:
>>>> Am 14.04.22 um 09:37 schrieb Michel Dänzer:
>>>>> On 2022-04-14 08:24, Christian König wrote:
>>>>>> Am 13.04.22 um 18:14 schrieb Michel Dänzer:
>>>>>>> From: Michel Dänzer <mdaenzer@redhat.com>
>>>>>>>
>>>>>>> Fixes compile errors with out-of-tree builds, e.g.
>>>>>>>
>>>>>>> ../drivers/gpu/drm/radeon/r420.c:38:10: fatal error: r420_reg_safe.h: No such file or directory
>>>>>>>      38 | #include "r420_reg_safe.h"
>>>>>>>         |          ^~~~~~~~~~~~~~~~~
>>>>>>
>>>>>> Well stuff like that usually points to a broken build environment.
>>>>> Just a separate build directory. Specifically, I'm hitting the errors with
>>>>>
>>>>>   make -C build-amd64 M=drivers/gpu/drm
> 
> 
> Maybe
> 
>         make  O=build-arm64   drivers/gpu/drm/
> 
> is the way you were searching for.
> 
> It builds only drivers/gpu/drm/
> in the separate directory.

Indeed, that works.


>>>>> Generated headers such as r420_reg_safe.h reside in the build directory, so source files in the source directory can't find them without an explicit search path.
>>>>
>>>> I'm trying to swap back into my brain how all of this used to work, but
>>>> that's a really long time ago that I tried this as well.
>>>>
>>>>> Are you saying that should get added automagically somehow?
> 
> 
> For the kernel tree, yes, it is done automatically.
> 
> See the code in scripts/Makefile.lib:
> 
> # $(srctree)/$(src) for including checkin headers from generated source files
> # $(objtree)/$(obj) for including generated headers from checkin source files
> ifeq ($(KBUILD_EXTMOD),)
> ifdef building_out_of_srctree
> _c_flags   += -I $(srctree)/$(src) -I $(objtree)/$(obj)
> _a_flags   += -I $(srctree)/$(src) -I $(objtree)/$(obj)
> _cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
> endif
> endif
> 
> 
> 
> 
> But, you used M=drivers/gpu/drm.
> So, it did not work.
> 
> 
> 
> M= is intended for building external modules.
> 
> I do not recommend it for in-tree drivers.

So I've been doing it wrong for all these years... Happened to always work for in-tree builds.

Thank you so much for your help, Yamada-san!

I am retracting this patch.
Michel Dänzer June 15, 2022, 8:35 a.m. UTC | #9
On 2022-04-14 18:57, Michel Dänzer wrote:
> On 2022-04-14 17:04, Masahiro Yamada wrote:
>> On Thu, Apr 14, 2022 at 10:50 PM Michel Dänzer
>> <michel.daenzer@mailbox.org> wrote:
>>> On 2022-04-14 15:34, Alex Deucher wrote:
>>>> On Thu, Apr 14, 2022 at 4:44 AM Christian König
>>>> <ckoenig.leichtzumerken@gmail.com> wrote:
>>>>> Am 14.04.22 um 09:37 schrieb Michel Dänzer:
>>>>>>
>>>>>>   make -C build-amd64 M=drivers/gpu/drm
>>
>>
>> Maybe
>>
>>         make  O=build-arm64   drivers/gpu/drm/
>>
>> is the way you were searching for.
>>
>> It builds only drivers/gpu/drm/
>> in the separate directory.
> 
> Indeed, that works.

I've come to realize that this doesn't produce the actual *.ko modules though. Is there a trick for building the modules, but only under drivers/gpu/drm/ ?
Masahiro Yamada June 18, 2022, 10:08 p.m. UTC | #10
On Wed, Jun 15, 2022 at 5:35 PM Michel Dänzer
<michel.daenzer@mailbox.org> wrote:
>
> On 2022-04-14 18:57, Michel Dänzer wrote:
> > On 2022-04-14 17:04, Masahiro Yamada wrote:
> >> On Thu, Apr 14, 2022 at 10:50 PM Michel Dänzer
> >> <michel.daenzer@mailbox.org> wrote:
> >>> On 2022-04-14 15:34, Alex Deucher wrote:
> >>>> On Thu, Apr 14, 2022 at 4:44 AM Christian König
> >>>> <ckoenig.leichtzumerken@gmail.com> wrote:
> >>>>> Am 14.04.22 um 09:37 schrieb Michel Dänzer:
> >>>>>>
> >>>>>>   make -C build-amd64 M=drivers/gpu/drm
> >>
> >>
> >> Maybe
> >>
> >>         make  O=build-arm64   drivers/gpu/drm/
> >>
> >> is the way you were searching for.
> >>
> >> It builds only drivers/gpu/drm/
> >> in the separate directory.
> >
> > Indeed, that works.
>
> I've come to realize that this doesn't produce the actual *.ko modules though. Is there a trick for building the modules, but only under drivers/gpu/drm/ ?
>
>
> --
> Earthling Michel Dänzer            |                  https://redhat.com
> Libre software enthusiast          |         Mesa and Xwayland developer


No.
There is no way to build *.ko
only under a specific directory.
Ernst Sjöstrand June 19, 2022, 4:22 p.m. UTC | #11
Den sön 19 juni 2022 kl 00:20 skrev Masahiro Yamada <masahiroy@kernel.org>:

> On Wed, Jun 15, 2022 at 5:35 PM Michel Dänzer
> <michel.daenzer@mailbox.org> wrote:
> >
> > On 2022-04-14 18:57, Michel Dänzer wrote:
> > > On 2022-04-14 17:04, Masahiro Yamada wrote:
> > >> On Thu, Apr 14, 2022 at 10:50 PM Michel Dänzer
> > >> <michel.daenzer@mailbox.org> wrote:
> > >>> On 2022-04-14 15:34, Alex Deucher wrote:
> > >>>> On Thu, Apr 14, 2022 at 4:44 AM Christian König
> > >>>> <ckoenig.leichtzumerken@gmail.com> wrote:
> > >>>>> Am 14.04.22 um 09:37 schrieb Michel Dänzer:
> > >>>>>>
> > >>>>>>   make -C build-amd64 M=drivers/gpu/drm
> > >>
> > >>
> > >> Maybe
> > >>
> > >>         make  O=build-arm64   drivers/gpu/drm/
> > >>
> > >> is the way you were searching for.
> > >>
> > >> It builds only drivers/gpu/drm/
> > >> in the separate directory.
> > >
> > > Indeed, that works.
> >
> > I've come to realize that this doesn't produce the actual *.ko modules
> though. Is there a trick for building the modules, but only under
> drivers/gpu/drm/ ?
> >
> >
> > --
> > Earthling Michel Dänzer            |                  https://redhat.com
> > Libre software enthusiast          |         Mesa and Xwayland developer
>
>
> No.
> There is no way to build *.ko
> only under a specific directory.
>

Doesn't "make modules M=drivers/gpu/drm/" do that?
Michel Dänzer June 20, 2022, 7:42 a.m. UTC | #12
On 2022-06-19 18:22, Ernst Sjöstrand wrote:
> Den sön 19 juni 2022 kl 00:20 skrev Masahiro Yamada <masahiroy@kernel.org <mailto:masahiroy@kernel.org>>:
> 
>     On Wed, Jun 15, 2022 at 5:35 PM Michel Dänzer
>     <michel.daenzer@mailbox.org <mailto:michel.daenzer@mailbox.org>> wrote:
>     >
>     > On 2022-04-14 18:57, Michel Dänzer wrote:
>     > > On 2022-04-14 17:04, Masahiro Yamada wrote:
>     > >> On Thu, Apr 14, 2022 at 10:50 PM Michel Dänzer
>     > >> <michel.daenzer@mailbox.org <mailto:michel.daenzer@mailbox.org>> wrote:
>     > >>> On 2022-04-14 15:34, Alex Deucher wrote:
>     > >>>> On Thu, Apr 14, 2022 at 4:44 AM Christian König
>     > >>>> <ckoenig.leichtzumerken@gmail.com <mailto:ckoenig.leichtzumerken@gmail.com>> wrote:
>     > >>>>> Am 14.04.22 um 09:37 schrieb Michel Dänzer:
>     > >>>>>>
>     > >>>>>>   make -C build-amd64 M=drivers/gpu/drm
>     > >>
>     > >>
>     > >> Maybe
>     > >>
>     > >>         make  O=build-arm64   drivers/gpu/drm/
>     > >>
>     > >> is the way you were searching for.
>     > >>
>     > >> It builds only drivers/gpu/drm/
>     > >> in the separate directory.
>     > >
>     > > Indeed, that works.
>     >
>     > I've come to realize that this doesn't produce the actual *.ko modules though. Is there a trick for building the modules, but only under drivers/gpu/drm/ ?
>     >
>     >
>     > --
>     > Earthling Michel Dänzer            |                  https://redhat.com <https://redhat.com>
>     > Libre software enthusiast          |         Mesa and Xwayland developer
> 
> 
>     No.
>     There is no way to build *.ko
>     only under a specific directory.
> 
> 
> Doesn't "make modules M=drivers/gpu/drm/" do that?

That again hits the compile error the patch was supposed to address. Apparently M= isn't for this but for building out-of-tree modules.
diff mbox series

Patch

diff --git a/drivers/gpu/drm/radeon/Makefile b/drivers/gpu/drm/radeon/Makefile
index 11c97edde54d..37caf5236048 100644
--- a/drivers/gpu/drm/radeon/Makefile
+++ b/drivers/gpu/drm/radeon/Makefile
@@ -3,6 +3,8 @@ 
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
 
+ccflags-y += -I$(src)
+
 hostprogs := mkregtable
 targets := rn50_reg_safe.h r100_reg_safe.h r200_reg_safe.h rv515_reg_safe.h r300_reg_safe.h r420_reg_safe.h rs600_reg_safe.h r600_reg_safe.h evergreen_reg_safe.h cayman_reg_safe.h