help-make
[Top][All Lists]
Advanced

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

Implicit rule for .S.o


From: Dmitry Dzhus
Subject: Implicit rule for .S.o
Date: Mon, 11 Aug 2008 21:05:50 +0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Hi all!

When is one expected to use the .S.o implicit rule?

My source contains a `foo.S` file, which needs to be preprocessed first
with `$(PREPROCESS.S)` to `foo.s` file, which later should be compiled with
`$(COMPILE.s)` (expanded to `$(AS) $(ASFLAGS)`, see default.c:383) to
`foo.o` file. That makes a chain of two implicit rules — «`.s` to `.S`»
plus «`.S` to `.o`». 

Anyways, Make has a special «optimized» rule which tries to shortcut the
way.

When attempting to update a `foo.o` target, Make tries to use a .S.o
rule (see default.c:212), the following happens:

    Considering target file `foo.o'.
         File `foo.o' does not exist.
         Looking for an implicit rule for `foo.o'.
         …
         Trying implicit prerequisite `foo.S'.
         Found prerequisite `foo.S' as VPATH `src/foo.S'
         Found an implicit rule for `foo.o'.
          Considering target file `foo.S'.
           Looking for an implicit rule for `foo.S'.
           …
           No implicit rule found for `foo.S'.
           Finished prerequisites of target file `foo.S'.
          No need to remake target `foo.S'; using VPATH name `src/foo.S'.
         Finished prerequisites of target file `foo.o'.
        Must remake target `foo.o'.
    cc --32 -DNDEBUG -c -o foo.o src/foo.S
    Putting child 0x080863b8 (foo.o) PID 32664 on the chain.
    Live child 0x080863b8 (foo.o) PID 32664 
    cc1: error: unrecognized command line option "-f32"
    Reaping losing child 0x080863b8 PID 32664 
    make: *** [foo.o] Error 1
    Removing child 0x080863b8 PID 32664 from chain.

I've noticed `$(COMPILE.S)` command used to directly build a `foo.c`
from `foo.S` is:

    "COMPILE.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c",

The difference between `$(COMPILE.s)` and `$(COMPILE.S)` is that the
latter one uses `$(CC)` instead of `$(AS)` for the command name.

My concern is whether should this ever work at all, given that `cc(1)`
doesn't recognize `as(1)` options? (Probably it's a `cc(1)` problem).

Doesn't Make attempt to be too smart in this case? Should this implicit
rule which tries to compile an `.S` file with CC and ASFLAGS at the same
time exist at all?

For now I've added an emptry `foo.s: foo.S` rule to my Makefile to force
Make use two implicit rules, not the shortcut one.

I've got a strange feeling that I've missed something important about
implicit rules etc.
-- 
Happy Hacking.

http://sphinx.net.ru

reply via email to

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