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: Philip Guenther
Subject: Re: sub makefile does not use correct value of CFLAGS from top make file,
Date: Fri, 3 Sep 2021 13:16:54 -0900

Unlike variable assignments, rules--including overrides of built-in pattern rules--are not inherited by recursively invoked instances of make.  They have to be in a makefile read by the instance of make that needs them.

(GNU makes built-in rules and variables have TARGET_ARCH for basically all types of compilation.  IMHO, if you have options that don't apply to, for example, .S files, then why not put them in CFLAGS *directly* and not in TARGET_ARCH?  Or just use your own variable name (e.g., "targ_arch") instead of trying to give your own use/meaning to a variable which is already in use.  Fighting the builtin rules is a bad use of your time.)


Philip Guenther

On Fri, Sep 3, 2021 at 12:58 PM Jeffrey.Fellin--- via Bug reports and discussion for GNU make <bug-make@gnu.org> wrote:

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]