diff options
author | Jack Lloyd <[email protected]> | 2015-10-26 14:12:23 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-10-26 14:12:23 -0400 |
commit | 54540244c1d89faa5b359c75a9c38b6fed0a08c9 (patch) | |
tree | 5725737a423af9a6224da7b060c385d886161fec | |
parent | 475a9dacb8d285d6e5a0244bcf816d2ae72a00a8 (diff) |
Remove the strange conjoining of debug and optimization flags.
Previously a build had optimizations disabled completely when debug info was
emitted. But there are many reasons to use optimized builds with debug symbols
(running under valgrind, against afl, with Asan/Ubsan, in prod, etc).
And personally I find even debugging at -O2 or -O3 is fine most of the time and
worth it for the speed. Use the (now documented!) --no-optimizations flag if no
optimization is desired while debugging.
This also removes the distinction between library and application compile flags;
there is a single optimization level that is probably good enough for everything.
On Win32 it removes definding _CONSOLE for the application. This seems to be
some mythical value that may have been required at some point, but is not
documented anywhere I can find. Who knows what VC thinks, hoping I don't have to
add this back. It also drops defining `EBUG` which is what happens when you
tell cl.exe to '/DEBUG'. LOL.
-rwxr-xr-x | configure.py | 66 | ||||
-rw-r--r-- | src/build-data/buildh.in | 2 | ||||
-rw-r--r-- | src/build-data/cc/clang.txt | 7 | ||||
-rw-r--r-- | src/build-data/cc/ekopath.txt | 7 | ||||
-rw-r--r-- | src/build-data/cc/gcc.txt | 9 | ||||
-rw-r--r-- | src/build-data/cc/hpcc.txt | 11 | ||||
-rw-r--r-- | src/build-data/cc/icc.txt | 7 | ||||
-rw-r--r-- | src/build-data/cc/msvc.txt | 17 | ||||
-rw-r--r-- | src/build-data/cc/pgi.txt | 7 | ||||
-rw-r--r-- | src/build-data/cc/sunstudio.txt | 7 | ||||
-rw-r--r-- | src/build-data/cc/xlc.txt | 7 | ||||
-rw-r--r-- | src/build-data/makefile/header.in | 13 |
12 files changed, 65 insertions, 95 deletions
diff --git a/configure.py b/configure.py index 1c6dfedc7..6536f3226 100755 --- a/configure.py +++ b/configure.py @@ -773,12 +773,9 @@ class CompilerInfo(object): 'add_lib_dir_option': '-L', 'add_lib_option': '-l', 'add_framework_option': '-framework ', - 'compile_flags_release': '', - 'compile_flags_debug': '', - 'lib_opt_flags_release': '', - 'lib_opt_flags_debug': '', - 'app_opt_flags_release': '', - 'app_opt_flags_debug': '', + 'compile_flags': '', + 'debug_info_flags': '', + 'optimization_flags': '', 'coverage_flags': '', 'sanitizer_flags': '', 'shared_flags': '', @@ -872,33 +869,23 @@ class CompilerInfo(object): return ' ' + abi_flags - """ - Return the optimization flags to use - """ - def opt_flags(self, who, options): + def cc_warning_flags(self, options): def gen_flags(): - if options.build_mode in ['debug', 'coverage']: - yield self.compile_flags_debug - else: - yield self.compile_flags_release + yield self.warning_flags + if options.maintainer_mode: + yield self.maintainer_warning_flags - if options.no_optimizations or options.build_mode == 'coverage': - return + return (' '.join(gen_flags())).strip() - if who == 'app': - if options.build_mode == 'release': - yield self.app_opt_flags_release - else: - yield self.app_opt_flags_debug - return - elif who == 'lib': - if options.build_mode == 'release': - yield self.lib_opt_flags_release - else: - yield self.lib_opt_flags_debug - return - else: - raise Exception("Invalid value of parameter 'who'.") + def cc_compile_flags(self, options): + def gen_flags(): + yield self.lang_flags + + if options.build_mode in ['debug', 'coverage', 'analyzer']: + yield self.debug_info_flags + + if not options.no_optimizations: + yield self.optimization_flags def submodel_fixup(flags, tup): return tup[0].replace('SUBMODEL', flags.replace(tup[1], '')) @@ -1146,12 +1133,13 @@ def gen_makefile_lists(var, build_config, options, modules, cc, arch, osinfo): """ def build_commands(sources, obj_dir, flags): for (obj_file,src) in zip(objectfile_list(sources, obj_dir), sources): - yield '%s: %s\n\t$(CXX)%s $(%s_FLAGS) %s%s %s %s$@\n' % ( + yield '%s: %s\n\t$(CXX)%s $(%s_FLAGS) %s%s %s %s %s$@\n' % ( obj_file, src, isa_specific_flags(cc, src), flags, cc.add_include_dir_option, build_config.include_dir, + cc.compile_flags, src, cc.output_to_option) @@ -1216,14 +1204,6 @@ def create_template_vars(build_config, options, modules, cc, arch, osinfo): return os.path.join(options.with_build_dir, path) return path - def warning_flags(normal_flags, - maintainer_flags, - maintainer_mode): - if maintainer_mode and maintainer_flags != '': - return normal_flags + ' ' + maintainer_flags - else: - return normal_flags - def innosetup_arch(os, arch): if os == 'windows': inno_arch = { 'x86_32': '', 'x86_64': 'x64', 'ia64': 'ia64' } @@ -1298,12 +1278,8 @@ def create_template_vars(build_config, options, modules, cc, arch, osinfo): 'cxx': (options.compiler_binary or cc.binary_name) + cc.mach_abi_link_flags(options), 'linker': cc.linker_name or '$(CXX)', - 'lib_opt': cc.opt_flags('lib', options), - 'app_opt': cc.opt_flags('app', options), - 'lang_flags': cc.lang_flags, - 'warn_flags': warning_flags(cc.warning_flags, - cc.maintainer_warning_flags, - options.maintainer_mode), + 'cc_compile_flags': cc.cc_compile_flags(options), + 'cc_warning_flags': cc.cc_warning_flags(options), 'shared_flags': cc.gen_shared_flags(options), 'visibility_attribute': cc.gen_visibility_attribute(options), diff --git a/src/build-data/buildh.in b/src/build-data/buildh.in index 3061c9608..23bb86e20 100644 --- a/src/build-data/buildh.in +++ b/src/build-data/buildh.in @@ -6,7 +6,7 @@ * %{user}@%{hostname} running '%{command_line}' * * Target -* - Compiler: %{cxx} %{lib_opt} +* - Compiler: %{cxx} %{cc_compile_flags} * - Arch: %{submodel}/%{arch} * - OS: %{os} */ diff --git a/src/build-data/cc/clang.txt b/src/build-data/cc/clang.txt index 129218dcd..fd11e59ec 100644 --- a/src/build-data/cc/clang.txt +++ b/src/build-data/cc/clang.txt @@ -13,10 +13,9 @@ lang_flags "-std=c++11 -D_REENTRANT -fstack-protector" warning_flags "-Wall -Wextra -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wunreachable-code" maintainer_warning_flags "-Qunused-arguments -Werror -Wno-error=unused-parameter -Wno-error=unused-variable -Wno-error=unreachable-code" -compile_flags_release "-c" -compile_flags_debug "-c -g" -lib_opt_flags_release "-O3" -app_opt_flags_release "-O2" +compile_flags "-c" +debug_info_flags "-g" +optimization_flags "-O3" shared_flags "-fPIC" coverage_flags "--coverage" diff --git a/src/build-data/cc/ekopath.txt b/src/build-data/cc/ekopath.txt index a41abc7c4..549c21a23 100644 --- a/src/build-data/cc/ekopath.txt +++ b/src/build-data/cc/ekopath.txt @@ -7,10 +7,9 @@ add_include_dir_option -I add_lib_dir_option -L add_lib_option -l -compile_flags_release "-c" -compile_flags_debug "-c -g" -lib_opt_flags_release "-O3 -OPT:Ofast:alias=disjoint" -app_opt_flags_release "-O2" +compile_flags "-c" +debug_info_flags "-g" +optimization_flags "-O3" lang_flags "-D_REENTRANT -ansi -Wno-long-long" warning_flags "-W -Wall" diff --git a/src/build-data/cc/gcc.txt b/src/build-data/cc/gcc.txt index 4eacacef2..3531e9355 100644 --- a/src/build-data/cc/gcc.txt +++ b/src/build-data/cc/gcc.txt @@ -11,12 +11,9 @@ lang_flags "-std=c++11 -D_REENTRANT" maintainer_warning_flags "-Wold-style-cast -Werror -Wno-error=old-style-cast -Wno-error=zero-as-null-pointer-constant -Wno-error=unused-parameter -Wno-error=unused-variable -Wno-error=strict-overflow" warning_flags "-Wall -Wextra -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant" -compile_flags_release "-c" -compile_flags_debug "-c -g" -lib_opt_flags_release "-O2" -lib_opt_flags_debug "-O0" -app_opt_flags_release "-O2" -app_opt_flags_debug "-O0" +compile_flags "-c" +debug_info_flags "-g" +optimization_flags "-O2" shared_flags "-fPIC" coverage_flags "--coverage" diff --git a/src/build-data/cc/hpcc.txt b/src/build-data/cc/hpcc.txt index 2e30995f6..2f2686d10 100644 --- a/src/build-data/cc/hpcc.txt +++ b/src/build-data/cc/hpcc.txt @@ -7,13 +7,12 @@ add_include_dir_option -I add_lib_dir_option -L add_lib_option -l -compile_flags_release "-c" -compile_flags_debug "-c -g" -lib_opt_flags_release "+O2" -app_opt_flags_release "+O2" - lang_flags "-AA -ext +eh -z" -warning_flags "" # +w + +compile_flags "-c" +debug_info_flags "-g" +optimization_flags "+O2" +warning_flags "+w" shared_flags "+Z" makefile_style gmake diff --git a/src/build-data/cc/icc.txt b/src/build-data/cc/icc.txt index f7fdf72be..084d2a4f2 100644 --- a/src/build-data/cc/icc.txt +++ b/src/build-data/cc/icc.txt @@ -7,10 +7,9 @@ add_include_dir_option -I add_lib_dir_option -L add_lib_option -l -compile_flags_release "-c -fomit-frame-pointer" -compile_flags_debug "-c -g" -lib_opt_flags_release "-O2 -ip -unroll" -app_opt_flags_release "-O2" +compile_flags "-c" +debug_info_flags "-g" +optimization_flags "-O2" lang_flags "-std=c++0x" warning_flags "-w1" diff --git a/src/build-data/cc/msvc.txt b/src/build-data/cc/msvc.txt index 7a35f9648..67e5023aa 100644 --- a/src/build-data/cc/msvc.txt +++ b/src/build-data/cc/msvc.txt @@ -8,10 +8,15 @@ add_include_dir_option "/I" add_lib_dir_option -L add_lib_option "" -compile_flags_release "/nologo /c /bigobj /O2" -compile_flags_debug "/nologo /c /bigobj /Od /Zi /FS /DEBUG" -app_opt_flags_release "/D_CONSOLE" -app_opt_flags_debug "/D_CONSOLE" +compile_flags "/nologo /c" + +optimization_flags "/O2" + +# for debug info in the object file: +#debug_info_flags "/Z7" + +# for using a PDB file: +debug_info_flags "/Zi /FS" lang_flags "/EHs /GR" warning_flags "/W3 /wd4275 /wd4267" @@ -46,6 +51,6 @@ default-debug -> "$(LINKER) /DEBUG" </binary_link_commands> <mach_abi_linking> -all -> "/MD" -all-debug -> "/MDd" +all -> "/MD /bigobj" +all-debug -> "/MDd /bigobj" </mach_abi_linking> diff --git a/src/build-data/cc/pgi.txt b/src/build-data/cc/pgi.txt index ca4b49cd9..06b2f8400 100644 --- a/src/build-data/cc/pgi.txt +++ b/src/build-data/cc/pgi.txt @@ -7,10 +7,9 @@ add_include_dir_option -I add_lib_dir_option -L add_lib_option -l -compile_flags_release "-c" -compile_flags_debug "-c" -lib_opt_flags_release "-fast -Minline" -app_opt_flags_release "-fast" +compile_flags "-c" +debug_info_flags "-g" +optimization_flags "-fast -Minline" shared_flags "-fPIC" makefile_style gmake diff --git a/src/build-data/cc/sunstudio.txt b/src/build-data/cc/sunstudio.txt index 964c878ff..9ace5107c 100644 --- a/src/build-data/cc/sunstudio.txt +++ b/src/build-data/cc/sunstudio.txt @@ -7,10 +7,9 @@ add_include_dir_option -I add_lib_dir_option -L add_lib_option -l -compile_flags_release "-c" -compile_flags_debug "-c -g" -lib_opt_flags_release "-xO5" -app_opt_flags_release "-xO2" +compile_flags "-c" +debug_info_flags "-g" +optimization_flags "-xO2" shared_flags "-KPIC" warning_flags "+w -erroff=truncwarn,wnoretvalue" diff --git a/src/build-data/cc/xlc.txt b/src/build-data/cc/xlc.txt index 68dc62582..55b9e7092 100644 --- a/src/build-data/cc/xlc.txt +++ b/src/build-data/cc/xlc.txt @@ -7,10 +7,9 @@ add_include_dir_option -I add_lib_dir_option -L add_lib_option -l -compile_flags_release "-c" -compile_flags_debug "-c -g" -lib_opt_flags_release "-O2" -app_opt_flags_release "-O2" +compile_flags "-c" +debug_info_flags "-g" +optimization_flags "-O2" lang_flags "" diff --git a/src/build-data/makefile/header.in b/src/build-data/makefile/header.in index a83184bb8..3c4272d05 100644 --- a/src/build-data/makefile/header.in +++ b/src/build-data/makefile/header.in @@ -1,10 +1,9 @@ # Compiler Options CXX = %{cxx} LINKER = %{linker} -LIB_OPT = %{lib_opt} -APP_OPT = %{app_opt} -LANG_FLAGS = %{lang_flags} -WARN_FLAGS = %{warn_flags} + +CXXFLAGS = %{cc_compile_flags} +WARN_FLAGS = %{cc_warning_flags} SO_OBJ_FLAGS = %{shared_flags} LIB_LINK_CMD = %{lib_link_cmd} @@ -15,9 +14,9 @@ LIB_LINKS_TO = %{link_to} APP_LINKS_TO = $(LIB_LINKS_TO) TEST_LINKS_TO = $(LIB_LINKS_TO) -LIB_FLAGS = $(SO_OBJ_FLAGS) $(LANG_FLAGS) $(LIB_OPT) $(WARN_FLAGS) -APP_FLAGS = $(LANG_FLAGS) $(APP_OPT) $(WARN_FLAGS) -TEST_FLAGS = $(LANG_FLAGS) $(APP_OPT) $(WARN_FLAGS) +LIB_FLAGS = $(SO_OBJ_FLAGS) $(CXXFLAGS) $(WARN_FLAGS) +APP_FLAGS = $(CXXFLAGS) $(WARN_FLAGS) +TEST_FLAGS = $(CXXFLAGS) $(WARN_FLAGS) SCRIPTS_DIR = %{scripts_dir} |