-
Notifications
You must be signed in to change notification settings - Fork 29
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
docs: Update linux build instructions #142
Conversation
docs/building.md
Outdated
$ cmake --build build --parallel | ||
# Note: number after '-j' is threads used. | ||
# Max is 'n-1' threads your cpu supports. | ||
$ cmake --build build --parallel -j 4 |
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.
Do we have this issue only in Linux? At least macOs has the same problem.
Also, we can try to use all available cores - 1 e.g. by doing:
https://unix.stackexchange.com/questions/208568/how-to-determine-the-maximum-number-to-pass-to-make-j-option
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.
The following works on mac:
$ nproc
12
$ nproc --ignore=1
11
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.
cmake --build build -j $(nproc)
built without issue. I just now realize that -j
and --parallel
are equivalent in cmake. So we could use whichever, don't need both.
$cmake --build
If <jobs> is omitted the native build tool's default number is used.
https://www.gnu.org/software/make/manual/html_node/Parallel.html
If there is nothing looking like an integer after the ‘-j’ option, there is no limit on the number of job slots.
So it looks like GNU make
has no limit, and building the protobuf library must bump that number of jobs above `nproc' for me. (which then maxes out my memory? From what I read, it's not just about jobs, but the memory it uses. So when google uses 9 jobs, it is over 13.5 GBs on my machine?)
So it seems it's build system dependent (native build tool that cmake is calling). I have to re-install windows to test that, I've never been able to clone a windows drive without it complaining and it got demoted to my slowest drive, I'll probably get that done in the next week or so.
TL;DR: (I guess --paralllel is more explicit to the user, I'm indifferent)
cmake --build build -j $(nproc)
or
cmake --build build --parallel $(nproc)
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.
From what I read, it's not just about jobs, but the memory it uses. So when google uses 9 jobs, it is over 13.5 GBs on my machine?)
Ah, that could be. Nice catch!
Ok, lets do the following:
- For macOs and Linux add
$(nproc)
(or probably$(nproc --ignore=1)
). - For windows: keep it as is until further issues.
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.
Addressed in e4e7baf with suggested corrections.
Thank you for the patch!
I tried including the |
$ cmake --build build --parallel | ||
$ cmake --build build --parallel $(nproc --ignore=0) | ||
|
||
# If building freezes in above step, increase number: --ignore=1, ignore=2 ... |
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.
Lets reshape it in the following way:
# Build the project.
cmake --build build --parallel $(nproc)
# If building freezes in above step, decrease nproc to 1 or more, e.g.:
cmake --build build --parallel $(nproc --ignore=1)
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.
Since the first command must work for everyone, we provide fallback command to those who have build issues.
Kudos to @Nickrader Signed-off-by: Alexander Kurbatov <sir.alkurbatov@yandex.ru>
Building protobuf with '--parallel' parameter causes computer to freeze and shell to crash.
Using 'n-1' threads that your cpu supports seems to avoid google crashing the shell.
Tried building protobuf outside the project with '--parallel' and it broke similar place as in our project.
closes #141