aboutsummaryrefslogtreecommitdiffstats
path: root/build/conf/compilers
diff options
context:
space:
mode:
authoralexv-smirnov <alex@ydb.tech>2023-06-13 11:05:01 +0300
committeralexv-smirnov <alex@ydb.tech>2023-06-13 11:05:01 +0300
commitbf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0 (patch)
tree1d1df72c0541a59a81439842f46d95396d3e7189 /build/conf/compilers
parent8bfdfa9a9bd19bddbc58d888e180fbd1218681be (diff)
downloadydb-bf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0.tar.gz
add ymake export to ydb
Diffstat (limited to 'build/conf/compilers')
-rw-r--r--build/conf/compilers/gnu_compiler.conf232
-rw-r--r--build/conf/compilers/msvc_compiler.conf90
-rw-r--r--build/conf/compilers/nvcc.conf3
3 files changed, 325 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..97e6f94abc
--- /dev/null
+++ b/build/conf/compilers/gnu_compiler.conf
@@ -0,0 +1,232 @@
+_OPTIMIZE_RELEASE=
+when ($_BUILD_RELEASE == "yes") {
+ 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
+ }
+ }
+ otherwise {
+ _OPTIMIZE_RELEASE=-O3
+ }
+}
+
+_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
+
+# 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
+}
+
+when ($ARCH_XTENSA == "yes") {
+ FSTACK=
+}
+
+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
+}
+# Though -w is intended to switch off all the warnings,
+# it does not switch at least -Wregister and -Wreserved-user-defined-literal under clang.
+#
+# Use -Wno-everything to force warning suppression.
+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
+}
+
+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
+ when ($ARCH_XTENSA == "yes") {
+ CL_DEBUG_INFO=
+ }
+ }
+ YASM_DEBUG_INFO=--replace=${ARCADIA_BUILD_ROOT}=/-B --replace=${ARCADIA_ROOT}=/-S --replace=$(TOOL_ROOT)=/-T ${env:"YASM_TEST_SUITE=1"}
+}
+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
+ when ($ARCH_XTENSA == "yes") {
+ CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=
+ }
+ }
+ YASM_DEBUG_INFO_DISABLE_CACHE__NO_UID__=--replace=${ARCADIA_BUILD_ROOT}=/-B --replace=${ARCADIA_ROOT}=/-S --replace=$(TOOL_ROOT)=/-T ${env:"YASM_TEST_SUITE=1"}
+}
+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
+ when ($ARCH_XTENSA == "yes") {
+ CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=
+ }
+ }
+ YASM_DEBUG_INFO_DISABLE_CACHE__NO_UID__=--replace=${ARCADIA_BUILD_ROOT}=/-B ${env:"YASM_TEST_SUITE=1"}
+}
+
+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}${COMPILE_OUT_SUFFIX}.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") && $_HAS_TIME_TRACE == "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=${hide;kv:"p CC"} ${hide;kv:"pc green"}
+_CPP_ARGS=\
+ $CLANG_TIDY_ARGS \
+ $YNDEXER_ARGS \
+ $RETRY_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 \
+ $RETRY_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
+
+_FORCE_CPP_FLAGS=-x c++
+
+_SRC_CPP_CMD=$_CPP_ARGS
+_SRC_C_CMD=$_C_ARGS
+_SRC_M_CMD=$SRC_c($SRC $SRCFLAGS)
+_SRC_MASM_CMD=$_EMPTY_CMD
diff --git a/build/conf/compilers/msvc_compiler.conf b/build/conf/compilers/msvc_compiler.conf
new file mode 100644
index 0000000000..a509b02348
--- /dev/null
+++ b/build/conf/compilers/msvc_compiler.conf
@@ -0,0 +1,90 @@
+MSVC_INLINE_OPTIMIZED=yes
+when ($MSVC_INLINE_OPTIMIZED == "yes") {
+ MSVC_INLINE_FLAG=/Zc:inline
+}
+when ($MSVC_INLINE_OPTIMIZED == "no") {
+ MSVC_INLINE_FLAG=/Zc:inline-
+}
+
+# Provide proper __cplusplus value
+# https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+_CXX_FLAGS=/Zc:__cplusplus
+
+_MSVC_ONLY_FLAGS=
+DEBUG_INFO_FLAGS=/Z7
+when ($IDE_MSVS == "yes") {
+ when ($CLANG_CL != "yes") {
+ _MSVC_ONLY_FLAGS=/FD /MP
+ }
+ DEBUG_INFO_FLAGS=/Zi /FS
+}
+
+# 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 $_MSVC_ONLY_FLAGS $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+=$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
+ when ($CLANG_CL == "yes") {
+ # Though /w is intended to switch off all the warnings,
+ # it does not switch at least -Wregister and -Wreserved-user-defined-literal under clang-cl.
+ #
+ # Use -Wno-everything to force warning suppression.
+ CXX_WARNING_OPTS=-Wno-everything
+ }
+ otherwise {
+ CXX_WARNING_OPTS=
+ }
+}
+
+when ($NO_OPTIMIZE == "yes") {
+ OPTIMIZE=/Od
+}
+
+SFDL_FLAG=/E /C /P /TP /Fi$SFDL_TMP_OUT
+WERROR_FLAG=/WX
+
+CL_WRAPPER=${FIX_MSVC_OUTPUT} cl
+ML_WRAPPER=${FIX_MSVC_OUTPUT} ml
+when ($_UNDER_WINE == "yes" && $CLANG_CL !="yes") {
+ CL_WRAPPER=
+ ML_WRAPPER=
+}
+
+_FORCE_CPP_FLAGS=/TP
+
+_SRC_C_NODEPS_CMD=${TOOLCHAIN_ENV} ${CL_WRAPPER} ${C_COMPILER} /c /Fo${OUTFILE} ${SRC} ${EXTRA_C_FLAGS} ${pre=/I :INC} ${CFLAGS} ${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} ${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} ${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 ${kv;hide:"p AS"} ${kv;hide:"pc yellow"}
diff --git a/build/conf/compilers/nvcc.conf b/build/conf/compilers/nvcc.conf
new file mode 100644
index 0000000000..12ea72eaa9
--- /dev/null
+++ b/build/conf/compilers/nvcc.conf
@@ -0,0 +1,3 @@
+when ($NO_COMPILER_WARNINGS == "yes") {
+ CUDA_NVCC_FLAGS += -w
+}