bug-make
[Top][All Lists]
Advanced

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

Re: sub makefile does not use correct value of CFLAGS from top make file


From: Martin Dorey
Subject: Re: sub makefile does not use correct value of CFLAGS from top make file,
Date: Fri, 3 Sep 2021 22:18:28 +0000

# Also note the top make file removes the default rule for %.o:%.[Sc], but

# the default rules are still being used.


I fear you think that .EXPORT_ALL_VARIABLES should have exported your custom rule to the sub-make.  It won't.  I didn't notice any difference in say 4.1 but I dug out a similarly prehistoric version of make, 3.81, and its default rule for compiling .S files doesn't mention CFLAGS:

COMPILE.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c
...
%.o: %.S
#  commands to execute (built-in):
        $(COMPILE.S) -o $@ $<

In make_top, there's an extra S on the name of the third variable used here:

echo "Assembling: $< : lib CFLAGS=$(CFLAGGS)" \

I doubt that line continuation backslash is going to have the desired effect, if it were ever used, given the @ at the start of the next line and the lack of a semicolon after the echo.


From: Bug-make <bug-make-bounces+martin.dorey=hds.com@gnu.org> on behalf of Jeffrey.Fellin--- via Bug reports and discussion for GNU make <bug-make@gnu.org>
Sent: Friday, September 3, 2021 13:34
To: bug-make@gnu.org <bug-make@gnu.org>
Subject: sub makefile does not use correct value of CFLAGS from top make file,
 
***** EXTERNAL EMAIL *****

I have a project that compiles .S and .c files, and the value of CFLAGS in the sub makefile is not the same for the compile lines

 

The version of make is

GNU Make 3.82

Built for x86_64-redhat-linux-gnu

Copyright (C) 2010  Free Software Foundation, Inc.

 

I’m attaching a tarball containing the following files, for ease in reproducing the problem

cflags_bug/make_top

cflags_bug/base/sub_make

cflags_bug/base/src/bug.S

cflags_bug/base/src/hello.c

 

The compile of bug.S succeeds, but doesn’t have the correct value of CFLAGS, as in the annotated output below. The compile of hello.c has the correct value of CFLAGS, but the compile fails due to the unsupported options to the cc. The extra options are for use by the project specific compiler.

 

The top make undefines the default rules for %.o:%.c and %.o:%.S, has my understanding from these documents:

Managing Projects with BNU Make, Third Edition,

GNU Make pdf, Section 10.5.5 Match-Anything Pattern Rules

 

The annotated execution of make -f make_top, supplied in the cflags_bug.tar

$ make -ikf make_top;exit

(cd base && make -f sub_make all)

make[1]: Entering directory `/home/jfellin/cflags_bug/base'

# This displays the value of CFLAGS that should be use in the

# compilation of the .S and .c files

# the compile errors are not important, but the different

# value of CFLAGS, which are expected to be the same.

 

# Also note the top make file removes the default rule for %.o:%.[Sc], but

# the default rules are still being used.

 

# Expected value in compile *.S and *.c

check CFLAGS=-DTOP_MAKE -Wall -I base/inc -mlittle-endian --target=aarch64-arm-none-eabi -mcpu=cortex-a53+nocrypto+nofp+nosimd -mno-unaligned-access -mfpu=None    -O  -MD -I /home/jfellin/cflags_bug/base/../base/inc  -D BASE_MAKE

 

 

# Note this value of CFLAGS is not the one printed above

cc    -c -o /home/jfellin/cflags_bug/base/../base/src/bug.o /home/jfellin/cflags_bug/base/../base/src/bug.S

 

 

# Note this value of CFLAGS is the one printed by the check_cflag rule

# in the file, sub_make,

cc -DTOP_MAKE -Wall -I base/inc -mlittle-endian --target=aarch64-arm-none-eabi -mcpu=cortex-a53+nocrypto+nofp+nosimd -mno-unaligned-access -mfpu=None    -O  -MD -I /home/jfellin/cflags_bug/base/../base/inc  -D BASE_MAKE  -mlittle-endian --target=aarch64-arm-none-eabi -mcpu=cortex-a53+nocrypto+nofp+nosimd -mno-unaligned-access -mfpu=None -c -o /home/jfellin/cflags_bug/base/../base/src/hello.o /home/jfellin/cflags_bug/base/../base/src/hello.c

cc: warning: \u2018-mcpu=\u2019 is deprecated; use \u2018-mtune=\u2019 or \u2018-march=\u2019 instead

cc: warning: \u2018-mcpu=\u2019 is deprecated; use \u2018-mtune=\u2019 or \u2018-march=\u2019 instead

cc: error: unrecognized command line option \u2018-mlittle-endian\u2019

cc: error: unrecognized command line option \u2018-mno-unaligned-access\u2019

cc: error: unrecognized command line option \u2018-mfpu=None\u2019

cc: error: unrecognized command line option \u2018-mlittle-endian\u2019

cc: error: unrecognized command line option \u2018-mno-unaligned-access\u2019

cc: error: unrecognized command line option \u2018-mfpu=None\u2019

make[1]: [/home/jfellin/cflags_bug/base/../base/src/hello.o] Error 1 (ignored)

make[1]: Leaving directory `/home/jfellin/cflags_bug/base'

 

Jeff

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]