tov / libffi-rs

Rust bindings for libffi
Apache License 2.0
104 stars 36 forks source link

Don't preserve libffi mode and ownership on build #80

Closed fracek closed 1 year ago

fracek commented 1 year ago

By default, copying a file will preserve its mode and ownership attributes. This is an issue when copying libffi from a read-only filesystem since the configuration log file also becomes read-only, causing a build failure.

yorickpeterse commented 1 year ago

@fracek Perhaps I'm misunderstanding the description, but how exactly would this work in the first place on a read-only file system? After all, you wouldn't be able to copy the files around in the first place.

fracek commented 1 year ago

@yorickpeterse In my case I'm copying from a read-only filesystem to a normal filesystem. I'm using the library in a Rust project and building it with nix, so all dependencies (including libffi) are stored in a read-only filesystem for caching. Before build, they're copied over to the working directory (which is in a normal filesystem). Without this patch, all files retain their read-only attributes and so the build fails. With this patch, the attributes are removed and the build works.

yorickpeterse commented 1 year ago

@fracek Ah that clears things up, thanks!

fracek commented 1 year ago

I see the build is failing on MacOS because it doesn't have the --no-preserve flag. I can fix it, but I want to hear what's your prefered solution:

yorickpeterse commented 1 year ago

@fracek Doing this in pure Rust is fine :smiley:

fracek commented 1 year ago

I didn't realize libffi was a directory. I changed it to conditionally add the necessary flags on linux.

fracek commented 1 year ago

@yorickpeterse I updated to check the output of cp --help to see if the flag exists.

yorickpeterse commented 1 year ago

@fracek Thanks!