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 build on OpenBSD #58

Merged
merged 1 commit into from
Jan 23, 2023
Merged

Fix build on OpenBSD #58

merged 1 commit into from
Jan 23, 2023

Conversation

kit-ty-kate
Copy link
Contributor

On OpenBSD swap32 and swap64 are defines such that:

#define swap32(x) __swap32(x)
#define swap64(x) __swap64(x)

When defining those functions below the compilation failed with:

#=== ERROR while compiling sha.1.15.2 =========================================#
# context     2.2.0~alpha~dev | openbsd/x86_64 | ocaml-base-compiler.4.14.0 | https://opam.ocaml.org#245530a0
# path        ~/.opam/default/.opam-switch/build/sha.1.15.2
# command     ~/.opam/default/bin/dune build -p sha -j 1 --promote-install-files=false @install
# exit-code   1
# env-file    ~/.opam/log/sha-20406-d9480e.env
# output-file ~/.opam/log/sha-20406-d9480e.out
### output ###
# [...]
# /usr/include/machine/_types.h:68:28: note: previous definition is here
# typedef unsigned long long      __uint64_t;
#                                 ^
# In file included from sha512_stubs.c:30:
# In file included from ./sha512.h:25:
# ./bitfn.h:59:26: error: use of undeclared identifier 'a'
#         asm ("bswap %0" : "=r" (a) : "0" (a));
#                                 ^
# ./bitfn.h:60:9: error: use of undeclared identifier 'a'
#         return a;
#                ^
# 2 warnings and 8 errors generated.

@kit-ty-kate
Copy link
Contributor Author

The AppVeyor failure is unrelated

@kit-ty-kate
Copy link
Contributor Author

cc @dsheets

@dsheets
Copy link
Contributor

dsheets commented Nov 29, 2022

Did you mean to ping me? Or perhaps @djs55 ? I'm not sure how I'm related to this issue.

@dra27
Copy link

dra27 commented Jan 23, 2023

Given how the header's used, might it be better instead to sha's static inline functions to have a prefix (i.e. change swap32 to ocaml_sha_swap32, etc?)

Copy link
Owner

@djs55 djs55 left a comment

Choose a reason for hiding this comment

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

Let’s fix the build and then consider a rename with a prefix as a second step

@djs55 djs55 merged commit cee3205 into djs55:master Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants