ColumPaget / libUseful

Programmers 'C' library of functions for: resizable strings, file and network access, string tokenization, pattern matching, terminal output, etc, etc
Other
14 stars 2 forks source link

libUseful mistakes Mac getxattr for Linux getxattr #1

Closed mistydemeo closed 4 years ago

mistydemeo commented 4 years ago

Both macOS and Linux provide non-POSIX functions named getxattr/setxattr, but they're not compatible with each other. At a glance, they seem to be mostly similar, but the Mac one takes extra position and options parameters: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getxattr.2.html

libUseful's configure script just checks for whether the function exists and assumes it's usable. That causes compilation to fail on Macs unless --disable-xattr is explicitly passed. Since it looks like it's specifically looking for the Linux function by this name, it's probably a good idea to make using it dependent on the OS too.

ColumPaget commented 4 years ago

thanks for reporting this. I thought I'd already fixed this one, but I must not have been able to figure it out. Do you have any insight into autoconf, and how I might catch this? I've always found autoconf to be like something Serverus Snape would teach.

hmm... maybe I can just check for osx at compile time? I did think I was doing that.

mistydemeo commented 4 years ago

Yeah, I think checking it in autoconf is going to be... thorny? I have about the same experiences with trying to make autoconf checks like that more complex.

I think scoping the check to #ifdef __linux__ would be more appropriate than checking for OS X; since it's a non-POSIX API, any other functions by the same name in other non-OS X OSs are probably also going to end up being incompatible.

ColumPaget commented 4 years ago

I've discovered there's an #ifdef APPLE, which I'm hoping will fix it. It's passing on travis-ci, but then it was before too. It's in the 4.23 release.

I tend to find autoconf is, to paraphrase Churchill, the worst build system there is, except for all the other ones I've seen.

Thanks again for reporting this.

mistydemeo commented 4 years ago

Thanks! I caught a handful of very minor issues with that commit, so I opened #2 to fix that.