diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /build/conf/compilers | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'build/conf/compilers')
-rw-r--r-- | build/conf/compilers/gnu_compiler.conf | 470 | ||||
-rw-r--r-- | build/conf/compilers/msvc_compiler.conf | 294 |
2 files changed, 764 insertions, 0 deletions
diff --git a/build/conf/compilers/gnu_compiler.conf b/build/conf/compilers/gnu_compiler.conf new file mode 100644 index 0000000000..373be5bedd --- /dev/null +++ b/build/conf/compilers/gnu_compiler.conf @@ -0,0 +1,470 @@ +_C_DEFINES_ANDROID= +_C_DEFINES_ANDROID_OTHERWISE= +when ($OS_ANDROID == "yes") { + _C_DEFINES_ANDROID=-DANDROID_FAKEID=$ANDROID_FAKEID +} +otherwise { + # There is no usable _FILE_OFFSET_BITS=64 support in Androids until API 21. And it's incomplete until at least API 24. + # https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md + # Arcadia have API 16 for 32-bit Androids. + _C_DEFINES_ANDROID_OTHERWISE=-D_FILE_OFFSET_BITS=64 +} + +_C_DEFINES_GNU_SOURCE= +when ($OS_LINUX == "yes" || $OS_ANDROID == "yes" || $OS_CYGWIN == "yes") { + _C_DEFINES_GNU_SOURCE=-D_GNU_SOURCE +} + +_C_DEFINES_CLANG_LINUX_X86_64= +when ($CLANG == "yes" && $OS_LINUX == "yes" && $ARCH_X86_64 == "yes") { + _C_DEFINES_CLANG_LINUX_X86_64=-D_YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE +} + +_C_DEFINES_IOS= +when ($OS_IOS == "yes") { + _C_DEFINES_IOS=-D_XOPEN_SOURCE -D_DARWIN_C_SOURCE +} + +_C_DEFINES_WITH_VALGRIND= +when ($WITH_VALGRIND == "yes") { + _C_DEFINES_WITH_VALGRIND=-DWITH_VALGRIND=1 +} + +C_DEFINES =-DFAKEID=$CPP_FAKEID +C_DEFINES+=$_C_DEFINES_ANDROID +C_DEFINES+=\ +-DARCADIA_ROOT=${ARCADIA_ROOT} \ +-DARCADIA_BUILD_ROOT=${ARCADIA_BUILD_ROOT} \ +-D_THREAD_SAFE \ +-D_PTHREADS \ +-D_REENTRANT \ +-D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES \ +-D_LARGEFILE_SOURCE \ +-D__STDC_CONSTANT_MACROS \ +-D__STDC_FORMAT_MACROS +C_DEFINES+=$_C_DEFINES_ANDROID_OTHERWISE +C_DEFINES+=$_C_DEFINES_GNU_SOURCE +C_DEFINES+=$_C_DEFINES_CLANG_LINUX_X86_64 +C_DEFINES+=$_C_DEFINES_IOS +C_DEFINES+=$_C_DEFINES_WITH_VALGRIND +C_DEFINES+=$_C_DEFINES_NDEBUG + +_C_FOPTIONS_INIT_ARRAY= +when ($CLANG == "yes" && $OS_LINUX == "yes") { + # Use .init_array instead of .ctors (default for old clang versions) + # See: https://maskray.me/blog/2021-11-07-init-ctors-init-array + _C_FOPTIONS_INIT_ARRAY=-fuse-init-array +} + +_C_FOPTIONS_COLOR= +_C_FOPTIONS_ALIGNED_ALLOCATION= +when ($CLANG == "yes") { + # Set up output colorization + _C_FOPTIONS_COLOR=-fcolor-diagnostics + # Enable aligned allocation + _C_FOPTIONS_ALIGNED_ALLOCATION=-faligned-allocation +} +elsewhen ($GCC == "yes") { + # Set up output colorization + _C_FOPTIONS_COLOR=-fdiagnostics-color=always + # It looks like there is no way to enable aligned allocation in gcc +} + +_C_FOPTIONS_MAPSMOBI_ARM= +when ($OS_IOS == "yes") { + when ($MAPSMOBI_BUILD_TARGET == "yes" && $ARCH_ARM == "yes") { + _C_FOPTIONS_MAPSMOBI_ARM=-fembed-bitcode + } +} + +_C_WARNINGS_CLANG= +_CXX_WARNINGS_CLANG= +when ($CLANG == "yes") { + + _CXX_WARNINGS_CLANG=\ +-Wimport-preprocessor-directive-pedantic \ +-Wno-undefined-var-template \ +-Wno-return-std-move \ +-Wno-address-of-packed-member \ +-Wno-defaulted-function-deleted \ +-Wno-pessimizing-move \ +-Wno-range-loop-construct \ +-Wno-deprecated-anon-enum-enum-conversion \ +-Wno-deprecated-enum-enum-conversion \ +-Wno-deprecated-enum-float-conversion \ +-Wno-ambiguous-reversed-operator \ +-Wno-deprecated-volatile + +# -Wno-unknown-warning-option +# For nvcc to accept the above. + _C_WARNINGS_CLANG=\ +-Wno-implicit-const-int-float-conversion \ +-Wno-unknown-warning-option + +} + +_C_FOPTIONS_GCC= +when ($GCC == "yes") { + _C_FOPTIONS_GCC=-fno-delete-null-pointer-checks -fabi-version=8 +} + +_C_FOPTIONS_IOS= +when ($OS_IOS != "yes") { + # Split all functions and data into separate sections for DCE and ICF linker passes + # NOTE: iOS build uses -fembed-bitcode which conflicts with -ffunction-sections (only relevant for ELF targets) + _C_FOPTIONS_IOS=-ffunction-sections -fdata-sections +} + +_C_FOPTIONS_DEBUG= +when ($_BUILD_DEBUG == "yes") { + _C_FOPTIONS_DEBUG=$FSTACK +} + +_C_FLAGS_RELEASE= +_C_FOPTIONS_RELEASE= +_OPTIMIZE_RELEASE= +when ($_BUILD_RELEASE == "yes") { + _C_FLAGS_RELEASE=$OPTIMIZE + when ($_BUILD_SIZE_OPTIMIZED == "yes") { + # -Oz is clang's more size-aggressive version of -Os + # For ARM specifically, clang -Oz is on par with gcc -Os: + # https://github.com/android/ndk/issues/133#issuecomment-365763507 + when($CLANG == "yes") { + _OPTIMIZE_RELEASE=-Oz + } + otherwise { + _OPTIMIZE_RELEASE=-Os + } + + # Generate sections with address significance tables for ICF linker pass + when($CLANG == "yes") { + _C_FOPTIONS_RELEASE=-faddrsig + } + } + otherwise { + _OPTIMIZE_RELEASE=-O3 + } +} + +_C_FOPTIONS_PROFILER= +when ($_BUILD_PROFILER_TYPE != "") { + when ($_BUILD_PROFILER_TYPE in ["generic", "gprof"]) { + _C_FOPTIONS_PROFILER=-fno-omit-frame-pointer + } +} + +_C_FOPTIONS = + +# Enable C++ exceptions (and allow them to be throw through pure C code) +_C_FOPTIONS+=-fexceptions + +# Enable standard-conforming behavior and generate duplicate symbol error in case of duplicated global constants. +# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85678#c0 +_C_FOPTIONS+=-fno-common + +_C_FOPTIONS+=$_C_FOPTIONS_INIT_ARRAY +_C_FOPTIONS+=$_C_FOPTIONS_COLOR +_C_FOPTIONS+=$_C_FOPTIONS_ALIGNED_ALLOCATION +_C_FOPTIONS+=$_C_FOPTIONS_MAPSMOBI_ARM +_C_FOPTIONS+=$_C_FOPTIONS_DEBUG +_C_FOPTIONS+=$_C_FOPTIONS_RELEASE +_C_FOPTIONS+=$_C_FOPTIONS_PROFILER +_C_FOPTIONS+=$_C_FOPTIONS_GCC +_C_FOPTIONS+=$_C_FOPTIONS_IOS + +# Enable default warnings subset +_C_WARNINGS =-Wall -Wextra + +# Disable some warnings which will fail compilation at the time +_C_WARNINGS+=-Wno-parentheses + +_C_WARNINGS+=$_C_WARNINGS_CLANG + +# Issue a warning if certain overload is hidden due to inheritance +_CXX_WARNINGS =-Woverloaded-virtual + +_CXX_WARNINGS+=$_CXX_WARNINGS_CLANG + +_C_FLAGS_ARCH= +when ($ARCH_I386 == "yes") { + _C_FLAGS_ARCH=-m32 +} +when ($ARCH_X86_64 == "yes") { + _C_FLAGS_ARCH=-m64 +} + +_C_FLAGS_FAST_DEBUG= +when ($_BUILD_FAST_DEBUG == "yes") { + _C_FLAGS_FAST_DEBUG=-Og +} + +_C_DEFINES_NDEBUG=-UNDEBUG +when ($_BUILD_WITH_NDEBUG == "yes") { + _C_DEFINES_NDEBUG=-DNDEBUG +} + +_C_FLAGS_PROFILER= +when ($_BUILD_PROFILER_TYPE == "gprof") { + _C_FLAGS_PROFILER=-pg +} + +_C_FLAGS=\ +$CL_DEBUG_INFO $CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__ $_C_FLAGS_ARCH_OPT -pipe +_C_FLAGS+=$_C_FLAGS_ARCH +_C_FLAGS+=$_C_FLAGS_FAST_DEBUG +_C_FLAGS+=$_C_FLAGS_RELEASE +_C_FLAGS+=$_C_FLAGS_PROFILER + +_SFDL_FLAGS=-E -C -x c++ +when ($CLANG == "yes") { + _SFDL_FLAGS+=-Qunused-arguments +} + +_DEBUG_INFO_FLAGS=-g +when ($OS_LINUX == "yes") { + _DEBUG_INFO_FLAGS=-g -ggnu-pubnames +} + +_CROSS_SUFFIX=.pic +when ($FORCE_NO_PIC == "yes") { + _CROSS_SUFFIX= +} + +C_COMPILER=${quo:C_COMPILER_UNQUOTED} +OPTIMIZE=$_OPTIMIZE_RELEASE +FSTACK=-fstack-protector +DUMP_DEPS= +GCC_PREPROCESSOR_OPTS=$DUMP_DEPS $C_DEFINES +C_WARNING_OPTS=$_C_WARNINGS +CXX_WARNING_OPTS=$_CXX_WARNINGS + +# PIE is only valid for executables, while PIC implies a shared library +# `-pie` with a shared library is either ignored or fails to link +when ($PIC == "yes") { + CFLAGS+=-fPIC + LDFLAGS+=-fPIC +} +elsewhen ($PIE == "yes") { + CFLAGS+=-fPIE + LDFLAGS+=-fPIE -pie +} + +CFLAGS+=$_C_FLAGS $DEBUG_INFO_FLAGS $_C_FOPTIONS $C_WARNING_OPTS $GCC_PREPROCESSOR_OPTS $USER_CFLAGS $USER_CFLAGS_GLOBAL +CXXFLAGS+=$CFLAGS $_CXX_STD $CXX_WARNING_OPTS $USER_CXXFLAGS $USER_CXXFLAGS_GLOBAL +CONLYFLAGS+=$USER_CONLYFLAGS $USER_CONLYFLAGS_GLOBAL +CXX_COMPILER=${quo:CXX_COMPILER_UNQUOTED} +NOGCCSTACKCHECK=yes +SFDL_FLAG=$_SFDL_FLAGS -o $SFDL_TMP_OUT +WERROR_FLAG=-Werror +DEBUG_INFO_FLAGS=$_DEBUG_INFO_FLAGS + +when ($NO_WSHADOW == "yes") { + C_WARNING_OPTS += -Wno-shadow +} +when ($NO_COMPILER_WARNINGS == "yes") { + C_WARNING_OPTS = -w + CXX_WARNING_OPTS = -Wno-everything +} +when ($NO_OPTIMIZE == "yes") { + OPTIMIZE = -O0 +} +when ($SAVE_TEMPS == "yes") { + CXXFLAGS += -save-temps +} +when ($NOGCCSTACKCHECK != "yes") { + FSTACK += -fstack-check +} + +# _C_DEBUG_LIGHT=-fdebug-prefix-map=${ARCADIA_BUILD_ROOT}=/-B +# _C_DEBUG_LIGHT_CL=$_C_DEBUG_LIGHT -Xclang -fdebug-compilation-dir -Xclang /tmp +# _C_DEBUG=$_C_DEBUG_LIGHT -fdebug-prefix-map=${ARCADIA_ROOT}=/-S -fdebug-prefix-map=$(TOOL_ROOT)=/-T +# _C_DEBUG_CL=$_C_DEBUG -Xclang -fdebug-compilation-dir -Xclang /tmp +# _YASM_DEBUG_LIGHT=--replace=${ARCADIA_BUILD_ROOT}=/-B +# _YASM_DEBUG=$_YASM_DEBUG_LIGHT --replace=${ARCADIA_ROOT}=/-S --replace=$(TOOL_ROOT)=/-T +# when ($FORCE_CONSISTENT_DEBUG == "yes") { +# when ($CLANG == "yes") { +# CL_DEBUG_INFO=$_C_DEBUG_CL +# } +# otherwise { +# CL_DEBUG_INFO=$_C_DEBUG +# } +# YASM_DEBUG_INFO=$_YASM_DEBUG +# } +# elsewhen ($CONSISTENT_DEBUG == "yes") { +# when ($CLANG == "yes") { +# CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=$_C_DEBUG_CL +# } +# otherwise { +# CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=$_C_DEBUG +# } +# YASM_DEBUG_INFO_DISABLE_CACHE__NO_UID__=$_YASM_DEBUG +# } +# elsewhen ($CONSISTENT_DEBUG_LIGHT == "yes") { +# when ($CLANG == "yes") { +# CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=$_C_DEBUG_LIGHT_CL +# } +# otherwise { +# CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=$_C_DEBUG_LIGHT +# } +# YASM_DEBUG_INFO_DISABLE_CACHE__NO_UID__=$_YASM_DEBUG_LIGHT +# } +# +# _C_BUILTINS=-Wno-builtin-macro-redefined -D__DATE__="\"""Sep 31 2019""\"" -D__TIME__=\"00:00:00\" +# when ($CLANG == "yes" && $_TC_VERSION_AT_LEAST_10 || $GCC == "yes" && $_TC_VERSION_AT_LEAST_8 == "yes") { +# # XXX does not support non-normalized paths +# _C_BUILTINS+=-fmacro-prefix-map=${ARCADIA_BUILD_ROOT}/= -fmacro-prefix-map=${ARCADIA_ROOT}/= -fmacro-prefix-map=$(TOOL_ROOT)/= +# } +# otherwise { +# # XXX this macro substitution breaks __FILE__ in included sources +# _C_BUILTINS+=-D__FILE__=\"${input;qe;rootrel:SRC}\" +# } +# +# when ($FORCE_CONSISTENT_BUILD == "yes") { +# CL_MACRO_INFO=$_C_BUILTINS +# } +# elsewhen ($CONSISTENT_BUILD == "yes") { +# CL_MACRO_INFO_DISABLE_CACHE__NO_UID__=$_C_BUILTINS +# } + +when ($FORCE_CONSISTENT_DEBUG == "yes") { + when ($CLANG == "yes") { + CL_DEBUG_INFO=-fdebug-prefix-map=${ARCADIA_BUILD_ROOT}=/-B -fdebug-prefix-map=${ARCADIA_ROOT}=/-S -fdebug-prefix-map=$(TOOL_ROOT)=/-T -Xclang -fdebug-compilation-dir -Xclang /tmp + } + otherwise { + CL_DEBUG_INFO=-fdebug-prefix-map=${ARCADIA_BUILD_ROOT}=/-B -fdebug-prefix-map=${ARCADIA_ROOT}=/-S -fdebug-prefix-map=$(TOOL_ROOT)=/-T + } + YASM_DEBUG_INFO=--replace=${ARCADIA_BUILD_ROOT}=/-B --replace=${ARCADIA_ROOT}=/-S --replace=$(TOOL_ROOT)=/-T +} +elsewhen ($CONSISTENT_DEBUG == "yes") { + when ($CLANG == "yes") { + CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=-fdebug-prefix-map=${ARCADIA_BUILD_ROOT}=/-B -fdebug-prefix-map=${ARCADIA_ROOT}=/-S -fdebug-prefix-map=$(TOOL_ROOT)=/-T -Xclang -fdebug-compilation-dir -Xclang /tmp + } + otherwise { + CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=-fdebug-prefix-map=${ARCADIA_BUILD_ROOT}=/-B -fdebug-prefix-map=${ARCADIA_ROOT}=/-S -fdebug-prefix-map=$(TOOL_ROOT)=/-T + } + YASM_DEBUG_INFO_DISABLE_CACHE__NO_UID__=--replace=${ARCADIA_BUILD_ROOT}=/-B --replace=${ARCADIA_ROOT}=/-S --replace=$(TOOL_ROOT)=/-T +} +elsewhen ($CONSISTENT_DEBUG_LIGHT == "yes") { + when ($CLANG == "yes") { + CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=-fdebug-prefix-map=${ARCADIA_BUILD_ROOT}=/-B -Xclang -fdebug-compilation-dir -Xclang /tmp + } + otherwise { + CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=-fdebug-prefix-map=${ARCADIA_BUILD_ROOT}=/-B + } + YASM_DEBUG_INFO_DISABLE_CACHE__NO_UID__=--replace=${ARCADIA_BUILD_ROOT}=/-B +} + +when ($FORCE_CONSISTENT_BUILD == "yes") { + CL_MACRO_INFO=-Wno-builtin-macro-redefined -D__DATE__=\""Sep 31 2019\"" -D__TIME__=\"00:00:00\" -fmacro-prefix-map=${ARCADIA_BUILD_ROOT}/= -fmacro-prefix-map=${ARCADIA_ROOT}/= -fmacro-prefix-map=$(TOOL_ROOT)/= +} +elsewhen ($CONSISTENT_BUILD == "yes") { + CL_MACRO_INFO_DISABLE_CACHE__NO_UID__=-Wno-builtin-macro-redefined -D__DATE__=\""Sep 31 2019\"" -D__TIME__=\"00:00:00\" -fmacro-prefix-map=${ARCADIA_BUILD_ROOT}/= -fmacro-prefix-map=${ARCADIA_ROOT}/= -fmacro-prefix-map=$(TOOL_ROOT)/= +} + +_CFLAGS_ARCH_I386= +when ($ARCH_I386 == "yes" && $ARCH_I686 != "yes") { + _CFLAGS_ARCH_I386=-march=pentiumpro -mtune=pentiumpro +} + +CFLAGS+=$_CFLAGS_ARCH_I386 + +BC_CFLAGS+=$CFLAGS +BC_CXXFLAGS+=$CXXFLAGS +C_DEFINES+=-D__LONG_LONG_SUPPORTED + +OBJ_CROSS_SUF=$OBJ_SUF$_CROSS_SUFFIX +OBJECT_SUF=$OBJ_SUF$_CROSS_SUFFIX.o +GCC_COMPILE_FLAGS=$EXTRA_C_FLAGS -c -o $_COMPILE_OUTPUTS ${pre=-I:_C__INCLUDE} +EXTRA_COVERAGE_OUTPUT=${output;noauto;hide;suf=${OBJECT_SUF}.gcno:SRC} +CLANG_TIDY_OUTPUT_FILE=${output;noauto;suf=${OBJECT_SUF}.tidyjson:SRC} +YNDEXER_OUTPUT_FILE=${output;noauto;suf=${OBJECT_SUF}.ydx.pb2:SRC} + +when ($DUMP_COMPILER_DEPS == "yes") { + DUMP_DEPS=-MD ${output;hide;noauto;suf=${OBJ_SUF}.o.d:SRC} +} +elsewhen ($DUMP_COMPILER_DEPS_FAST == "yes") { + DUMP_DEPS=-E -M -MF ${output;noauto;suf=${OBJ_SUF}.o.d:SRC} +} + +_COMPILER_TIME_TRACE_GRANULARITY=500 +when ($TIME_TRACE_GRANULARITY && $TIME_TRACE_GRANULARITY != "") { + _COMPILER_TIME_TRACE_GRANULARITY=$TIME_TRACE_GRANULARITY +} + +_COMPILER_TIME_TRACE_FLAGS= +_COMPILER_TIME_TRACE_POSTPROCESS= +when (($TIME_TRACE == "yes" || $COMPILER_TIME_TRACE == "yes") && $CLANG == "yes" && $_TC_VERSION_AT_LEAST_9 == "yes") { + _COMPILER_TIME_TRACE_FLAGS=-ftime-trace -ftime-trace-granularity=$_COMPILER_TIME_TRACE_GRANULARITY + _COMPILER_TIME_TRACE_POSTPROCESS=$YMAKE_PYTHON ${input:"build/scripts/find_time_trace.py"} $_COMPILE_OUTPUTS $_COMPILE_TIME_TRACE_OUTPUTS +} + +_C_CPP_KV_STYLE=${requirements;hide:CC_REQUIREMENTS} ${hide;kv:"p CC"} ${hide;kv:"pc green"} +_CPP_ARGS=\ +$CLANG_TIDY_ARGS \ +$YNDEXER_ARGS \ +$CXX_COMPILER \ +$C_FLAGS_PLATFORM \ +$GCC_COMPILE_FLAGS \ +$CXXFLAGS \ +$CL_MACRO_INFO \ +$CL_MACRO_INFO_DISABLE_CACHE__NO_UID__ \ +$_COMPILER_TIME_TRACE_FLAGS \ +$EXTRA_OUTPUT \ +$SRCFLAGS \ +$_LANG_CFLAGS_VALUE \ +${input:SRC} \ +$TOOLCHAIN_ENV \ +$YNDEXER_OUTPUT \ +&& $_COMPILER_TIME_TRACE_POSTPROCESS \ +$_C_CPP_KV_STYLE + +_C_ARGS=\ +$CLANG_TIDY_ARGS \ +$YNDEXER_ARGS \ +$C_COMPILER \ +$C_FLAGS_PLATFORM \ +$GCC_COMPILE_FLAGS \ +$CFLAGS \ +$CL_MACRO_INFO \ +$CL_MACRO_INFO_DISABLE_CACHE__NO_UID__ \ +$_COMPILER_TIME_TRACE_FLAGS \ +$CONLYFLAGS \ +$EXTRA_OUTPUT \ +$SRCFLAGS \ +${input:SRC} \ +$TOOLCHAIN_ENV \ +$YNDEXER_OUTPUT \ +$_C_CPP_KV_STYLE + +### _SRC_C_NODEPS_CMD is obtained from _C_ARGS by filtering the following elements: +### ${input:SRC} +### $CL_MACRO_INFO +### $CL_MACRO_INFO_DISABLE_CACHE__NO_UID__ +### $CLANG_TIDY_ARGS +### $EXTRA_OUTPUT +### $EXTRA_COVERAGE_OUTPUT +### $SRCFLAGS +### $YNDEXER_ARGS +### $YNDEXER_OUTPUT +### +### $GCC_COMPILE_FLAGS is substituted for $EXTRA_C_FLAGS -c -o ${OUTFILE} ${SRC} ${pre=-I:INC} +_SRC_C_NODEPS_CMD=\ +$C_COMPILER \ +$C_FLAGS_PLATFORM \ +$EXTRA_C_FLAGS -c -o ${OUTFILE} ${SRC} ${pre=-I:INC} \ +$CFLAGS \ +$CONLYFLAGS \ +$TOOLCHAIN_ENV \ +$_C_CPP_KV_STYLE + +_SRC_CPP_CMD=$_CPP_ARGS +_SRC_C_CMD=$_C_ARGS +_SRC_M_CMD=$SRC_c($SRC $SRCFLAGS) +_SRC_MASM_CMD=$_EMPTY_CMD + +# fuzzing configuration +when ($CLANG == "yes") { + when ($_TC_VERSION_AT_LEAST_12 == "yes") { + LIBFUZZER_PATH=contrib/libs/libfuzzer12 + } +} diff --git a/build/conf/compilers/msvc_compiler.conf b/build/conf/compilers/msvc_compiler.conf new file mode 100644 index 0000000000..6667f35c5c --- /dev/null +++ b/build/conf/compilers/msvc_compiler.conf @@ -0,0 +1,294 @@ +_MSVC_MACRO=_WIN32_WINNT +_MSVC_WINDOWS7=0x0601 +_MSVC_WINDOWS8=0x0602 + +_MSVC_WARNS_ENABLED= +# 'expression' : signed/unsigned mismatch +_MSVC_WARNS_ENABLED+=/w14018 +# 'class' : class has virtual functions, but destructor is not virtual +_MSVC_WARNS_ENABLED+=/w14265 +# 'operator' : expression is always false +_MSVC_WARNS_ENABLED+=/w14296 +# missing type specifier - int assumed +_MSVC_WARNS_ENABLED+=/w14431 + +_MSVC_WARNS_AS_ERRORS= +# 'function' undefined; assuming extern returning int +_MSVC_WARNS_AS_ERRORS+=/we4013 + +_MSVC_WARNS_DISABLED= +# conditional expression is constant +_MSVC_WARNS_DISABLED+=/wd4127 +# nonstandard extension used : zero-sized array in struct/union +_MSVC_WARNS_DISABLED+=/wd4200 +# nonstandard extension used : nameless struct/union +_MSVC_WARNS_DISABLED+=/wd4201 +# elements of array will be default initialized +_MSVC_WARNS_DISABLED+=/wd4351 +# 'this' : used in base member initializer list +_MSVC_WARNS_DISABLED+=/wd4355 +# decorated name length exceeded, name was truncated +_MSVC_WARNS_DISABLED+=/wd4503 +# default constructor could not be generated +_MSVC_WARNS_DISABLED+=/wd4510 +# copy constructor could not be generated +_MSVC_WARNS_DISABLED+=/wd4511 +# assignment operator could not be generated +_MSVC_WARNS_DISABLED+=/wd4512 +# check operator precedence for possible error; use parentheses to clarify precedence +_MSVC_WARNS_DISABLED+=/wd4554 +# 'object' can never be instantiated - user defined constructor required +_MSVC_WARNS_DISABLED+=/wd4610 +# assignment within conditional expression +_MSVC_WARNS_DISABLED+=/wd4706 +# forcing value to bool 'true' or 'false' (performance warning) +_MSVC_WARNS_DISABLED+=/wd4800 +# The POSIX name for this item is deprecated +_MSVC_WARNS_DISABLED+=/wd4996 +# function marked as __forceinline not inlined +_MSVC_WARNS_DISABLED+=/wd4714 +# 'TAtomic' : top-level volatile in cast is ignored +_MSVC_WARNS_DISABLED+=/wd4197 +# 'initializing' : conversion from 'int' to 'ui32', signed/unsigned mismatch +_MSVC_WARNS_DISABLED+=/wd4245 +# 'ystd::function<void (uint8_t *)>': structure was padded due to alignment specifier +_MSVC_WARNS_DISABLED+=/wd4324 +# 'register' is no longer a supported storage class +_MSVC_WARNS_DISABLED+=/wd5033 + +_C_WARNINGS_CLANG_CL= +_CXX_WARNINGS_CLANG_CL= +_CXX_WARNINGS_CLANG_CL_2019= +_CXX_WARNINGS_CLANG_CL_2019_IDE_MSVS= +when ($CLANG_CL == "yes") { + _C_WARNINGS_CLANG_CL=\ +-Wno-absolute-value \ +-Wno-bitwise-op-parentheses \ +-Wno-dll-attribute-on-redeclaration \ +-Wno-extern-initializer \ +-Wno-format \ +-Wno-ignored-pragma-optimize \ +-Wno-inconsistent-dllimport \ +-Wno-int-conversion \ +-Wno-int-to-void-pointer-cast \ +-Wno-invalid-noreturn \ +-Wno-logical-op-parentheses \ +-Wno-macro-redefined \ +-Wno-parentheses \ +-Wno-pragma-pack \ +-Wno-tautological-constant-out-of-range-compare \ +-Wno-unknown-argument \ +-Wno-unknown-warning-option + + _CXX_WARNINGS_CLANG_CL=\ +-Woverloaded-virtual \ +-Wno-attributes + # IGNIETFERRO-722 needed for contrib + _CXX_WARNINGS_CLANG_CL+=-Wno-register + + _CXX_WARNINGS_CLANG_CL+=\ +-Wimport-preprocessor-directive-pedantic \ +-Wno-undefined-var-template + + when ($_TC_VERSION_AT_LEAST_2019 == "yes") { + _CXX_WARNINGS_CLANG_CL_2019=\ +-Wno-deprecated-volatile \ +-Wno-deprecated-anon-enum-enum-conversion \ +-Wno-defaulted-function-deleted \ +-Wno-deprecated-enum-enum-conversion \ +-Wno-ambiguous-reversed-operator \ +-Wno-deprecated-enum-float-conversion \ +-Wno-pointer-to-int-cast + } + + when ($IDE_MSVS == "yes") { + _CXX_WARNINGS_CLANG_CL_2019_IDE_MSVS=-Wno-unused-command-line-argument + } +} + +_C_WARNINGS =$_MSVC_WARNS_AS_ERRORS +_C_WARNINGS+=$_MSVC_WARNS_ENABLED +_C_WARNINGS+=$_MSVC_WARNS_DISABLED +_C_WARNINGS+=$_C_WARNINGS_CLANG_CL + +_CXX_WARNINGS = +_CXX_WARNINGS+=$_CXX_WARNINGS_CLANG_CL +_CXX_WARNINGS+=$_CXX_WARNINGS_CLANG_CL_2019 +_CXX_WARNINGS+=$_CXX_WARNINGS_CLANG_CL_2019_IDE_MSVS + +_WINAPI_UNICODE=no + +_DEFINES_ARCH= +when ($ARCH_X86_64 == "yes") { + _DEFINES_ARCH=/D_WIN64 /DWIN64 +} +elsewhen ($ARCH_ARMV7 == "yes") { + _DEFINES_ARCH=/D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE /D__arm__ +} + +_DEFINES_WIN32_WINNT=/D$_MSVC_MACRO=$_MSVC_WINDOWS7 + +when ($_WINAPI_UNICODE == "yes") { + _DEFINES_UNICODE=/DUNICODE /D_UNICODE +} +otherwise { + _DEFINES_UNICODE=/D_MBCS +} + +_C_DEFINES=\ +/DARCADIA_ROOT=${ARCADIA_ROOT} \ +/DARCADIA_BUILD_ROOT=${ARCADIA_BUILD_ROOT} \ +/DFAKEID=$CPP_FAKEID \ +/DWIN32 \ +/D_WIN32 \ +/D_WINDOWS \ +/D_CRT_SECURE_NO_WARNINGS \ +/D_CRT_NONSTDC_NO_WARNINGS \ +/D_USE_MATH_DEFINES \ +/D__STDC_CONSTANT_MACROS \ +/D__STDC_FORMAT_MACROS \ +/D_USING_V110_SDK71_ \ +/D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES \ +/DNOMINMAX \ +/DWIN32_LEAN_AND_MEAN + +_C_DEFINES+=$_DEFINES_ARCH +_C_DEFINES+=$_DEFINES_WIN32_WINNT +_C_DEFINES+=$_DEFINES_UNICODE + +C_DEFINES+=$_C_DEFINES + +_MSVC_FLAGS_CLANG= +_MSVC_FLAGS_CLANG_NO_WARNINGS= +_MSVC_FLAGS_CLANG_ARCH= +_MSVC_FLAGS_CLANG_EQ_2019= +when ($CLANG_CL == "yes") { + # -fcase-insensitive-paths + # Allow <windows.h> to be included via <Windows.h> in case-sensitive file-systems. + # + # -fno-common + # Enable standard-conforming behavior and generate duplicate symbol error in case of duplicated global constants. + # See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85678#c0 + _MSVC_FLAGS_CLANG=-fcase-insensitive-paths -fno-common + when ($ARCH_X86_64 == "yes") { + _MSVC_FLAGS_CLANG_ARCH=-m64 + } + elsewhen ($ARCH_I386 == "yes") { + _MSVC_FLAGS_CLANG_ARCH=-m32 + } + otherwise { + _MSVC_FLAGS_CLANG_ARCH= + } + + # Some warnings are getting triggered even when NO_COMPILER_WARNINGS is enabled + _MSVC_FLAGS_CLANG_NO_WARNINGS=-Wno-c++11-narrowing -Wno-register + + when ($_TC_VERSION_EXACTLY_2019 == "yes") { + # heretic: на момент коммита в нашей конфигурации указано, что тулчейн clang11-windows - аналог msvc 2019 + # https://a.yandex-team.ru/arc/trunk/arcadia/build/ya.conf.json?rev=r7910792#L2185 + # сам clang11 по дефолту представляется msvc2017 (#define _MSC_VER 1911 + # https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/clang11/lib/Driver/ToolChains/MSVC.cpp?rev=r7913127#L1352 + # вручную заставляем его представляться msvc2019 (#define _MSC_VER 1921) + # значение версии взято вот отсюда: + # https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/llvm11/include/llvm/Support/Compiler.h?blame=true&rev=r7913127#L89 + _MSVC_FLAGS_CLANG_EQ_2019=-fms-compatibility-version=19.21 + } +} + +_MSVC_FLAGS=/nologo /Zm500 /GR /bigobj /FC /EHs /errorReport:prompt $MSVC_INLINE_FLAG /utf-8 +# enable standard conforming mode +_MSVC_FLAGS+=/permissive- +_MSVC_FLAGS+=$_MSVC_FLAGS_ARCH_OPT +_MSVC_FLAGS+=$_MSVC_FLAGS_CLANG +_MSVC_FLAGS+=$_MSVC_FLAGS_CLANG_ARCH +_MSVC_FLAGS+=$_MSVC_FLAGS_CLANG_NO_WARNINGS +_MSVC_FLAGS+=$_MSVC_FLAGS_CLANG_EQ_2019 +_MSVC_FLAGS+=$_MSVC_FLAGS_INCLUDE + +MSVC_INLINE_OPTIMIZED=yes +when ($MSVC_INLINE_OPTIMIZED == "yes") { + MSVC_INLINE_FLAG=/Zc:inline +} +when ($MSVC_INLINE_OPTIMIZED == "no") { + MSVC_INLINE_FLAG=/Zc:inline- +} + +# Use builtin offsetof implementation +# instead of a crutcy macro defined in ucrt/stddef.h. +# The latter can not be used in constexpr statements. +_CXX_DEFINES=/D_CRT_USE_BUILTIN_OFFSETOF + +_FLAGS_C_ONLY= + +# Provide proper __cplusplus value +# https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +_CXX_FLAGS=/Zc:__cplusplus + +_FLAGS_MSVS_ONLY= +DEBUG_INFO_FLAGS=/Z7 +when ($IDE_MSVS == "yes") { + when ($CLANG_CL != "yes") { + _FLAGS_MSVS_ONLY=/FD /MP + } + DEBUG_INFO_FLAGS=/Zi /FS +} + +C_WARNING_OPTS=$_C_WARNINGS +CXX_WARNING_OPTS=$_CXX_WARNINGS + +# https://msdn.microsoft.com/en-us/library/abx4dbyh.aspx +when ($DLL_RUNTIME == "yes") { + _FLAGS_DEBUG_RUNTIME=/MDd + _FLAGS_RELEASE_RUNTIME=/MD +} +otherwise { + _FLAGS_DEBUG_RUNTIME=/MTd + _FLAGS_RELEASE_RUNTIME=/MT +} +CFLAGS_DEBUG=/Ob0 /Od /D_DEBUG $_FLAGS_DEBUG_RUNTIME +CFLAGS_RELEASE=/Ox /Ob2 /Oi /DNDEBUG $_FLAGS_RELEASE_RUNTIME + +MASMFLAGS= +_MASM_IO=/nologo /c /Fo${output;suf=${OBJECT_SUF}:SRC} ${input;msvs_source:SRC} +when ($ARCH_ARMV7) { + _MASM_IO=-o ${output;suf=${OBJECT_SUF}:SRC} ${input;msvs_source:SRC} +} + +OBJ_CROSS_SUF=$OBJ_SUF +OBJECT_SUF=$OBJ_SUF.obj + +CFLAGS+=$_MSVC_FLAGS $_FLAGS_MSVS_ONLY $CFLAGS_PER_TYPE $DEBUG_INFO_FLAGS $C_WARNING_OPTS $C_DEFINES $USER_CFLAGS $USER_CFLAGS_GLOBAL +CXXFLAGS+=$CFLAGS $_STD_CXX $_CXX_FLAGS $_CXX_DEFINES $CXX_WARNING_OPTS $USER_CXXFLAGS $USER_CXXFLAGS_GLOBAL +CONLYFLAGS+=$_FLAGS_C_ONLY $USER_CONLYFLAGS $USER_CONLYFLAGS_GLOBAL + +BC_CFLAGS+=$CFLAGS +BC_CXXFLAGS+=$BC_CFLAGS $CXXFLAGS + +CFLAGS+=$_CFLAGS_UCRT_VC_INCLUDES + +when ($NO_WSHADOW == "yes") { + C_WARNING_OPTS+=/wd4456 /wd4457 +} +when ($NO_COMPILER_WARNINGS == "yes") { + C_WARNING_OPTS=/w + CXX_WARNING_OPTS= +} +when ($NO_OPTIMIZE == "yes") { + OPTIMIZE=/Od +} + +SFDL_FLAG=/E /C /P /TP /Fi$SFDL_TMP_OUT +WERROR_FLAG=/WX + +CL_WRAPPER=${YMAKE_PYTHON} ${input:"build/scripts/fix_msvc_output.py"} cl +ML_WRAPPER=${YMAKE_PYTHON} ${input:"build/scripts/fix_msvc_output.py"} ml +when ($_UNDER_WINE == "yes") { + CL_WRAPPER= + ML_WRAPPER= +} + +_SRC_C_NODEPS_CMD=${TOOLCHAIN_ENV} ${CL_WRAPPER} ${C_COMPILER} /c /Fo${OUTFILE} ${SRC} ${EXTRA_C_FLAGS} ${pre=/I :INC} ${CFLAGS} ${requirements;hide:CC_REQUIREMENTS} ${hide;kv:"soe"} ${hide;kv:"p CC"} ${hide;kv:"pc yellow"} +_SRC_CPP_CMD=${TOOLCHAIN_ENV} ${CL_WRAPPER} ${CXX_COMPILER} /c /Fo$_COMPILE_OUTPUTS ${input;msvs_source:SRC} ${EXTRA_C_FLAGS} ${pre=/I :_C__INCLUDE} ${CXXFLAGS} ${SRCFLAGS} ${_LANG_CFLAGS_VALUE} ${requirements;hide:CC_REQUIREMENTS} ${hide;kv:"soe"} ${hide;kv:"p CC"} ${hide;kv:"pc yellow"} +_SRC_C_CMD=${TOOLCHAIN_ENV} ${CL_WRAPPER} ${C_COMPILER} /c /Fo$_COMPILE_OUTPUTS ${input;msvs_source:SRC} ${EXTRA_C_FLAGS} ${pre=/I :_C__INCLUDE} ${CFLAGS} ${CONLYFLAGS} ${SRCFLAGS} ${requirements;hide:CC_REQUIREMENTS} ${hide;kv:"soe"} ${hide;kv:"p CC"} ${hide;kv:"pc yellow"} +_SRC_M_CMD=$_EMPTY_CMD +_SRC_MASM_CMD=${cwd:ARCADIA_BUILD_ROOT} ${TOOLCHAIN_ENV} ${ML_WRAPPER} ${MASM_COMPILER} ${MASMFLAGS} ${SRCFLAGS} $_MASM_IO ${requirements;hide:CC_REQUIREMENTS} ${kv;hide:"p AS"} ${kv;hide:"pc yellow"} |