diff options
Diffstat (limited to 'debian/patches/gcc-distro-specs.diff')
-rw-r--r-- | debian/patches/gcc-distro-specs.diff | 244 |
1 files changed, 244 insertions, 0 deletions
diff --git a/debian/patches/gcc-distro-specs.diff b/debian/patches/gcc-distro-specs.diff new file mode 100644 index 0000000..538954e --- /dev/null +++ b/debian/patches/gcc-distro-specs.diff @@ -0,0 +1,244 @@ +# DP: Add empty distro and hardening specs + +Index: gcc/gcc.c +=================================================================== +--- a/src/gcc/gcc.c (revision 270858) ++++ a/src/gcc/gcc.c (working copy) +@@ -27,6 +27,11 @@ + Once it knows which kind of compilation to perform, the procedure for + compilation is specified by a string called a "spec". */ + ++/* Inject some default compilation flags which are used as the default. ++ Done by the packaging build system. Should that be done in the headers ++ gcc/config/<arch>/*.h instead? */ ++#include "distro-defaults.h" ++ + #include "config.h" + #include "system.h" + #include "coretypes.h" +@@ -875,6 +880,69 @@ + #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}" + #endif + ++/* Generate full unwind information covering all program points. ++ Only needed for some architectures. */ ++#ifndef ASYNC_UNWIND_SPEC ++# ifdef DIST_DEFAULT_ASYNC_UNWIND ++# define ASYNC_UNWIND_SPEC "%{!fno-asynchronous-unwind-tables:-fasynchronous-unwind-tables}" ++# else ++# define ASYNC_UNWIND_SPEC "" ++# endif ++#endif ++ ++/* Turn on stack protector. ++ */ ++#ifndef SSP_DEFAULT_SPEC ++# ifdef DIST_DEFAULT_SSP ++# ifdef DIST_DEFAULT_SSP_STRONG ++# define SSP_DEFAULT_SPEC " %{!fno-stack-protector:%{!fstack-protector-all:%{!ffreestanding:%{!nostdlib:%{!fstack-protector:-fstack-protector-strong}}}}}" ++# else ++# define SSP_DEFAULT_SPEC " %{!fno-stack-protector:%{!fstack-protector-all:%{!ffreestanding:%{!nostdlib:-fstack-protector}}}}" ++# endif ++# else ++# define SSP_DEFAULT_SPEC "" ++# endif ++#endif ++ ++/* Turn on -Wformat -Wformat-security by default for C, C++, ++ ObjC, ObjC++. */ ++#ifndef FORMAT_SECURITY_SPEC ++# ifdef DIST_DEFAULT_FORMAT_SECURITY ++# define FORMAT_SECURITY_SPEC " %{!Wformat:%{!Wformat=2:%{!Wformat=0:%{!Wall:-Wformat} %{!Wno-format-security:-Wformat-security}}}}" ++# else ++# define FORMAT_SECURITY_SPEC "" ++# endif ++#endif ++ ++/* Enable -fstack-clash-protection by default. Only available ++ on some targets. */ ++#ifndef STACK_CLASH_SPEC ++# ifdef DIST_DEFAULT_STACK_CLASH ++# define STACK_CLASH_SPEC " %{!fno-stack-clash-protection:-fstack-clash-protection}" ++# else ++# define STACK_CLASH_SPEC "" ++# endif ++#endif ++ ++/* Enable code instrumentation of control-flow transfers. ++ Available on x86 and x86_64. */ ++#ifndef CF_PROTECTION_SPEC ++# ifdef DIST_DEFAULT_CF_PROTECTION ++# define CF_PROTECTION_SPEC " %{!fcf-protection*:%{!fno-cf-protection:-fcf-protection}}" ++# else ++# define CF_PROTECTION_SPEC "" ++# endif ++#endif ++ ++/* Don't enable any of those for the offload compilers, ++ unsupported. */ ++#if !defined(DISTRO_DEFAULT_SPEC) && !defined(ACCEL_COMPILER) ++# define DISTRO_DEFAULT_SPEC ASYNC_UNWIND_SPEC SSP_DEFAULT_SPEC \ ++ FORMAT_SECURITY_SPEC STACK_CLASH_SPEC CF_PROTECTION_SPEC ++#else ++# define DISTRO_DEFAULT_SPEC "" ++#endif ++ + #ifndef LINK_SSP_SPEC + #ifdef TARGET_LIBC_PROVIDES_SSP + #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ +@@ -1079,6 +1148,7 @@ + static const char *cc1_spec = CC1_SPEC; + static const char *cc1plus_spec = CC1PLUS_SPEC; + static const char *link_gcc_c_sequence_spec = LINK_GCC_C_SEQUENCE_SPEC; ++static const char *distro_default_spec = DISTRO_DEFAULT_SPEC; + static const char *link_ssp_spec = LINK_SSP_SPEC; + static const char *asm_spec = ASM_SPEC; + static const char *asm_final_spec = ASM_FINAL_SPEC; +@@ -1136,7 +1206,7 @@ + "%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\ + %{f*} %{g*:%{%:debug-level-gt(0):%{g*}\ + %{!fno-working-directory:-fworking-directory}}} %{O*}\ +- %{undef} %{save-temps*:-fpch-preprocess}"; ++ %{undef} %{save-temps*:-fpch-preprocess} %(distro_defaults)"; + + /* This contains cpp options which are not passed when the preprocessor + output will be used by another program. */ +@@ -1319,9 +1389,9 @@ + %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \ + %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\ + cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \ +- %(cc1_options)}\ ++ %(cc1_options)%(distro_defaults)}\ + %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\ +- cc1 %(cpp_unique_options) %(cc1_options)}}}\ ++ cc1 %(cpp_unique_options) %(cc1_options) %(distro_defaults)}}}\ + %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 1}, + {"-", + "%{!E:%e-E or -x required when input is from standard input}\ +@@ -1335,18 +1405,18 @@ + %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \ + %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\ + cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \ +- %(cc1_options)\ ++ %(cc1_options) %(distro_defaults)\ + %{!fsyntax-only:%{!S:-o %g.s} \ + %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}\ + %W{o*:--output-pch=%*}}%V}}\ + %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\ +- cc1 %(cpp_unique_options) %(cc1_options)\ ++ cc1 %(cpp_unique_options) %(cc1_options) %(distro_defaults)\ + %{!fsyntax-only:%{!S:-o %g.s} \ + %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}\ + %W{o*:--output-pch=%*}}%V}}}}}}}", 0, 0, 0}, + {".i", "@cpp-output", 0, 0, 0}, + {"@cpp-output", +- "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, ++ "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %(distro_defaults) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, + {".s", "@assembler", 0, 0, 0}, + {"@assembler", + "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 0, 0}, +@@ -1577,6 +1647,7 @@ + INIT_STATIC_SPEC ("cc1_options", &cc1_options), + INIT_STATIC_SPEC ("cc1plus", &cc1plus_spec), + INIT_STATIC_SPEC ("link_gcc_c_sequence", &link_gcc_c_sequence_spec), ++ INIT_STATIC_SPEC ("distro_defaults", &distro_default_spec), + INIT_STATIC_SPEC ("link_ssp", &link_ssp_spec), + INIT_STATIC_SPEC ("endfile", &endfile_spec), + INIT_STATIC_SPEC ("link", &link_spec), +Index: gcc/cp/lang-specs.h +=================================================================== +--- a/src/gcc/cp/lang-specs.h (revision 270858) ++++ a/src/gcc/cp/lang-specs.h (working copy) +@@ -47,7 +47,7 @@ + " cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed" + " %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}" + " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}" +- " %(cc1_options) %2" ++ " %(cc1_options) %(distro_defaults) %2" + " %{!fsyntax-only:%{!S:-o %g.s}" + " %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}" + " %W{o*:--output-pch=%*}}%V}}}}", +@@ -60,11 +60,11 @@ + " cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed" + " %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}" + " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}" +- " %(cc1_options) %2" ++ " %(cc1_options) %(distro_defaults) %2" + " %{!fsyntax-only:%(invoke_as)}}}}", + CPLUSPLUS_CPP_SPEC, 0, 0}, + {".ii", "@c++-cpp-output", 0, 0, 0}, + {"@c++-cpp-output", + "%{!E:%{!M:%{!MM:" +- " cc1plus -fpreprocessed %i %(cc1_options) %2" ++ " cc1plus -fpreprocessed %i %(cc1_options) %(distro_defaults) %2" + " %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, +Index: gcc/objc/lang-specs.h +=================================================================== +--- a/src/gcc/objc/lang-specs.h (revision 270858) ++++ a/src/gcc/objc/lang-specs.h (working copy) +@@ -29,9 +29,9 @@ + %{traditional|traditional-cpp:\ + %eGNU Objective C no longer supports traditional compilation}\ + %{save-temps*|no-integrated-cpp:cc1obj -E %(cpp_options) -o %{save-temps*:%b.mi} %{!save-temps*:%g.mi} \n\ +- cc1obj -fpreprocessed %{save-temps*:%b.mi} %{!save-temps*:%g.mi} %(cc1_options) %{print-objc-runtime-info} %{gen-decls}}\ ++ cc1obj -fpreprocessed %{save-temps*:%b.mi} %{!save-temps*:%g.mi} %(cc1_options) %(distro_defaults) %{print-objc-runtime-info} %{gen-decls}}\ + %{!save-temps*:%{!no-integrated-cpp:\ +- cc1obj %(cpp_unique_options) %(cc1_options) %{print-objc-runtime-info} %{gen-decls}}}\ ++ cc1obj %(cpp_unique_options) %(cc1_options) %(distro_defaults) %{print-objc-runtime-info} %{gen-decls}}}\ + %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, + {"@objective-c-header", + "%{E|M|MM:cc1obj -E %{traditional|traditional-cpp:-traditional-cpp}\ +@@ -40,11 +40,11 @@ + %{traditional|traditional-cpp:\ + %eGNU Objective C no longer supports traditional compilation}\ + %{save-temps*|no-integrated-cpp:cc1obj -E %(cpp_options) -o %{save-temps*:%b.mi} %{!save-temps*:%g.mi} \n\ +- cc1obj -fpreprocessed %b.mi %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\ ++ cc1obj -fpreprocessed %b.mi %(cc1_options) %(distro_defaults) %{print-objc-runtime-info} %{gen-decls}\ + -o %g.s %{!o*:--output-pch=%i.gch}\ + %W{o*:--output-pch=%*}%V}\ + %{!save-temps*:%{!no-integrated-cpp:\ +- cc1obj %(cpp_unique_options) %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\ ++ cc1obj %(cpp_unique_options) %(cc1_options) %(distro_defaults) %{print-objc-runtime-info} %{gen-decls}\ + -o %g.s %{!o*:--output-pch=%i.gch}\ + %W{o*:--output-pch=%*}%V}}}}}", 0, 0, 0}, + {".mi", "@objective-c-cpp-output", 0, 0, 0}, +@@ -53,5 +53,5 @@ + %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, + {"@objc-cpp-output", + "%nobjc-cpp-output is deprecated; please use objective-c-cpp-output instead\n\ +- %{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\ ++ %{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %(distro_defaults) %{print-objc-runtime-info} %{gen-decls}\ + %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, +Index: gcc/objcp/lang-specs.h +=================================================================== +--- a/src/gcc/objcp/lang-specs.h (revision 270858) ++++ a/src/gcc/objcp/lang-specs.h (working copy) +@@ -36,7 +36,7 @@ + %(cpp_options) %2 -o %{save-temps*:%b.mii} %{!save-temps*:%g.mii} \n}\ + cc1objplus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.mii} %{!save-temps*:%g.mii}}\ + %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\ +- %(cc1_options) %2\ ++ %(cc1_options) %(distro_defaults) %2\ + -o %g.s %{!o*:--output-pch=%i.gch} %W{o*:--output-pch=%*}%V}}}", + CPLUSPLUS_CPP_SPEC, 0, 0}, + {"@objective-c++", +@@ -46,16 +46,16 @@ + %(cpp_options) %2 -o %{save-temps*:%b.mii} %{!save-temps*:%g.mii} \n}\ + cc1objplus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.mii} %{!save-temps*:%g.mii}}\ + %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\ +- %(cc1_options) %2\ ++ %(cc1_options) %(distro_defaults) %2\ + %{!fsyntax-only:%(invoke_as)}}}}", + CPLUSPLUS_CPP_SPEC, 0, 0}, + {".mii", "@objective-c++-cpp-output", 0, 0, 0}, + {"@objective-c++-cpp-output", + "%{!M:%{!MM:%{!E:\ +- cc1objplus -fpreprocessed %i %(cc1_options) %2\ ++ cc1objplus -fpreprocessed %i %(cc1_options) %(distro_defaults) %2\ + %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, + {"@objc++-cpp-output", + "%nobjc++-cpp-output is deprecated; please use objective-c++-cpp-output instead\n\ + %{!M:%{!MM:%{!E:\ +- cc1objplus -fpreprocessed %i %(cc1_options) %2\ ++ cc1objplus -fpreprocessed %i %(cc1_options) %(distro_defaults) %2\ + %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, |