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

Changed the default C compiler used to build nim from gcc to clang #394

Closed
ghost opened this issue Jun 28, 2021 · 8 comments
Closed

Changed the default C compiler used to build nim from gcc to clang #394

ghost opened this issue Jun 28, 2021 · 8 comments

Comments

@ghost
Copy link

ghost commented Jun 28, 2021

Currently, Nim and its surrounding tools are built with gcc, but I would like to see this changed to building with clang.
On macOS/Linux, even gcc does not cause serious problems, but on Windows, the dependency on MinGW is a problem.

From my experience, it seems that products built with MinGW are more likely to be caught by virus signatures. And I'm also having a hard time facing the following problem.
(See also: nim-lang/Nim#17820)

VS2019 also allows you to optionally add a Clang layer, making it compatible with different operating systems but not requiring a dependency on MinGW.
(See also: https://docs.microsoft.com/en-us/cpp/build/clang-support-msbuild)

Please kindly consider this matter.

@Varriount
Copy link

Varriount commented Jun 28, 2021

It's quite possible to use Clang, rather than GCC, to compile Nim code. You either need to modify nim.cfg, or pass --cc:clang on the command line. I'll admit that there could be improvements here though - the build_all.bat file assumes GCC is being used, for example.

If you're suggesting that Clang be used by default, the problem is that Clang is a compiler, while MinGW is a compiler and SDK. Defaulting to Clang would require users to download the Windows SDK (which is several gigabytes in size, even without Visual Studio).

@rockcavera
Copy link

One of the reasons I chose Nim over Rust was the ease of installation on Windows. In other words, for Nim you only had to download the Nim compiler and install Mingw. As for Rust, you had to download an entire SDK and visual studio toolchain. If this change occurs for Clang, which by default uses msvc target and not mingw on Windows, I believe it will have this additional dependency.

I really like Clang and even use it, but Gcc on Windows is still the best option, in my opinion.

@juancarlospaco
Copy link
Contributor

Why not offer binaries built with both GCC and Clang, and let user choose...

@Varriount
Copy link

Why not offer binaries built with both GCC and Clang, and let user choose...

Assuming that the MinGW SDK is still being used, what benefit would the choice bring?

@ghost
Copy link
Author

ghost commented Jul 5, 2021

Due to lack of feedback from the Nim development team, the proposal will be temporarily withdrawn on July 10, 2021.

@Araq
Copy link
Member

Araq commented Jul 5, 2021

Well it's most important to me that the resulting binaries use a libc that comes preinstalled with Windows. If https://docs.microsoft.com/en-us/cpp/build/clang-support-msbuild can deliver that, I'm happy to use it instead.

(I'm part of the development team, so there is no need to withdraw the proposal.)

@ghost
Copy link
Author

ghost commented Jul 6, 2021

Thank you, @Araq.

If you have this component installed, you can run clang in the development console as well as MSBuild.
I rewrote the gcc specified in csources and nim.cfg to clang and tried to build it, and the binary was created without any errors.

However, please note that MSVC does not have unistd.h. This is a dependency of MinGW and needs to be resolved.

@rockcavera
Copy link

From my experience, it seems that products built with MinGW are more likely to be caught by virus signatures.

I had some extra time and compiled the Nim devel with vcc and clang. I uploaded all the executables (koch.exe, nim.exe, nimsuggest.exe, nimgrep.exe, vccexe.exe, nimpretty.exe, testament.exe, nim_dbg.exe and nimble.exe) to virustotal.com. In the same way that a false positive detection can occur when compiled with GCC, false positive detection occurred for both VCC and CLANG.

Therefore, there is no reason to change the compiler to avoid potential anti-virus detection of false positives. The problem is not there.

@ghost ghost closed this as completed Aug 3, 2021
This issue was closed.
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

No branches or pull requests

4 participants