From 6b597a4b588aa49f6c6055042676a6299b9dad54 Mon Sep 17 00:00:00 2001 From: CC Date: Thu, 7 Jul 2022 10:48:07 -0600 Subject: [PATCH] builder: add support for icc (Intel C Compiler) (#14975) --- doc/docs.md | 4 ++-- vlib/v/builder/cc.v | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/docs.md b/doc/docs.md index 80ef078280..45514ccbd0 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -22,7 +22,7 @@ The major way to get the latest and greatest V, is to __install it from source__ It is __easy__, and it usually takes __only a few seconds__. ### Linux, macOS, FreeBSD, etc: -You need `git`, and a C compiler like `tcc`, `gcc` or `clang`, and `make`: +You need `git`, and a C compiler like `tcc`, `gcc`, `icc` or `clang`, and `make`: ```bash git clone https://github.com/vlang/v cd v @@ -38,7 +38,7 @@ git clone https://github.com/vlang/v cd v make.bat -tcc ``` -NB: You can also pass one of `-gcc`, `-msvc`, `-clang` to `make.bat` instead, +NB: You can also pass one of `-gcc`, `-msvc`, `-clang`, to `make.bat` instead, if you do prefer to use a different C compiler, but -tcc is small, fast, and easy to install (V will download a prebuilt binary automatically). diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index 94b556cacb..cfea5dc462 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -147,6 +147,7 @@ mut: debug_mode bool is_cc_tcc bool is_cc_gcc bool + is_cc_icc bool is_cc_msvc bool is_cc_clang bool // @@ -240,6 +241,7 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) { // ccoptions.is_cc_tcc = ccompiler.contains('tcc') || ccoptions.guessed_compiler == 'tcc' ccoptions.is_cc_gcc = ccompiler.contains('gcc') || ccoptions.guessed_compiler == 'gcc' + ccoptions.is_cc_icc = ccompiler.contains('icc') || ccoptions.guessed_compiler == 'icc' ccoptions.is_cc_msvc = ccompiler.contains('msvc') || ccoptions.guessed_compiler == 'msvc' ccoptions.is_cc_clang = ccompiler.contains('clang') || ccoptions.guessed_compiler == 'clang' // For C++ we must be very tolerant @@ -275,6 +277,15 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) { } optimization_options = ['-O3', '-fno-strict-aliasing', '-flto'] } + if ccoptions.is_cc_icc { + if ccoptions.debug_mode { + debug_options = ['-g'] + if user_darwin_version > 9 { + debug_options << '-no-pie' + } + } + optimization_options = ['-Ofast', '-fno-strict-aliasing'] + } // if ccoptions.debug_mode { ccoptions.args << debug_options