public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] BaseTools: Fix an incremental build issue caused by macro in #include
@ 2019-10-16  6:17 Lin, Derek (HPS SW)
  2019-10-16 11:53 ` [edk2-devel] " Philippe Mathieu-Daudé
  0 siblings, 1 reply; 4+ messages in thread
From: Lin, Derek (HPS SW) @ 2019-10-16  6:17 UTC (permalink / raw)
  To: devel; +Cc: derek.lin2, bob.c.feng, liming.gao, zhijux.fan

When c/h file use macro after #include, for example,
In this case, GenMake is not able to create a healthy dependency for the c
file. GenMake used to add $(FORCE_REBUILD) dependency in the c file, this
guarantee the c file is always compiled in incremental build. But, this
function is broken since 05217d210e8da37b47d0be58ec363f7af2fa1c18 which
enable /MP for MSVC compiler, in order to compile multiple c files in one
command multi-processing. The fix here is adding '$(FORCE_REBUILD)' back to
retain the original function.

Line number 1728 and 978 are the code pieces which handle this logic.

Signed-off-by: Derek Lin <derek.lin2@hpe.com>
---
 BaseTools/Source/Python/AutoGen/GenMake.py | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index 97ba158ff2..59a01a7f24 100755
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -1080,13 +1080,17 @@ cleanlib:
                     else:
                         CmdCppDict[item.Target.SubDir] = ['$(MAKE_FILE)', Path]
                     if CppPath.Path in DependencyDict:
-                        for Temp in DependencyDict[CppPath.Path]:
-                            try:
-                                Path = self.PlaceMacro(Temp.Path, self.Macros)
-                            except:
-                                continue
-                            if Path not in (self.CommonFileDependency + CmdCppDict[item.Target.SubDir]):
-                                CmdCppDict[item.Target.SubDir].append(Path)
+                        if '$(FORCE_REBUILD)' in DependencyDict[CppPath.Path]:
+                            if '$(FORCE_REBUILD)' not in (self.CommonFileDependency + CmdCppDict[item.Target.SubDir]):
+                                CmdCppDict[item.Target.SubDir].append('$(FORCE_REBUILD)')
+                        else:
+                            for Temp in DependencyDict[CppPath.Path]:
+                                try:
+                                    Path = self.PlaceMacro(Temp.Path, self.Macros)
+                                except:
+                                    continue
+                                if Path not in (self.CommonFileDependency + CmdCppDict[item.Target.SubDir]):
+                                    CmdCppDict[item.Target.SubDir].append(Path)
         if T.Commands:
             CommandList = T.Commands[:]
             for Item in CommandList[:]:
-- 
2.20.1.windows.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [PATCH] BaseTools: Fix an incremental build issue caused by macro in #include
  2019-10-16  6:17 [PATCH] BaseTools: Fix an incremental build issue caused by macro in #include Lin, Derek (HPS SW)
@ 2019-10-16 11:53 ` Philippe Mathieu-Daudé
  2019-10-17  0:38   ` Bob Feng
  0 siblings, 1 reply; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-16 11:53 UTC (permalink / raw)
  To: devel, derek.lin2; +Cc: bob.c.feng, liming.gao, zhijux.fan

Hi Derek,

On 10/16/19 8:17 AM, Lin, Derek (HPS SW) wrote:
> When c/h file use macro after #include, for example,

Apparently you forgot to write your example.

> In this case, GenMake is not able to create a healthy dependency for the c
> file. GenMake used to add $(FORCE_REBUILD) dependency in the c file, this
> guarantee the c file is always compiled in incremental build. But, this
> function is broken since 05217d210e8da37b47d0be58ec363f7af2fa1c18 which
> enable /MP for MSVC compiler, in order to compile multiple c files in one
> command multi-processing. The fix here is adding '$(FORCE_REBUILD)' back to
> retain the original function.
> 
> Line number 1728 and 978 are the code pieces which handle this logic.
> 
> Signed-off-by: Derek Lin <derek.lin2@hpe.com>
> ---
>   BaseTools/Source/Python/AutoGen/GenMake.py | 18 +++++++++++-------
>   1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
> index 97ba158ff2..59a01a7f24 100755
> --- a/BaseTools/Source/Python/AutoGen/GenMake.py
> +++ b/BaseTools/Source/Python/AutoGen/GenMake.py
> @@ -1080,13 +1080,17 @@ cleanlib:
>                       else:
>                           CmdCppDict[item.Target.SubDir] = ['$(MAKE_FILE)', Path]
>                       if CppPath.Path in DependencyDict:
> -                        for Temp in DependencyDict[CppPath.Path]:
> -                            try:
> -                                Path = self.PlaceMacro(Temp.Path, self.Macros)
> -                            except:
> -                                continue
> -                            if Path not in (self.CommonFileDependency + CmdCppDict[item.Target.SubDir]):
> -                                CmdCppDict[item.Target.SubDir].append(Path)
> +                        if '$(FORCE_REBUILD)' in DependencyDict[CppPath.Path]:
> +                            if '$(FORCE_REBUILD)' not in (self.CommonFileDependency + CmdCppDict[item.Target.SubDir]):
> +                                CmdCppDict[item.Target.SubDir].append('$(FORCE_REBUILD)')
> +                        else:
> +                            for Temp in DependencyDict[CppPath.Path]:
> +                                try:
> +                                    Path = self.PlaceMacro(Temp.Path, self.Macros)
> +                                except:
> +                                    continue
> +                                if Path not in (self.CommonFileDependency + CmdCppDict[item.Target.SubDir]):
> +                                    CmdCppDict[item.Target.SubDir].append(Path)
>           if T.Commands:
>               CommandList = T.Commands[:]
>               for Item in CommandList[:]:
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [PATCH] BaseTools: Fix an incremental build issue caused by macro in #include
  2019-10-16 11:53 ` [edk2-devel] " Philippe Mathieu-Daudé
