Skip to content

Rewrite the logic to check for CRC32 at runtime#3072

Merged
leggettc18 merged 10 commits intoHarbourMasters:develop-sulufrom
louist103:CRC32Fix
Aug 12, 2023
Merged

Rewrite the logic to check for CRC32 at runtime#3072
leggettc18 merged 10 commits intoHarbourMasters:develop-sulufrom
louist103:CRC32Fix

Conversation

@louist103
Copy link
Contributor

@louist103 louist103 commented Jul 7, 2023

Some users of older AMD CPUs have issues with the CRC intrinsic not being supported on their CPU leading to a crash. This changes the logic to check for the instruction at run time before running the CRC check on the rom.

Build Artifacts

Copy link
Contributor

@Malkierian Malkierian left a comment

Choose a reason for hiding this comment

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

I feel like this needs a bit of code clarification.


#if ((defined(__llvm__) && defined(__x86_64__) || defined(__i386__)))
#pragma clang attribute pop
#elif ((defined(__GNUC__) && defined(__x86_64__) || defined(__i386__)))
Copy link
Contributor

Choose a reason for hiding this comment

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

And also these two.

#include <immintrin.h>
#elif ((defined(__GNUC__) && defined(__x86_64__) || defined(__i386__)) && defined(__SSE4_2__))
#include <intrin.h>
#elif ((defined(__GNUC__) && defined(__x86_64__) || defined(__i386__)))
Copy link
Contributor

Choose a reason for hiding this comment

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

And here.

// Clang will define both __llvm__ and __GNUC__ but GCC will only define __GNUC__. So we need to check for __llvm__ first.
#if ((defined(__llvm__) && defined(__x86_64__) || defined(__i386__)))
#pragma clang attribute push(__attribute__((target("crc32"))), apply_to = function)
#elif ((defined(__GNUC__) && defined(__x86_64__) || defined(__i386__)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Here also.


// Force the compiler to assume we have support for the CRC32 intrinsic. We will check for our selves later.
// Clang will define both __llvm__ and __GNUC__ but GCC will only define __GNUC__. So we need to check for __llvm__ first.
#if ((defined(__llvm__) && defined(__x86_64__) || defined(__i386__)))
Copy link
Contributor

Choose a reason for hiding this comment

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

I may not be able to follow the entirety of the code, but this mix of && and || doesn't seem to be properly isolated. I find it hard to follow what the groupings are supposed to be. is it (llvm && x86_64) || i386, or llvm && (x86_64 || i386?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, great, I added them out of order XD.

@garrettjoecox
Copy link
Contributor

@louist103 what's the status of this? Is it good to go?

@louist103
Copy link
Contributor Author

@louist103 what's the status of this? Is it good to go?

Just tested it on M1. Seems good to me.

@Archez
Copy link
Contributor

Archez commented Aug 8, 2023

Since we know this fixes issues that users are facing in our support channels, I think this might be better suited for develop-sulu.

@louist103 louist103 force-pushed the CRC32Fix branch 2 times, most recently from b387cd5 to 7994cd9 Compare August 11, 2023 16:06
@louist103 louist103 changed the base branch from develop to develop-sulu August 11, 2023 16:07
@leggettc18 leggettc18 merged commit d22ca3c into HarbourMasters:develop-sulu Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants