-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
easyinstall: Add an option to compile with clang++ #968
Comments
@uweseimet As someone not knowing the intricacies of the gcc vs. clang capabilities, are there any drawbacks to using clang over gcc? FYI it is perfectly possible to compile RaSCSI with gcc on a Pi Zero W and Zero 2 W when running a 32 bit OS. I do this all the time. I also recall seeing discussions on Discord about using virtual memory as an option, which is of course not the fastest option. Besides, I have found that 64 bit RaSCSI runs noticeably slower and uses more memory on my Pi Zeroes, and even on my Pi 3+. Therefore I exclusively run 32 bit OSes on my Pis again. |
@rdmark The Pi uses virtual memory by default, as far as I can tell. Of course if this memory is needed because there is not enough RAM, it is not fast, but if you have a Pi like the Zero WH compiling is very slow anyway. But still, even with extensive swapping I would not expect the system/the compiler to crash, but this is what happens at least with my setup. |
By the way, I don't mind at all if this ticket is rejected. It's just a suggestion for a potential resolution of compilation problems on systems with memory issues. |
If clang provides for faster compilation on a Pi Zero I think that alone would be a solid reason to look closer at this and potentially make this the default on Bullseye, or at least offer it as an option. The long compilation times on the Zero is something users do complain about sometimes. I've been testing on one of my Zeros here and it does seem somewhat faster, although I haven't timed it exactly since it's still too long to be sitting in front of a terminal with a stop watch. I bet there's some kind of scripting you can do to automate this. |
@rdmark There is no need for any scripting. You can simply run
to measure the time it takes. If I recall correctly, on my PC clang++ needs about 60% if the time required with g++. I have not compared the times on my Pi Zero. I hardly ever compile on it. Even with clang++ it is very slow. |
@uweseimet I was testing on my Buster system, and found that apt does provide a I'm building rascsi on Buster with |
@rdmark Sounds good. In that case clang++ is an option for everybody. @akuker Regarding the Makefile: I don't think we should make clang++ the default compiler. Something with clang++ is different when you create code metrics information. As far as I can tell gcov/lcov and maybe also the SonarCloud code metrics collection do not work anymore when using clang++. This requires additional research. For now having the option to use clang++ for those who cannot use g++ and for developers who know what they are doing should be fine. There is IMHO no need to go too far and break something. |
@rdmark Do you know whether there is also an option to use a newer g++ on buster and whether there are also even newer compilers optionally available on bullseys? I'm asking because of a bug in old gcc versions we cannot use the standard C++ filesystem library everywhere because it cannot deal with files > 2 GiB. Currently we have to use a Linux specific OS API for that. If newer compilers were available everywhere there might be a way to resolve this problem. |
Just checked bullseye: There is clang-13. (The current version is 15, by the way.) A quick test showed that at least the non-optimized binary appears to be fine when using clang++ 13 on bullseye. |
@uweseimet In Buster the latest available apt package is |
@rdmark I don't know for sure whether there are any bugs (I did not find any so far) and suggest that someone tests this. If there are so many users there should be some who are willing to help. I am less concerned about bugs but more about test coverage not working anymore when compiling with clang. At least on my machine gcov did not like the binaries created by clang, but without gcov there is no code analysis anymore . |
Compiling (optimized, non-debug) on a Pi Zero WH with an up to date bullseye (64 bit) with g++ results in internal errors or segfaults, whereas on buster (32 bit) everything is fine. With the same bullseys setup (same SD card) on a Pi 4 there are no issues, indicating that the limited hardware/memory of the Pi Zero causes problems with g++, at least with a 64 bit installation.
When using clang++ instead everything is fine. clang++ claims to use less memory, and it compiles faster than g++. The resulting binaries are working fine. This is why an option to use clang++ instead of g++ may be useful, so that clang++ is installed and make is run with "make CXX=clang++".
Alternative approach that does not require any option: Make clang++ the default compiler on Pis with bullseye and 512 MB RAM. (Using clang++ on buster does not work because it is outdated.) Maybe this should not even be optional, because clang++ may be the only working compiler anyway, and more options make easyinstall more complicated to use.
Yet another simple approach: On buster use g++, on bullseye use clang++.
The text was updated successfully, but these errors were encountered: