[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
POSIX question on implicit .o rules
From: |
Eric Blake |
Subject: |
POSIX question on implicit .o rules |
Date: |
Thu, 19 Dec 2024 12:17:46 -0600 |
User-agent: |
NeoMutt/20241114 |
Hello Paul and GNU make developers,
The Austin Group (the people in charge of the POSIX specification)
recently discussed this bug, and desire feedback from the GNU make
community:
https://www.austingroupbugs.net/bug_view_page.php?bug_id=1890
With GNU make 4.4.1 (and no makefile):
$ touch foo.c
$ make -n foo.o
cc -c -o foo.o foo.c
$ POSIXLY_CORRECT=1 make -n foo.o
cc -c -o foo.o foo.c
But a close reading of the standard states that the implicit rule
should be:
https://pubs.opengroup.org/onlinepubs/9699919799/toc.htm
| CC=c99
| CFLAGS=-O 1
|
| .c.o:
| $(CC) $(CFLAGS) -c $<
Currently GNU make does not conform to the required .c.o inference
rule because it adds a -o option.
What's worse, the addition of a -o rule causes interesting effects; $<
contains a name with a /, the presence or absence of .o changes which
directory the compiler would put its outpt in, which in turn
influences where make should look for any existing .o file to check
for timestamps before deciding if compilation is needed.
Note that the other inference rules which invoke a $(CC) command with
-c are similarly affected.
The questions, then, are:
1. Would GNU make be willing to change such that when POSIXLY_CORRECT
is set, it uses the POSIX .c.o inference rule with no -o?
2. If not, and the standard should be changed to allow the .c.o
inference rule to include the -o option, could you supply proposed
wording for that, while still accounting for other implementations
that do not insert -o?
--
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization: qemu.org | libguestfs.org
- POSIX question on implicit .o rules,
Eric Blake <=