Reporting Issues
Bug 2596 - FltUsedLib
Summary: FltUsedLib
Status: RESOLVED WONTFIX
Alias: None
Product: Tianocore Feature Requests
Classification: Unclassified
Component: Code (show other bugs)
Version: Current
Hardware: All All
: Lowest normal
Assignee: guomin.jiang
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-13 16:11 UTC by Matthew Carlson
Modified: 2020-07-21 20:25 UTC (History)
3 users (show)

See Also:
EDK II Code First industry standard specifications: ---
Branch URL:
Release(s) the issue is observed:
The OS the target platform is running: ---
Package: MdePkg
Release(s) the issues must be fixed:
Tianocore documents:


Attachments
proposed patch (2.28 KB, patch)
2020-03-13 16:12 UTC, Matthew Carlson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Carlson 2020-03-13 16:11:38 UTC
OpenSSL requires _fltused to be defined as a constant anywhere floating point is used. This is to satisfy the linker, however, it is possible to compile a module with multiple definitions of fltused. This causes the MSVC compiler to fail the build. To solve this problem, the FltUsedLib was created that is one spot that the global static can exist.
Comment 1 Matthew Carlson 2020-03-13 16:12:05 UTC
Created attachment 484 [details]
proposed patch
Comment 2 Matthew Carlson 2020-03-13 16:13:27 UTC
This makes a lot of situations easier (CryptoPkg\Library\IntrinsicLib\MemoryIntrinsics.c for example) as it can be included as a library.
Comment 3 nobody 2020-03-17 22:05:45 UTC
guomin: please check it.
Comment 4 guomin.jiang 2020-03-20 03:41:31 UTC
Hi Matthew,

Have you encountered this type issue?

If define library class, it may conflict with IntrinsicLib library class.

If consumer override the IntrinsicLib rather than define new?

Thanks
Comment 5 Sean Brogan 2020-03-24 15:52:30 UTC
Not sure i follow your question but the reason we moved to a library to define this symbol was to deal with two libraries within the same module.  If both libs defined it then there were problems.  If they both claimed dependent on the same library then it would only be defined once for the whole module.
Comment 6 nobody 2020-03-24 22:22:21 UTC
Propose the generic null type IntrinsicLib to include the common used intrinsic APIs, such as memcpy, memset. This library can be linked to every module.
Comment 7 guomin.jiang 2020-03-30 04:54:38 UTC
Post patch at message https://edk2.groups.io/g/devel/message/56613
Comment 8 nobody 2020-03-30 07:42:48 UTC
Guomin: please discuss the proposal on the generic null type IntrinsicLib first.
Comment 9 guomin.jiang 2020-03-30 09:06:25 UTC
Hi Liming,

The IntrinsicLib is just for CryptoLib. when you use openssl, it will intrinsic memset() and memcmp() provided by compiler.

But in edk2 implement, we have disabled the intrinsic feature from compiler, and it will occur that build error so we add the IntrinsicLib.

If we provide the null implement, although it can build pass, but the function will fail when memset() and memcmp() is invoked, so i think it is not a good idea.

Thanks.
Comment 10 nobody 2020-04-07 22:14:49 UTC
Guomin: please summary current feedback in edk2 community.
Comment 11 guomin.jiang 2020-04-10 01:53:27 UTC
Summarize the current status<br/>

Problem: It may occur that _fltused symbol is defined in two library and both are dependent by one module.<br/>

Goal: The reporter want to separate the _fltused symbol into single library and all other libraries which need _fltused symbol depend on the library, so it can resolve the problem.<br/>

Candidate Proposal 1: Define a NULL library for fltused.
  Michael D Kinney <michael.d.kinney@intel.com> exhibit that ARM use NULL library class for intrinsic.
  Sean <sean.brogan=microsoft.com@groups.io> think that it will affect it will affect size, optimization, and suggest that use new library.
  Michael D Kinney <michael.d.kinney@intel.com> think it will have no effect on size.

Candidate Proposal 2: Define FltUsedLib and IntrinsicLib separately.
  Bret Barkelew <bret.barkelew@microsoft.com> have provide the reviewed-by and seem that he/she agree define FltUsedLib
  Ard Biesheuvel <ard.biesheuvel@linaro.org> have consider that it affect all platform, and it is a problem.
  Laszlo Ersek <lersek@redhat.com> suggest that only add file on OpensslLib rather create new library and add limitation only for MSVC and disagree that add new FltusedLib.
  Matthew Carlson <macarl=microsoft.com@groups.io> point that it is required by MSVC compiler, but this is not just for openssl, for example, OnScreenKeyboard and UiToolKit driver will need this as well.
  Ard Biesheuvel <ard.biesheuvel@linaro.org> think it should belong to IntrinsicsLib and think can add fltused in a single file and add it to EntryPointLib(PEIMs, DXEs, etc).
  Laszlo Ersek <lersek@redhat.com> agree with Adr Biesheuvel
  I <guomin.jiang@intel.com> test add file FloatUsed.c with MSFT, it still fail because it will need /GL-.
  Ard Biesheuvel <ard.biesheuvel@linaro.org> think it should add EntryPointLib, but it seem that build fail.
  Michael D Kinney <michael.d.kinney@intel.com> think can use EntryPointLib or NULL
Comment 12 Sean Brogan 2020-04-20 17:45:13 UTC
I recently got confirmation from the Microsoft compiler team that fltused doesn't do anything anymore.  It is still required (bug filed for next version to remove).  I am now aligned with Mike K in that we should just add it to a baselib (both H and C files) for the Microsoft compiler toolchain.  We can then remove it from all other libraries.  

Thoughts? 

Thanks
Sean
Comment 13 guomin.jiang 2020-04-22 23:12:31 UTC
Post Patch v2 at https://edk2.groups.io/g/devel/message/57900.
Comment 14 guomin.jiang 2020-04-29 03:21:15 UTC
Hi All,

When i add FltUsed.c into BaseLib, it have below build error
UefiDriverEntryPoint.lib(DriverEntryPoint.obj) : fatal error LNK1237: during code generation, compiler introduced reference to symbol '_fltused' defined in module 'BaseLib.lib(FltUsed.obj)' compiled with /GL

Another thing:
I will not follow up the bug until Quarter 3 or July, thanks for your patience.

Best Regards
guomin
Comment 15 guomin.jiang 2020-07-09 20:54:51 UTC
I want to drop the request, because it seem that not necessary.

I want to get feedback from you, if no comments, i will close it next Friday.

Best Regards
Guomin
Comment 16 guomin.jiang 2020-07-21 20:25:57 UTC
Close it because it seem that no one care it.