@ 2019-10-17  0:38   ` Bob Feng
  2019-10-17  2:02     ` Lin, Derek (HPS SW)
  0 siblings, 1 reply; 4+ messages in thread
From: Bob Feng @ 2019-10-17  0:38 UTC (permalink / raw)
  To: devel@edk2.groups.io, philmd@redhat.com, derek.lin2@hpe.com
  Cc: Gao, Liming, Fan, ZhijuX

I think one of the example would be like this:
    #include MACRO(xxx.h)

I think this patch is good. Thanks for caching and fixing this bug.

Reviewed-by: Bob Feng <bob.c.feng@intel.com>

Thanks,
Bob

-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Philippe Mathieu-Daudé
Sent: Wednesday, October 16, 2019 7:54 PM
To: devel@edk2.groups.io; derek.lin2@hpe.com
Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>; Fan, ZhijuX <zhijux.fan@intel.com>
Subject: Re: [edk2-devel] [PATCH] BaseTools: Fix an incremental build issue caused by macro in #include

Hi Derek,

On 10/16/19 8:17 AM, Lin, Derek (HPS SW) wrote:
> When c/h file use macro after #include, for example,

Apparently you forgot to write your example.

> In this case, GenMake is not able to create a healthy dependency for 
> the c file. GenMake used to add $(FORCE_REBUILD) dependency in the c 
> file, this guarantee the c file is always compiled in incremental 
> build. But, this function is broken since 
> 05217d210e8da37b47d0be58ec363f7af2fa1c18 which enable /MP for MSVC 
> compiler, in order to compile multiple c files in one command 
> multi-processing. The fix here is adding '$(FORCE_REBUILD)' back to retain the original function.
> 
> Line number 1728 and 978 are the code pieces which handle this logic.
> 
> Signed-off-by: Derek Lin <derek.lin2@hpe.com>
> ---
>   BaseTools/Source/Python/AutoGen/GenMake.py | 18 +++++++++++-------
>   1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py 
> b/BaseTools/Source/Python/AutoGen/GenMake.py
> index 97ba158ff2..59a01a7f24 100755
> --- a/BaseTools/Source/Python/AutoGen/GenMake.py
> +++ b/BaseTools/Source/Python/AutoGen/GenMake.py
> @@ -1080,13 +1080,17 @@ cleanlib:
>                       else:
>                           CmdCppDict[item.Target.SubDir] = ['$(MAKE_FILE)', Path]
>                       if CppPath.Path in DependencyDict:
> -                        for Temp in DependencyDict[CppPath.Path]:
> -                            try:
> -                                Path = self.PlaceMacro(Temp.Path, self.Macros)
> -                            except:
> -                                continue
> -                            if Path not in (self.CommonFileDependency + CmdCppDict[item.Target.SubDir]):
> -                                CmdCppDict[item.Target.SubDir].append(Path)
> +                        if '$(FORCE_REBUILD)' in DependencyDict[CppPath.Path]:
> +                            if '$(FORCE_REBUILD)' not in (self.CommonFileDependency + CmdCppDict[item.Target.SubDir]):
> +                                CmdCppDict[item.Target.SubDir].append('$(FORCE_REBUILD)')
> +                        else:
> +                            for Temp in DependencyDict[CppPath.Path]:
> +                                try:
> +                                    Path = self.PlaceMacro(Temp.Path, self.Macros)
> +                                except:
> +                                    continue
> +                                if Path not in (self.CommonFileDependency + CmdCppDict[item.Target.SubDir]):
> +                                    
> + CmdCppDict[item.Target.SubDir].append(Path)
>           if T.Commands:
>               CommandList = T.Commands[:]
>               for Item in CommandList[:]:
> 





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [PATCH] BaseTools: Fix an incremental build issue caused by macro in #include
  2019-10-17  0:38   ` Bob Feng
@ 2019-10-17  2:02     ` Lin, Derek (HPS SW)
  0 siblings, 0 replies; 4+ messages in thread
From: Lin, Derek (HPS SW) @ 2019-10-17  2:02 UTC (permalink / raw)
  To: Bob Feng, devel

[-- Attachment #1: Type: text/plain, Size: 378 bytes --]

Hi Phillippe,

Yeah, I forgot to fill my example. Thanks for the catch.

It is exactly as Bob mentioned, #include MACRO(xxx.h).

There are silicon code use macro to separate definitions, and use the approach to reuse code. Like:
#define PATH(x) <silicon1/x.h> // in platform 1
#define PATH(x) <silicon2/x.h> // in platform 2
#include PATH(abc.h)   // in common code

[-- Attachment #2: Type: text/html, Size: 434 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-17  2:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-16  6:17 [PATCH] BaseTools: Fix an incremental build issue caused by macro in #include Lin, Derek (HPS SW)
2019-10-16 11:53 ` [edk2-devel] " Philippe Mathieu-Daudé
2019-10-17  0:38   ` Bob Feng
2019-10-17  2:02     ` Lin, Derek (HPS SW)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox