Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support incremental builds with CMake #288

Merged
merged 3 commits into from
Jul 26, 2023
Merged

Support incremental builds with CMake #288

merged 3 commits into from
Jul 26, 2023

Conversation

Patryk27
Copy link
Contributor

@Patryk27 Patryk27 commented May 6, 2023

When CMake builds a project, it generates a file called CMakeCache.txt that contains - among others - a dump of environmental variables.

This file is generated both for the deps-only- and the main- derivation, and if env-vars happen to differ between both¹, CMake will refuse to compile the latter derivation, saying:

CMake Error: The current CMakeCache.txt directory ... is different than the directory ... where CMakeCache.txt was created.

Solving this problem is easy - one just has to remove CMakeCache.txt to let CMake regenerate it.

Note that the original bug report (linked below) suggests to use sed, but that doesn't work on Darwin which uses a different convention for temporary paths - compare error messages for the failing derivations:

... on Linux:

CMake Error: The current CMakeCache.txt directory /build/source/target/release/build/oqs-sys-a19e222d9ef825d3/out/build/CMakeCache.txt is different than the directory /build/dummy-src/target/release/build/oqs-sys-a19e222d9ef825d3/out/build where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt

... and on Darwin:

CMake Error: The current CMakeCache.txt directory /tmp/nix-build-app-0.1.0.drv-5/source/target/release/build/oqs-sys-4b5e25b1671aa1e5/out/build/CMakeCache.txt is different than the directory /tmp/nix-build-app-deps-0.1.0.drv-0/source/target/release/build/oqs-sys-4b5e25b1671aa1e5/out/build where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt

As for the implementation, since two-step builds are a Naersk-specific construct, I think solving this transparently on Naersk's side instead of just adding a tip into README.md is the better approach here, since it keeps Naersk plug-and-play'able.

Closes #285.

¹ which is not that difficult, e.g. that's how pkgs.rustPlatform.bindgenHook behaves

nix/sources.json Outdated Show resolved Hide resolved
nix/sources.json Outdated Show resolved Hide resolved
nix/sources.json Outdated Show resolved Hide resolved
@Patryk27 Patryk27 marked this pull request as ready for review May 6, 2023 19:16
.github/workflows/test.yml Outdated Show resolved Hide resolved
@nmattia
Copy link
Collaborator

nmattia commented May 23, 2023

Missed the notification! I'll have a look ASAP

@Patryk27
Copy link
Contributor Author

Ping, @nmattia 🙂

If you don't have time, it's alright, of course - I'm re-pinging just in case.

Copy link
Collaborator

@nmattia nmattia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Patryk27 sorry, completely dropped the ball 😬 Lots going on privately

Is there any way you could split out the bits not directly related to CMake (formatting, package updates, etc)? That'd make it easier to review, right now I'm not 100% sure what's needed by the "CMake changes" and was is just clean up

@Patryk27
Copy link
Contributor Author

Sure, sure - that exists as a single commit only because it's required for the test to exist - I'll split it into separate commits when I find a moment 🙂

@Patryk27
Copy link
Contributor Author

Okie, commit split 🙂

nmattia
nmattia previously approved these changes Jun 20, 2023
Copy link
Collaborator

@nmattia nmattia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! Guess this had very little to do with CMake in the end :)

default.nix Outdated Show resolved Hide resolved
@nmattia
Copy link
Collaborator

nmattia commented Jun 20, 2023

@Patryk27 sorry for the delay! Bit snowed under with personal stuff at the moment, but don't hesitate to ping me again if I forget :)

@Patryk27
Copy link
Contributor Author

Patryk27 commented Jul 9, 2023

Ping, ping @nmattia - should be much easier to review now 😄

I've had to bump Nix sources and add Fenix to get tests working on aarch64, but other than that, there's only the README.md change.

Copy link
Collaborator

@nmattia nmattia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, I was out for a bit! Let's gooo :)

@Patryk27 Patryk27 merged commit 711ebec into master Jul 26, 2023
@Patryk27 Patryk27 deleted the fix-285/cmake branch July 26, 2023 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

two step builds fail if CMake is used in a build.rs
2 participants