wheybags/glibc_version_header

How to deal with fcntl64?

rkfg opened this issue · 2 comments

rkfg commented

I'm using Boost.Asio in my project and it relies on fcntl64 that's only available in the most recent glibc 2.28. No matter what header I use this one symbol is still imported as fcntl64@@GLIBC_2.28 and prevents the binary from launching on an older system. I'm looking for a way to disable it and force using fcntl instead (which is available everywhere). One way to sort of fix it is to add __asm__(".symver fcntl64,fcntl@GLIBC_2.2.5"); (an example for glibc 2.9; basically, alias fcntl as fcntl64) but I'm not sure if it's the right way. My program works with this and I haven't noticed any issues yet. Any other suggestions? I'd like to simply add a #define somewhere (or undefine something).

If the code is explicitly using that newer function, I guess what you're doing is the only way.
Maybe you could look at the boost source and it could be using some glibc version detection then deciding to use that? You could then use temporary defines to force it to think its on an older version?
Not the loveliest solution I know :(

@rkfg I had the same problem, and implemented a workaround with symver and --wrap. Here is the Q&A for it:

https://stackoverflow.com/a/58472959/211160