Skip to content

Fix building on FreeBSD 12#232

Closed
meanphil wants to merge 1 commit intobcrypt-ruby:masterfrom
meanphil:freebsd12_fix
Closed

Fix building on FreeBSD 12#232
meanphil wants to merge 1 commit intobcrypt-ruby:masterfrom
meanphil:freebsd12_fix

Conversation

@meanphil
Copy link
Copy Markdown

Based on a similar previous commit in ow-crypt.h, skip (re)defining crypt_r function signatures when they already exist in unistd.h

Not sure if this is completely the correct fix, but seems to work with FreeBSD and passes specs. Just unsure if it's then broken other platforms...

Without the fix, it has a similar error to building 3.1.12 on FreeBSD 12:

compiling ../../../../ext/mri/wrapper.c
../../../../ext/mri/wrapper.c:182:7: error: conflicting types for 'crypt_r'
char *crypt_r(const char *key, const char *setting, void *data)
      ^
/usr/include/unistd.h:499:7: note: previous declaration is here
char    *crypt_r(const char *, const char *, struct crypt_data *);
         ^
1 error generated.

FreeBSD 12.1
Ruby 2.6.6
FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based on LLVM 8.0.1)

Based on a similar commit in ow-crypt.h, skip (re)defining crypt_r function
signatures, when they already exist in unistd.h
@meanphil
Copy link
Copy Markdown
Author

meanphil commented Jul 29, 2020

Actually, it kind of looks like the 'crypt_r' function could be removed entirely as it's never called. Also the name of the GNU flag is misleading, it should really just be a generic test to see if the OS already has a function with the same name, rather than just checking for __GLIBC__

@jlduran
Copy link
Copy Markdown

jlduran commented Jul 31, 2020

Similar to: #166

@benpratt
Copy link
Copy Markdown

In #233 there was a comment by michelboaventura with another possible fix. He said:

I think de last argument's type is wrong. If you look at the documentation for crypt_r it should be struct crypt_data *, not void *. https://linux.die.net/man/3/crypt_r. If you change just this type it compiles both on FreeBSD and Linux.

@meanphil meanphil closed this Aug 28, 2020
@meanphil meanphil deleted the freebsd12_fix branch September 2, 2020 21:28
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.

3 participants