Skip to contentSkip to conversation

kbuild: Make NOSTDINC_FLAGS a simply expanded variable

PATCH In review Douglas Anderson 2 participants 6 messages Mar 14, 2019 – Mar 15, 2019 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: Make NOSTDINC_FLAGS a simply expanded variable

During a simple no-op (nothing changed) build I saw 39 invocations of the C compiler with the argument "-print-file-name=include". We don't need to call the C compiler 39 times for this--one time will suffice.

Let's change NOSTDINC_FLAGS to a simply expanded variable to avoid this since there doesn't appear to be any reason it should be recursively expanded.

On my build this shaved ~400 ms off my "no-op" build.

Note that the recursive expansion seems to date back to the (really old) commit e8f5bdb02ce0 ("[PATCH] Makefile include path ordering"). It's a little unclear to me if the point of that patch was to switch the variable to be recursively expanded (which it did) or to avoid directly assigning to NOSTDINC_FLAGS (AKA to switch to +=) because someone else (out of tree?) was setting it. I presume later since if the only goal was to switch to recursive expansion the patch would have just removed the ":".

---

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index 9ef547fc7ffe..3034ba66ad51 100644
@@ -402,7 +402,7 @@ CHECK		= sparse
 
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
 		  -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
-NOSTDINC_FLAGS  =
+NOSTDINC_FLAGS :=
 CFLAGS_MODULE   =
 AFLAGS_MODULE   =
 LDFLAGS_MODULE  =
Signature · 1 line
2.21.0.360.g471c308f928-goog
#1 lore raw
Quoted 20 lines · Douglas Anderson

During a simple no-op (nothing changed) build I saw 39 invocations of the C compiler with the argument "-print-file-name=include". We don't need to call the C compiler 39 times for this--one time will suffice.

Let's change NOSTDINC_FLAGS to a simply expanded variable to avoid this since there doesn't appear to be any reason it should be recursively expanded.

On my build this shaved ~400 ms off my "no-op" build.

Note that the recursive expansion seems to date back to the (really old) commit e8f5bdb02ce0 ("[PATCH] Makefile include path ordering"). It's a little unclear to me if the point of that patch was to switch the variable to be recursively expanded (which it did) or to avoid directly assigning to NOSTDINC_FLAGS (AKA to switch to +=) because someone else (out of tree?) was setting it. I presume later since if the only goal was to switch to recursive expansion the patch would have just removed the ":".

Quoted 1 line

Applied to linux-kbuild.
Thanks.

Quoted 21 lines

---

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -2
index 9ef547fc7ffe..3034ba66ad51 100644
@@ -402,7 +402,7 @@ CHECK               = sparse
 
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
                  -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
-NOSTDINC_FLAGS  =
+NOSTDINC_FLAGS :=
 CFLAGS_MODULE   =
 AFLAGS_MODULE   =
 LDFLAGS_MODULE  =
--

2.21.0.360.g471c308f928-goog

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw
Quoted 22 lines · Masahiro Yamada
Quoted 20 lines · Douglas Anderson

During a simple no-op (nothing changed) build I saw 39 invocations of the C compiler with the argument "-print-file-name=include". We don't need to call the C compiler 39 times for this--one time will suffice.

Let's change NOSTDINC_FLAGS to a simply expanded variable to avoid this since there doesn't appear to be any reason it should be recursively expanded.

On my build this shaved ~400 ms off my "no-op" build.

Note that the recursive expansion seems to date back to the (really old) commit e8f5bdb02ce0 ("[PATCH] Makefile include path ordering"). It's a little unclear to me if the point of that patch was to switch the variable to be recursively expanded (which it did) or to avoid directly assigning to NOSTDINC_FLAGS (AKA to switch to +=) because someone else (out of tree?) was setting it. I presume later since if the only goal was to switch to recursive expansion the patch would have just removed the ":".

Quoted 4 lines
Quoted 1 line

Applied to linux-kbuild.
Thanks.

BTW, I noticed no one else
appends NOSTDINC_FLAGS.

So, does it make more sense to do as follows?

NOSTDINC_FLAGS := -nostdinc -isystem $(shell $(CC) -print-file-name=include)

Quoted 28 lines
Quoted 21 lines

---

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -2
index 9ef547fc7ffe..3034ba66ad51 100644
@@ -402,7 +402,7 @@ CHECK               = sparse
 
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
                  -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
-NOSTDINC_FLAGS  =
+NOSTDINC_FLAGS :=
 CFLAGS_MODULE   =
 AFLAGS_MODULE   =
 LDFLAGS_MODULE  =
--
Quoted 2 lines

2.21.0.360.g471c308f928-goog

--
Best Regards
Masahiro Yamada

Signature · 2 lines
Best Regards
Masahiro Yamada
#3 lore raw

Hi,

Quoted 31 lines · Masahiro Yamada
Quoted 22 lines · Masahiro Yamada
Quoted 20 lines · Douglas Anderson

During a simple no-op (nothing changed) build I saw 39 invocations of the C compiler with the argument "-print-file-name=include". We don't need to call the C compiler 39 times for this--one time will suffice.

Let's change NOSTDINC_FLAGS to a simply expanded variable to avoid this since there doesn't appear to be any reason it should be recursively expanded.

On my build this shaved ~400 ms off my "no-op" build.

Note that the recursive expansion seems to date back to the (really old) commit e8f5bdb02ce0 ("[PATCH] Makefile include path ordering"). It's a little unclear to me if the point of that patch was to switch the variable to be recursively expanded (which it did) or to avoid directly assigning to NOSTDINC_FLAGS (AKA to switch to +=) because someone else (out of tree?) was setting it. I presume later since if the only goal was to switch to recursive expansion the patch would have just removed the ":".

Quoted 4 lines
Quoted 1 line

Applied to linux-kbuild.
Thanks.

Quoted 8 lines

BTW, I noticed no one else
appends NOSTDINC_FLAGS.

So, does it make more sense to do as follows?

NOSTDINC_FLAGS := -nostdinc -isystem $(shell $(CC) -print-file-name=include)

It might. ...but go back to look at commit e8f5bdb02ce0 ("[PATCH] Makefile include path ordering"). Why did they do a += there since even then nobody was setting it. Try:

$ git grep NOSTDINC_FLAGS e8f5bdb02ce0~

Do you understand what was going on in that commit?

-Doug

#4 lore raw

Hi,

Quoted 45 lines · Doug Anderson

Hi,

Quoted 31 lines · Masahiro Yamada
Quoted 22 lines · Masahiro Yamada
Quoted 20 lines · Douglas Anderson

During a simple no-op (nothing changed) build I saw 39 invocations of the C compiler with the argument "-print-file-name=include". We don't need to call the C compiler 39 times for this--one time will suffice.

Let's change NOSTDINC_FLAGS to a simply expanded variable to avoid this since there doesn't appear to be any reason it should be recursively expanded.

On my build this shaved ~400 ms off my "no-op" build.

Note that the recursive expansion seems to date back to the (really old) commit e8f5bdb02ce0 ("[PATCH] Makefile include path ordering"). It's a little unclear to me if the point of that patch was to switch the variable to be recursively expanded (which it did) or to avoid directly assigning to NOSTDINC_FLAGS (AKA to switch to +=) because someone else (out of tree?) was setting it. I presume later since if the only goal was to switch to recursive expansion the patch would have just removed the ":".

Quoted 4 lines
Quoted 1 line

Applied to linux-kbuild.
Thanks.

Quoted 8 lines

BTW, I noticed no one else
appends NOSTDINC_FLAGS.

So, does it make more sense to do as follows?

NOSTDINC_FLAGS := -nostdinc -isystem $(shell $(CC) -print-file-name=include)

Quoted 8 lines

It might. ...but go back to look at commit e8f5bdb02ce0 ("[PATCH] Makefile include path ordering"). Why did they do a += there since even then nobody was setting it. Try:

$ git grep NOSTDINC_FLAGS e8f5bdb02ce0~

Do you understand what was going on in that commit?

No, I do not understand.

Maybe, it fixed a problem in downstream code since there was no directory like include/asm-xen.

If you do not want to take risk,
I am fine with this patch, though.

Quoted 1 line

-Doug

Signature · 2 lines
Best Regards
Masahiro Yamada
#5 lore raw

Hi,

Quoted 59 lines · Masahiro Yamada

Hi,

Quoted 45 lines · Doug Anderson

Hi,

Quoted 31 lines · Masahiro Yamada
Quoted 22 lines · Masahiro Yamada
Quoted 20 lines · Douglas Anderson

During a simple no-op (nothing changed) build I saw 39 invocations of the C compiler with the argument "-print-file-name=include". We don't need to call the C compiler 39 times for this--one time will suffice.

Let's change NOSTDINC_FLAGS to a simply expanded variable to avoid this since there doesn't appear to be any reason it should be recursively expanded.

On my build this shaved ~400 ms off my "no-op" build.

Note that the recursive expansion seems to date back to the (really old) commit e8f5bdb02ce0 ("[PATCH] Makefile include path ordering"). It's a little unclear to me if the point of that patch was to switch the variable to be recursively expanded (which it did) or to avoid directly assigning to NOSTDINC_FLAGS (AKA to switch to +=) because someone else (out of tree?) was setting it. I presume later since if the only goal was to switch to recursive expansion the patch would have just removed the ":".

Quoted 4 lines
Quoted 1 line

Applied to linux-kbuild.
Thanks.

Quoted 8 lines

BTW, I noticed no one else
appends NOSTDINC_FLAGS.

So, does it make more sense to do as follows?

NOSTDINC_FLAGS := -nostdinc -isystem $(shell $(CC) -print-file-name=include)

Quoted 8 lines

It might. ...but go back to look at commit e8f5bdb02ce0 ("[PATCH] Makefile include path ordering"). Why did they do a += there since even then nobody was setting it. Try:

$ git grep NOSTDINC_FLAGS e8f5bdb02ce0~

Do you understand what was going on in that commit?

Quoted 8 lines

No, I do not understand.

Maybe, it fixed a problem in downstream code since there was no directory like include/asm-xen.

If you do not want to take risk,
I am fine with this patch, though.

OK, let's keep the patch I posted then. Thanks!

-Doug