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

fix: detect loongarch cpu in header #2128

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/ring-core/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
#elif !(defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) && \
!(defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
#error "Unsupported endianness"
#elif defined(__LP64__)
#elif defined(__LP64__) || defined(__loongarch64) || defined(__loongarch_lp64)
Copy link
Owner

Choose a reason for hiding this comment

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

Why is this needed? Does GCC for the 64-bit target not define __LP64__? https://loongson.github.io/LoongArch-Documentation/LoongArch-toolchain-conventions-EN.html says it is defined so this shouldn't be needed.

#define OPENSSL_64_BIT
#elif defined(__ILP32__)
#elif defined(__ILP32__) || defined(__loongarch__)
Copy link
Owner

Choose a reason for hiding this comment

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

Wouldn't this addition be better placed ...

Copy link

@setarcos setarcos Nov 2, 2024

Choose a reason for hiding this comment

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

__loongarch__ is defined for 64-bit systems as well, so this expression doesn't seem correct.

Copy link
Owner

Choose a reason for hiding this comment

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

__loongarch__ is defined for 64-bit systems as well, so this expression doesn't seem correct.

Yes, but __LP64__ will be set for 64-bit systems, right? Otherwise the logic for the other 32-bit archs wouldn't work either. Keep in mind that the thing we're really working around is that these old versions of GCC didn't set __ILP32__ for many 32-bit architectures.

#define OPENSSL_32_BIT
// Versions of GCC before 10.0 didn't define `__ILP32__` for all 32-bit targets.
#elif defined(__MIPSEL__) || defined(__MIPSEB__) || defined(__PPC__) || defined(__powerpc__) || defined(__csky__) || defined(__XTENSA__)
Copy link
Owner

Choose a reason for hiding this comment

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

...here, with all the other similar ones?

Expand Down