From: Konstantin Demin rockdrilla@gmail.com
Signed-off-by: Konstantin Demin rockdrilla@gmail.com --- tools/makedep.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
diff --git a/tools/makedep.c b/tools/makedep.c index 3fe2d254fdf..05360bdda91 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -32,6 +32,7 @@ #include <sys/stat.h>
#include "tools.h" +#include "lto.h" #include "wine/list.h"
enum incl_type @@ -245,6 +246,7 @@ static const char *temp_file_name; static char cwd[PATH_MAX]; static int compile_commands_mode; static int silent_rules; +static int with_lto = 0; static int input_line; static int output_column; static FILE *output_file; @@ -273,6 +275,10 @@ static void fatal_perror( const char *msg, ... ) __attribute__ ((__format__ (__p static void output( const char *format, ... ) __attribute__ ((__format__ (__printf__, 1, 2))); static char *strmake( const char* fmt, ... ) __attribute__ ((__format__ (__printf__, 1, 2)));
+static void output_lto_flags_source( struct makefile *make, struct incl_file *source, unsigned int arch, + int prefer_env ); +static void output_lto_flags_target( struct makefile *make, unsigned int arch, int prefer_env ); + /******************************************************************* * fatal_error */ @@ -2478,6 +2484,7 @@ static void output_winegcc_command( struct makefile *make, unsigned int arch ) output_filename( "--winebuild" ); output_filename( tools_path( make, "winebuild" )); } + output_lto_flags_target( make, arch, 0 /* generic LTO flags */ ); output_filenames( target_flags[arch] ); if (native_archs[arch] && !make->disabled[native_archs[arch]]) output_filenames( hybrid_target_flags[arch] ); @@ -3299,6 +3306,7 @@ static void output_source_one_arch( struct makefile *make, struct incl_file *sou output_filenames( defines ); output_filenames( cflags ); output_filename( var_cflags ); + output_lto_flags_source( make, source, arch, 1 /* prefer flags from env */ ); output( "\n" );
if (make->testdll && strendswith( source->name, ".c" ) && @@ -3573,6 +3581,7 @@ static void output_import_lib( struct makefile *make, unsigned int arch ) if (hybrid_arch) output_filenames_obj_dir( make, make->implib_files[hybrid_arch] ); output( "\n" ); output( "\t%s%s -w --implib -o $@", cmd_prefix( "BUILD" ), tools_path( make, "winebuild" ) ); + output_lto_flags_target( make, arch, 0 /* generic LTO flags */ ); if (!delay_load_flags[arch]) output_filename( "--without-dlltool" ); output_filenames( target_flags[hybrid_arch ? hybrid_arch : arch] ); if (make->is_win16) output_filename( "-m16" ); @@ -3608,6 +3617,7 @@ static void output_unix_lib( struct makefile *make ) output( "\n" ); output( "\t%s$(CC) -o $@", cmd_prefix( "CCLD" )); output_filenames( get_expanded_make_var_array( make, "UNIXLDFLAGS" )); + output_lto_flags_target( make, arch, 1 /* prefer flags from env */ ); output_filenames_obj_dir( make, make->unixobj_files ); output_filenames( unix_libs ); output_filename( "$(LDFLAGS)" ); @@ -3634,6 +3644,7 @@ static void output_static_lib( struct makefile *make, unsigned int arch ) output( "\n" ); output( "\t%s%s -w --staticlib -o $@", cmd_prefix( "BUILD" ), tools_path( make, "winebuild" )); output_filenames( target_flags[hybrid_arch ? hybrid_arch : arch] ); + output_lto_flags_target( make, arch, 0 /* generic LTO flags */ ); output_filenames_obj_dir( make, make->object_files[arch] ); if (hybrid_arch) output_filenames_obj_dir( make, make->object_files[hybrid_arch] ); if (!arch) output_filenames_obj_dir( make, make->unixobj_files ); @@ -3758,6 +3769,7 @@ static void output_programs( struct makefile *make ) output_filenames( deps ); output( "\n" ); output( "\t%s$(CC) -o $@", cmd_prefix( "CCLD" )); + output_lto_flags_target( make, arch, 1 /* prefer flags from env */ ); output_filenames_obj_dir( make, objs ); output_filenames( all_libs ); output_filename( "$(LDFLAGS)" ); @@ -4596,6 +4608,9 @@ static int parse_option( const char *opt ) case 'S': silent_rules = 1; break; + case 'L': + with_lto = 1; + break; default: fprintf( stderr, "Unknown option '%s'\n%s", opt, Usage ); exit(1); @@ -4615,6 +4630,47 @@ static unsigned int find_pe_arch( const char *arch ) }
+/******************************************************************* + * output_lto_flags + */ +static void output_lto_flags( int use_lto, int prefer_env ) +{ + struct strarray lto_flags = empty_strarray; + append_lto_flags( <o_flags, use_lto, prefer_env ); + output_filenames( lto_flags ); +} + + +/******************************************************************* + * output_lto_flags_source + */ +static void output_lto_flags_source( struct makefile *make, struct incl_file *source, unsigned int arch, + int prefer_env ) +{ + if (!with_lto) return; + if (!make) return; + if (!source) return; + + (void) arch; /* mark as used */ + + output_lto_flags( with_lto, prefer_env ); +} + + +/******************************************************************* + * output_lto_flags_target + */ +static void output_lto_flags_target( struct makefile *make, unsigned int arch, int prefer_env ) +{ + if (!with_lto) return; + if (!make) return; + + (void) arch; /* mark as used */ + + output_lto_flags( with_lto, prefer_env ); +} + + /******************************************************************* * main */