- Always use string pooling when building: this helps reducing the
size of the binaries due to string redundancy coming from the usage
of __FILE__ / __RELFILE__ in the debugging helper macros. Note also
that GCC builds use string pooling by default.
- Use suitable add_compile_flags() command.
- Add some explanative comments for some settings.
Some numbers (obtained with my local builds):
Before / After => Reduction
===========================
freeldr.sys : 443 KB ( 453.632 bytes) / 364 KB ( 372.736 bytes) => ~ 18%
win32k.sys : 1877 KB (1.922.048 bytes) / 1562 KB (1.599.488 bytes) => ~ 17%
ntoskrnl.exe : 2253 KB (2.307.072 bytes) / 1902 KB (1.947.136 bytes) => ~ 15.6%
kernel32.dll : 3008 KB (3.080.192 bytes) / 2906 KB (2.975.744 bytes) => ~ 3.4%
"Generate instructions for this CPU type. Specify one of:
k8 opteron athlon64 athlon-fx")
"Generate instructions for this CPU type. Specify one of:
k8 opteron athlon64 athlon-fx")
-set (OPTIMIZE "1" CACHE STRING
+set(OPTIMIZE "1" CACHE STRING
"What level of optimization to use.
0 = off
1 = Default option, optimize for size (-Os) with some additional options
"What level of optimization to use.
0 = off
1 = Default option, optimize for size (-Os) with some additional options
"Generate instructions for this CPU type. Specify one of:
armv5te armv7-a")
"Generate instructions for this CPU type. Specify one of:
armv5te armv7-a")
-set (OPTIMIZE "1" CACHE STRING
+set(OPTIMIZE "1" CACHE STRING
"What level of optimization to use.
0 = off
1 = Default option, optimize for size (-Os) with some additional options
"What level of optimization to use.
0 = off
1 = Default option, optimize for size (-Os) with some additional options
add_compile_flags("/Ox /Ob2 /Ot /Oy /GT /GF")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:REF /OPT:ICF")
elseif(OPTIMIZE STREQUAL "1")
add_compile_flags("/Ox /Ob2 /Ot /Oy /GT /GF")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:REF /OPT:ICF")
elseif(OPTIMIZE STREQUAL "1")
+ add_compile_flags("/O1")
elseif(OPTIMIZE STREQUAL "2")
elseif(OPTIMIZE STREQUAL "2")
+ add_compile_flags("/O2")
elseif(OPTIMIZE STREQUAL "3")
elseif(OPTIMIZE STREQUAL "3")
- add_definitions(/Ot /Ox /GS-)
+ add_compile_flags("/Ot /Ox /GS-")
elseif(OPTIMIZE STREQUAL "4")
elseif(OPTIMIZE STREQUAL "4")
- add_definitions(/Os /Ox /GS-)
+ add_compile_flags("/Os /Ox /GS-")
elseif(OPTIMIZE STREQUAL "5")
elseif(OPTIMIZE STREQUAL "5")
- add_definitions(/GF /Gy /Ob2 /Os /Ox /GS-)
+ add_compile_flags("/GF /Gy /Ob2 /Os /Ox /GS-")
+# Always use string pooling: this helps reducing the binaries size since a lot
+# of redundancy come from the usage of __FILE__ / __RELFILE__ in the debugging
+# helper macros. Note also that GCC builds use string pooling by default.
+add_compile_flags("/GF")
+
# Enable function level linking and comdat folding
add_compile_flags("/Gy")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:REF /OPT:ICF")
# Enable function level linking and comdat folding
add_compile_flags("/Gy")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:REF /OPT:ICF")
add_definitions(/Dinline=__inline /D__STDC__=1)
add_definitions(/Dinline=__inline /D__STDC__=1)
+# Ignore any "standard" include paths, and do not use any default CRT library.
if(NOT USE_CLANG_CL)
add_compile_flags("/X /Zl")
endif()
if(NOT USE_CLANG_CL)
add_compile_flags("/X /Zl")
endif()
-add_compile_flags("/GR- /EHs-c- /GS- /W3")
+# Disable RTTI, exception handling and buffer security checks by default.
+# These require run-time support that may not always be available.
+add_compile_flags("/GR- /EHs-c- /GS-")
if(USE_CLANG_CL)
set(CMAKE_CL_SHOWINCLUDES_PREFIX "Note: including file: ")
if(USE_CLANG_CL)
set(CMAKE_CL_SHOWINCLUDES_PREFIX "Note: including file: ")
add_compile_flags("/Zc:threadSafeInit-")
endif ()
add_compile_flags("/Zc:threadSafeInit-")
endif ()
+# Generate Warnings Level 3
+add_compile_flags("/W3")
+
# Disable overly sensitive warnings as well as those that generally aren't
# useful to us.
# - C4244: implicit integer truncation
# Disable overly sensitive warnings as well as those that generally aren't
# useful to us.
# - C4244: implicit integer truncation
# Add our library
if(MSVC_IDE)
add_library(${_libname} STATIC EXCLUDE_FROM_ALL ${_asm_stubs_file}.obj)
# Add our library
if(MSVC_IDE)
add_library(${_libname} STATIC EXCLUDE_FROM_ALL ${_asm_stubs_file}.obj)
- set_source_files_properties(${_asm_stubs_file}.obj PROPERTIES EXTERNAL_OBJECT 1)
+ set_source_files_properties(${_asm_stubs_file}.obj PROPERTIES EXTERNAL_OBJECT TRUE)
set_target_properties(${_libname} PROPERTIES LINKER_LANGUAGE "C")
else()
# NOTE: as stub file and def file are generated in one pass, depending on one is like depending on the other
set_target_properties(${_libname} PROPERTIES LINKER_LANGUAGE "C")
else()
# NOTE: as stub file and def file are generated in one pass, depending on one is like depending on the other
OUTPUT ${_preprocessed_asm_file} ${_object_file}
COMMAND cl /nologo /X /I${REACTOS_SOURCE_DIR}/sdk/include/asm /I${REACTOS_BINARY_DIR}/sdk/include/asm ${_directory_includes} ${_source_file_defines} ${_directory_defines} /D__ASM__ /D_USE_ML /EP /c ${_source_file_full_path} > ${_preprocessed_asm_file} && ${_pp_asm_compile_command}
DEPENDS ${_source_file_full_path})
OUTPUT ${_preprocessed_asm_file} ${_object_file}
COMMAND cl /nologo /X /I${REACTOS_SOURCE_DIR}/sdk/include/asm /I${REACTOS_BINARY_DIR}/sdk/include/asm ${_directory_includes} ${_source_file_defines} ${_directory_defines} /D__ASM__ /D_USE_ML /EP /c ${_source_file_full_path} > ${_preprocessed_asm_file} && ${_pp_asm_compile_command}
DEPENDS ${_source_file_full_path})
- set_source_files_properties(${_object_file} PROPERTIES EXTERNAL_OBJECT 1)
+ set_source_files_properties(${_object_file} PROPERTIES EXTERNAL_OBJECT TRUE)
list(APPEND ${_target} ${_object_file})
endforeach()
else()
list(APPEND ${_target} ${_object_file})
endforeach()
else()