-
Notifications
You must be signed in to change notification settings - Fork 292
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
fix: Remove cmake cache files after copying to container build directory #2325
fix: Remove cmake cache files after copying to container build directory #2325
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2325 +/- ##
==========================================
+ Coverage 78.06% 78.08% +0.01%
==========================================
Files 140 140
Lines 31053 31053
==========================================
+ Hits 24243 24247 +4
+ Misses 6810 6806 -4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@robinlinden Hey, could you review this when possible? Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: 0 of 1 approvals obtained
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 approvals obtained
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @Tha14)
other/docker/windows/build_toxcore.sh
line 74 at r1 (raw file):
-DCMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS -fstack-protector" \ -DCMAKE_SHARED_LINKER_FLAGS="$CMAKE_SHARED_LINKER_FLAGS" \ "$EXTRA_CMAKE_FLAGS" \
Please remove the quotes, they are undesirable. You are essentially forcing $EXTRA_CMAKE_FLAGS
to be passed to cmake as a single flag, where we want to allow it to contain multiple flags.
This PR doesn't make sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @nurupo)
other/docker/windows/build_toxcore.sh
line 74 at r1 (raw file):
Previously, nurupo wrote…
Please remove the quotes, they are undesirable. You are essentially forcing
$EXTRA_CMAKE_FLAGS
to be passed to cmake as a single flag, where we want to allow it to contain multiple flags.
Done.
Ok, I'm able to reproduce this. This is weird, I expected cmake to look for CMakeCache.txt only inside the build dir, but apparently it's also looking for it in the source directory. What's weirder is that if it doesn't error on it, it just ignores it, e.g. I had CMakeCache.txt contain only This seems to be more of an user error than a build script bug. The user made an in-tree cmake build and littered the source directory with cmake files. This is why it's recommended to use out-of-tree builds to avoid such issues. I'm for merging this, but Tha_14 should really consider doing out-of-tree builds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status:complete! 1 of 1 approvals obtained
Ok, I found the explanation of this weird behavior. See the first two commands in: https://cmake.org/cmake/help/v3.24/manual/cmake.1.html?highlight=cmakecache%20txt#generate-a-project-buildsystem
Essentially, because you had CMakeCache.txt file in the directory we specify when calling cmake, cmake treated that directory not as a source directory, but as a build directory, looking up the path to the source directory from the CMakeCache.txt file, and realizing that such path doesn't exist, resulting in the error you are seeing. This explains why it was picking up the CMakeCache.txt outside the current directory when I didn't expect it to. With this new information, this looks to be more of a build script bug than a user error as I have mentioned earlier. A proper fix would be to change the last cmake argument from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I should have commented via Reviewable so that I could do "Request changes".
Reviewable status: 1 change requests, 0 of 1 approvals obtained
|
That fixed the reproduced error for me. @Tha14 does it work for you? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nurupo Yes, I reproduced the mistake I did the first time and it fixes it.
Reviewable status: 1 change requests, 0 of 1 approvals obtained
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status:complete! 1 of 1 approvals obtained
Restyled is a required check, huh. It's a false positive in this case, we don't want that variable quoted, we want word splitting in here. I could add |
cmake treats the provided path differently depending on whether it contains a CMakeCache.txt or not. If it doesn't contain it -- it's treated as a path to the source tree, if it does -- as a path to the build tree. We want it to be treated as a source tree path, but if a user has CMakeCache.txt in that directory, e.g. from a previous in-tree build the user has done, cmake will treat it as a build tree instead, which might lead to unexpected results (improperly configured build) or an error, with the latter being more likely considering we are building inside a container and the host paths specified in the user-generated CMakeCache.txt likely don't exist in there.
Yes! At last, the final boss Restyled is defeated. Having to add this totally unnecessary array just to work-around the linter check is kind of crazy though. |
Now the AppVeyor build failed:
It was about to run the last autotest and finish... |
This is a change to the build script of the docker container for cross compiling toxcore for windows. I use the same repository cloned dir when I am building for both windows and linux and what tends to happen is CMakeCache.txt and CMakeFiles dir get copied to the build directory inside the container image which results in an error when cmake runs:
CMake Error: The current CMakeCache.txt directory /tmp/toxcore/CMakeCache.txt is different than the directory /root/Desktop/c-toxcore 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
To avoid having this problem I have added two
rm
commands to remove the files that cause the issue.This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)