Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEST COMMIT: Update OcCompilerIntrinsicsLib so that it can build the network stack #555

Closed
wants to merge 1 commit into from

Conversation

mikebeaton
Copy link
Contributor

@mikebeaton mikebeaton commented Sep 7, 2024

@vit9696 - This is a test commit to show my current thinking on the intrinsics library.

This commit has the changes required to update our intrinsics library so that it can build the network stack. Note that we end up importing several things from the CryptoPkg IntrinsicLib (that is, the EDK 2 intrinsics library which I have used entirely instead of ours in the versions so far of the network boot PR).

This makes me wonder whether the CryptoPkg IntrinsicLib might not be the best one to base on (or rather just use as is, since it already builds our packages and the rest of EDK 2 fine) for a shared intrinsics lib, rather than ours, because the CryptoPkg library already covers the imported things and multiple other cases. (Albeit that, as you pointed out, the EDK 2 CryptoPkg IntrinsicLib has some bugs which we already had to fix.)

EDIT: Okay, it seems this commit has only the changes to our intrinsics library necessary to build the network stack on Xcode - as can be seen in the CI, we would need to import yet more of what is already in CryptoPkg (EDK 2) IntrinsicLib to update our intrinsics lib enough to build the network package on all the architectures. Which I think probably just confirms the point above.

My next step of reasoning, if the CryptoPkg IntrinsicLib is the best intrinsics lib to use, is that possibly moving it to MdePkg is not such a good idea. This is because it is already quite widely used as an intrinsics library all around EDK 2, despite by its name sounding as if it wouldn't be:

./CryptoPkg/CryptoPkgMbedTls.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./CryptoPkg/CryptoPkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./CryptoPkg/CryptoPkg.dsc:  CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./FmpDevicePkg/FmpDevicePkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./NetworkPkg/NetworkPkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./NetworkPkg/Test/NetworkPkgHostTest.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./OvmfPkg/Microvm/MicrovmX64.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./OvmfPkg/OvmfXen.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./OvmfPkg/CloudHv/CloudHvX64.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./OvmfPkg/Bhyve/BhyveX64.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./OvmfPkg/IntelTdx/IntelTdxX64.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./OvmfPkg/OvmfPkgIa32.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./OvmfPkg/OvmfPkgX64.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./OvmfPkg/AmdSev/AmdSevX64.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./OvmfPkg/OvmfPkgIa32X64.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./UefiCpuPkg/UefiCpuPkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./UefiCpuPkg/UefiCpuPkg.dsc:  CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./UefiPayloadPkg/UefiPayloadPkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./EmulatorPkg/EmulatorPkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./SecurityPkg/SecurityPkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./SecurityPkg/SecurityPkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./SecurityPkg/SecurityPkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./SecurityPkg/SecurityPkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./SecurityPkg/SecurityPkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./MdeModulePkg/MdeModulePkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./SignedCapsulePkg/SignedCapsulePkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./SignedCapsulePkg/SignedCapsulePkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./SignedCapsulePkg/SignedCapsulePkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./SignedCapsulePkg/SignedCapsulePkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./SignedCapsulePkg/SignedCapsulePkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./SignedCapsulePkg/SignedCapsulePkg.dsc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
./ArmVirtPkg/ArmVirt.dsc.inc:  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf

Another edit: I realised most of the above IntrinsicLib definitions are for use within CryptoPkg. :-/ But not all of them, as below. Which maybe allows me to still make the same point, but more weakly. i.e. it doesn't really seem worth moving the library out of CryptoPkg, if it's already at least somewhat normal to use it as an intrinsics lib outside that context. (But maybe I should be saying instead, it's been used outside twice - the fact that we want to use it outside a third time means it should be moved...?!) It's definitely that much easier to leave it where it is (assuming it's even the one we're going to use), but let me know.

./CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf:  IntrinsicLib
./CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf:  IntrinsicLib
./CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf:  IntrinsicLib
./CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf:  IntrinsicLib
./CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf:  IntrinsicLib
./CryptoPkg/Library/TlsLib/TlsLib.inf:  IntrinsicLib
./CryptoPkg/Library/BaseCryptLibMbedTls/BaseCryptLib.inf:  IntrinsicLib
./CryptoPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.inf:  IntrinsicLib
./CryptoPkg/Library/BaseCryptLibMbedTls/RuntimeCryptLib.inf:  IntrinsicLib
./CryptoPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.inf:  IntrinsicLib
./CryptoPkg/Library/BaseCryptLibMbedTls/SecCryptLib.inf:  IntrinsicLib
./OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.inf:  IntrinsicLib
./UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf:  IntrinsicLib

@mikebeaton mikebeaton marked this pull request as draft September 7, 2024 11:01
@mikebeaton mikebeaton marked this pull request as ready for review September 7, 2024 11:01
Comment on lines -401 to -402
CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf

Copy link
Contributor Author

@mikebeaton mikebeaton Sep 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these lines ever needed? I hope I'm not missing something, but AFAICT not. (This commit is relative to the network boot PR, but these lines were present before (further up in the file), referring to the OcCompilerIntrinsicsLib, before the network boot commit.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, based on feedback from #556, I believe there is indeed no point in including these lines for another package's library, as this is now - but it would have made sense to include them before, when they were our package's library.


GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN gOcCompilerIntrinsicsLib;

#if defined (MDE_CPU_IA32) && defined (__clang__) && defined (__apple_build_version__) && __apple_build_version__ < 11000000
#if defined (MDE_CPU_IA32) && defined (__clang__) && defined (__APPLE__)
Copy link
Contributor Author

@mikebeaton mikebeaton Sep 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did need to remove the version test, __udivdi3 was getting generated by code in TlsDxe when compiling using Xcode 15.0.1

@mikebeaton
Copy link
Contributor Author

Closing this, as I believe the investigations done here more or less establish that 'the one' intrinsics lib to use would be the CryptoLib one, not an updated OcCompilerIntrinsicsLib. (Though this may end up meaning some update of the CryptoLib IntrinsicsLib, possibly providing ARM intrinsics too, if that gets produced in EDK 2.)

@mikebeaton mikebeaton closed this Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant