dtrugman / pfs

Parsing the Linux procfs
Apache License 2.0
99 stars 33 forks source link

Fix compilation with musl libc #45

Closed doughdemon closed 6 months ago

dtrugman commented 7 months ago

Hi @doughdemon, Thanks for the contribution. I remember vaguely that I used pread64 to be compliant with older versions of gcc, so let me check that again. Possibly we will need to add a compilation time flag to choose the best flavor.

I'm sorry for the delay, and I will try to get to that asap.

doughdemon commented 7 months ago

Thanks for the contribution. I remember vaguely that I used pread64 to be compliant with older versions of gcc, so let me check that again. Possibly we will need to add a compilation time flag to choose the best flavor.

-D_FILE_OFFSET_BITS=64 should ensure that preadv uses the 64 bit version even on old systems.

dtrugman commented 6 months ago

Hi @doughdemon,

I didn't have too much time recently to get to this, but I finally did this morning. I realized that the problem was not older GCC versions, but rather something else.

There was an issue before #7 that helped me refresh my memory. What happens is this. When you compile the code with preadv as a 32-bit executable, everything seems to work find, but(!) you can't read the entire memory space of a 64-bit process. By using preadv64, you are able to do so, because it expects an loff_t, which is 64-bit even for 32-bit executables. If we use preadv, you are NOT able to do so, because it expects an off_t, which is a 32-bit value.

Unfortunately my current setup makes it difficult for me to run the exact scenario locally, so I need to spawn up a new machine to test it thoroughly. I believe I can do that today or tomorrow, and then I can try to adjust the tests accordingly. Having this test in the CI/CD pipeline could prevent some human errors.

Thanks for your patience.

doughdemon commented 6 months ago

No worries about the delay.

-D_FILE_OFFSET_BITS=64 should ensure that off_t is 64bit on all systems.

dtrugman commented 6 months ago

OK, It seems to work fine. For future readers: As currently running 32-bit executables on a 64-bit machine is not a popular use-case, no reason to invest significantly in it. And it will be handled upon request.