psyq321 / PowerMonkey

UEFI Application for CPU Voltage/Frquency and Power Management adjustment. Great for undervolting.
Apache License 2.0
218 stars 24 forks source link

Can't compile with ENABLE_MINILOG_TRACING #25

Open csdvrx opened 1 year ago

csdvrx commented 1 year ago

The normal build works fine with:

cd .. \
 && git clone https://github.com/tianocore/edk2-platforms.git \
 && cd edk2-platforms \
 && git submodule update --init

cd .. \
 git clone https://github.com/tianocore/edk2-non-osi.git \

echo $PWD | grep edk2 || echo "bad directory" && exit -1
export EDK_TOOLS_PATH="$PWD/BaseTools"
export PACKAGES_PATH="$PWD:$PWD/../edk2-platforms:$PWD/../edk2-non-osi"

. ./edksetup.sh

I then type: make -c BaseTool; build -a X64 -t GCC5 -p MdeModulePkg/MdeModulePkg.dsc

However, if I uncomment ENABLE_MINILOG_TRACING in ./MdeModulePkg/Application/PowerMonkeyApp/CONFIGURATION.h

/code/edk2/MdeModulePkg/Application/PowerMonkeyApp/MiniLog.c: In function ‘MiniTrace’:
/code/edk2/MdeModulePkg/Application/PowerMonkeyApp/MiniLog.c:286:7: error: implicit declaration of function ‘memset’ [-Werror=implicit-function-declaration]
  286 |       memset(lfb + startPix, 0, lineStride*font->fbHeight);
      |       ^~~~~~
/code/edk2/MdeModulePkg/Application/PowerMonkeyApp/MiniLog.c:113:1: note: ‘memset’ is defined in header ‘<string.h>’; did you forget to ‘#include <string.h>’?
  112 | #include "BmpFont.h"
  +++ |+#include <string.h>
  113 |
/code/edk2/MdeModulePkg/Application/PowerMonkeyApp/MiniLog.c: In function ‘MiniTraceEx’:
/code/edk2/MdeModulePkg/Application/PowerMonkeyApp/MiniLog.c:307:11: error: variable ‘nprinted’ set but not used [-Werror=unused-but-set-variable]
  307 |   UINTN   nprinted;
      |           ^~~~~~~~
cc1: all warnings being treated as errors
make: *** [GNUmakefile:462: /code/edk2/Build/MdeModule/DEBUG_GCC5/X64/MdeModulePkg/Application/PowerMonkeyApp/PowerMonkey/OUTPUT/MiniLog.obj] Error 1

The solution is to remove nprinted declaration and variable, and to add string.h

psyq321 commented 1 year ago

What is the compiler you are using?

Officially, UEFI spec frowns on using C lib, and some compilers (MSVC, I am looking at you) were still adding implicit memset calls by detecting memory copy patterns in the code, which is why I implemented own memset() in SaferAsm.nasm - and this is where linker probably links it from. PLMK what is the compiler so I can check and maybe change the name of the call so it does not introduce potential conflicts.