Re: Module build problems with gmake 3.x

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Sep 11, 2021 at 7:45 AM Markus Mayer <mmayer@xxxxxxxxxxxx> wrote:
>
> On Thu, 9 Sept 2021 at 05:20, Masahiro Yamada <masahiroy@xxxxxxxxxx> wrote:
> >
> > I sometimes test GNU make 3.81 for kernel builds, but I have not tested
> > the -e option.
> >
> > Now I tested the -e option, and it worked for me.
> > Both $(M) and $(KBUILD_EXTMOD) were correctly set.
> >
> > So, I did not observe anything you claim.
>
> Thanks for trying it out. See below for a summary of my test comparing
> GNUmake 3.81 and 4.1. All the tests have been performed on Ubuntu
> 14.04. (Yes, I know that's old.)
>
> > I ran this Makefile with GNU Make 3.81
> >
> > masahiro@oscar:~/workspace/hello$ cat Makefile
> > obj-m += hello.o
> >
> > KERNEL_DIR := $(HOME)/ref/linux
> >
> > all:
> >         ${MAKE} -C $(KERNEL_DIR) -e M=$(PWD) modules
> >
> > clean:
> >         make -C $(KERNEL_DIR) M=$(PWD) clean
> > masahiro@oscar:~/workspace/hello$ make-3.81 --version
> > GNU Make 3.81
> > Copyright (C) 2006  Free Software Foundation, Inc.
> > This is free software; see the source for copying conditions.
> > There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
> > PARTICULAR PURPOSE.
> >
> > This program built for x86_64-unknown-linux-gnu
> > masahiro@oscar:~/workspace/hello$ make-3.81
> > make-3.81 -C /home/masahiro/ref/linux -e
> > M=/home/masahiro/workspace/hello modules
> > make-3.81[1]: Entering directory `/home/masahiro/ref/linux'
> > make-3.81[2]: Entering directory `/home/masahiro/ref/linux'
> >   CC [M]  /home/masahiro/workspace/hello/hello.o
> >   MODPOST /home/masahiro/workspace/hello/Module.symvers
> >   CC [M]  /home/masahiro/workspace/hello/hello.mod.o
> >   LD [M]  /home/masahiro/workspace/hello/hello.ko
> > make-3.81[2]: Leaving directory `/home/masahiro/ref/linux'
> > make-3.81[1]: Leaving directory `/home/masahiro/ref/linux'
> > masahiro@oscar:~/workspace/hello$ ls hello*
> > hello.c  hello.ko  hello.mod  hello.mod.c  hello.mod.o  hello.o
> >
> > hello.ko was successfully built.
> >
> > Entering/Leaving directory is eye-sores,
> > but presumably it is because MAKEFLAGS is overridden
> > by the environment since you gave -e.
>
> Here is what I have.
>
> $ cat Makefile
>
> export KERNEL_DIR = /local/users/mmayer/linux-5.4


>From this line, I understand how to reproduce the case.

The key is 'linux-5.4'

In your initial email, you mentioned that this happened on

  * newish kernel  (>=5.1)


So, I used the latest kernel for testing,
but this does not happen after
bcf637f54f6d2515d4c9c81808faf01848916152
because the M= parameter is parsed before the sub-make.


By running your test code on linux 5.4, yes,
I can observe the same symptom.




The root case seams, GNU Make changes
the origin of variables to 'environment'.
I do not know if it is an intended behavior.
(maybe, better to ask the GNU Make maintainer)



I narrowed it down to the following test code.
To me, the behavior is weird.



masahiro@oscar:~/workspace/foo$ cat Makefile
$(warning the origin of FOO is: $(origin FOO))

all:
        $(MAKE) -e -f Makefile.sub1 FOO=1
masahiro@oscar:~/workspace/foo$ cat Makefile.sub1
$(warning the origin of FOO is: $(origin FOO))

all:
        $(MAKE) -f Makefile.sub2
masahiro@oscar:~/workspace/foo$ cat Makefile.sub2
$(warning the origin of FOO is: $(origin FOO))

all:
        @:
masahiro@oscar:~/workspace/foo$ make
Makefile:1: the origin of FOO is: undefined
make -e -f Makefile.sub1 FOO=1
make[1]: Entering directory '/home/masahiro/workspace/foo'
Makefile.sub1:1: the origin of FOO is: command line
make -f Makefile.sub2
make[2]: Entering directory '/home/masahiro/workspace/foo'
Makefile.sub2:1: the origin of FOO is: environment
make[2]: Leaving directory '/home/masahiro/workspace/foo'
make[1]: Leaving directory '/home/masahiro/workspace/foo'






So, this is what your can tell:

- The behavior of the -e option seems to have a weird
    side-effect.
    Later, I will ask this to the GNU Make maintainer
    to see whether it is a bug or not.

- I do not want to support the -e option.  I do not think
  it is a commonly-used option because you are the
  first person who asked this since Linux 5.4.
  (notice Linux 5.4 is almost two years old)

 - If you use the latest kernel
    (after bcf637f54f6d251), you will be able to build
    external modules with the -e option.
    But, I recommend you to not use -e.

 - If you still insist on the -e option on Linux 5.4,
    you can cherry-pick bcf637f54f6d251
    (but it is out of scope of the support of the community)




>
> > I do not understand your motivation for using -e, though.
>
> I am not entirely clear on that either, but I have been told it is
> needed in that particular build environment.


Maybe, better to consider removing the -e option.






-- 
Best Regards
Masahiro Yamada



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux