extendr / rextendr

An R package that helps scaffolding extendr-enabled packages or compiling Rust code dynamically
https://extendr.github.io/rextendr/
Other
184 stars 27 forks source link

Unable to mock `libgcc_*` lib file if it already exists #209

Closed Ilia-Kosenkov closed 1 year ago

Ilia-Kosenkov commented 1 year ago

https://github.com/extendr/rextendr/actions/runs/3255637727/jobs/5345165032#step:9:220

C:\rtools42\x86_64-w64-mingw32.static.posix\bin\ar.exe: creating libgcc_eh.a cp: cannot create regular file 'libgcc_s.a': File exists ERROR: configuration failed for package 'rextendr'

Ilia-Kosenkov commented 1 year ago

Reopening this because it still happens. Seems to be some sort of a race condition, see e.g. this SO post. UPD: Perhaps we should try to just touch this file here, instead of making a full copy https://github.com/extendr/rextendr/blob/36e145fb00167e25b9c0c891f35720aff70bf02d/inst/templates/Makevars.win#L21

yutannihilation commented 1 year ago

How about rm -r $(TARGET_DIR)/libgcc_mock before mkdir?

I think I tried to treat $(TARGET_DIR)/libgcc_mock as a target to prevent from executing twice, but my make-fu was not enough (probably some problem happened, but I don't remember well). There might be some better structure....

Ilia-Kosenkov commented 1 year ago

We can try that, but here the issue is some race condition -- cp does a check if the file exists (it does not at that time), then proceeds to copy, but the file is already there (something else created it), so it blows up. Cleaning the directory might not solve this, but worth giving a shot.

yutannihilation commented 1 year ago

Hmm, have you seen the problem on your local? Or is this only happen on the CI?

How about creating a tempdir and then mv last?

Ilia-Kosenkov commented 1 year ago

Actually, not locally, only on CI, but local machine != cloud runner, so that might be a problem. I will try something different, though the problem is the issue is random so there is no way to test it robustly.

Ilia-Kosenkov commented 1 year ago

Hm, why do we need libgcc_s.a? We always had problems with libgcc_eh.a, or its absence. In my case, I am able to compile a test package locally even if I just create a mock directory and then touch libgcc_eh.a. I'll make a test branch to see how it works on CI.

Ilia-Kosenkov commented 1 year ago

https://github.com/Ilia-Kosenkov/rextendr/actions/runs/3558213145 https://github.com/Ilia-Kosenkov/rextendr/actions/runs/3558213146 Seems to work fine, even though the only thing I did was touching libgcc_eh.a, without real compilation. https://github.com/Ilia-Kosenkov/rextendr/blob/3ca62814d4170d6600dce2e0fff8b97cab0728e7/inst/templates/Makevars.win#L18