I think the error Lee is talking about is due to MSVC Whole Program
Optimization. We were able to work around this by using #pragmas to tell MSVC
to use our own functions for memcpy and memset instead of the compiler's
intrinsic implementations. These functions simply wrap around CopyMem() and
SetMem().
See
http://stackoverflow.com/questions/2938966/how-to-use-vc-intrinsic-functions-w-o-run-time-library/2945619#2945619
We were able to get this solution to work without disabling Whole Program
Optimization with VS2010.
-Varun
From: Andrew Fish [mailto:[email protected]]
Sent: Thursday, September 05, 2013 11:59 AM
To: [email protected]
Subject: Re: [edk2] "unresolved external _memset" build error and how to fix it
On Sep 5, 2013, at 11:47 AM, "Hamel, Lee M"
<[email protected]<mailto:[email protected]>> wrote:
If you get this build error "unresolved external _memset in aLibrary.lib
(aSource.obj)"
It takes a bit of time to solve because the build log doesn't provide a
detailed clue. One way the issue can show up is when you are looping over an
array and setting the array item to 0. The compiler decides to use its
intrinsic function _memset to set the array memory block to 0 instead of
setting each item to 0.
Offending code
Corrected code
MyMemSet((UINT8 *) &myarray, 0, sizeof(myarray));
Is there a reason you could not use the
https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Include/Library/BaseMemoryLib.h
ZeroMem()?
for (x = 0; x < MAX_X; x++) {
for (y = 0; y < MAX_Y; y++) {
myarray[x][y] = 0;
} // y loop
} // x loop
You can track down the issue if you modify the library INF and add /FAcs build
flag, e.g.
[BuildOptions.common]
MSFT:*_*_*_CC_FLAGS = /FAcs
You can find where the compiler used its intrinsic function _memset as
disassembly mixed with source code. View the file
Build\YourPkg\<target>_<toolchain>\aPkg\Library\aLibrary\aLibrary\aSource.cod
and search for _memset. The .cod file lists source line numbers to enable you
to find where _memset is being used.
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk_______________________________________________
edk2-devel mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/edk2-devel
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may
contain
confidential information. Any unauthorized review, use, disclosure or
distribution
is prohibited. If you are not the intended recipient, please contact the
sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel