dotfiles/pkgs/osu-wine/patches/0002-revert-mscvrt-ify-modules.patch
2024-05-15 08:35:49 +07:00

199 lines
7.9 KiB
Diff

--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -199,6 +199,7 @@
const char *staticlib;
const char *importlib;
const char *unixlib;
+ int use_msvcrt;
int data_only;
int is_win16;
int is_exe;
@@ -602,17 +603,6 @@
/*******************************************************************
- * is_using_msvcrt
- *
- * Check if the files of a makefile use msvcrt by default.
- */
-static int is_using_msvcrt( struct makefile *make )
-{
- return make->module || make->testdll;
-}
-
-
-/*******************************************************************
* arch_module_name
*/
static char *arch_module_name( const char *module, unsigned int arch )
@@ -870,7 +860,7 @@
file->basename = xstrdup( filename ? filename : name );
file->filename = obj_dir_path( make, file->basename );
file->file->flags = FLAG_GENERATED;
- file->use_msvcrt = is_using_msvcrt( make );
+ file->use_msvcrt = make->use_msvcrt;
list_add_tail( &make->sources, &file->entry );
if (make == include_makefile)
{
@@ -1620,7 +1610,7 @@
memset( file, 0, sizeof(*file) );
file->name = xstrdup(name);
- file->use_msvcrt = is_using_msvcrt( make );
+ file->use_msvcrt = make->use_msvcrt;
file->is_external = !!make->extlib;
list_add_tail( &make->sources, &file->entry );
if (make == include_makefile)
@@ -1818,12 +1808,13 @@
unsigned int i, arch;
struct incl_file *source, *next, *file, *dlldata = NULL;
struct strarray objs = get_expanded_make_var_array( make, "EXTRA_OBJS" );
+ int multiarch = archs.count > 1 && make->use_msvcrt;
LIST_FOR_EACH_ENTRY_SAFE( source, next, &make->sources, struct incl_file, entry )
{
for (arch = 0; arch < archs.count; arch++)
{
- if (!is_multiarch( arch )) continue;
+ if (!arch != !multiarch) continue;
if (source->file->flags & FLAG_IDL_CLIENT)
{
file = add_generated_source( make, replace_extension( source->name, ".idl", "_c.c" ), NULL, arch );
@@ -1942,7 +1933,7 @@
{
for (arch = 0; arch < archs.count; arch++)
{
- if (!is_multiarch( arch )) continue;
+ if (!arch != !multiarch) continue;
file = add_generated_source( make, "testlist.o", "testlist.c", arch );
add_dependency( file->file, "wine/test.h", INCL_NORMAL );
add_all_includes( make, file, file->file );
@@ -2196,6 +2187,7 @@
*/
static const char *get_default_crt( const struct makefile *make )
{
+ if (!make->use_msvcrt) return NULL;
if (make->module && is_crt_module( make->module )) return NULL; /* don't add crt import to crt dlls */
return !make->testdll && (!make->staticlib || make->extlib) ? "ucrtbase" : "msvcrt";
}
@@ -2352,7 +2344,6 @@
strarray_add( &ret, strmake( "-I%s", root_src_dir_path( "include/msvcrt" )));
for (i = 0; i < make->include_paths.count; i++)
strarray_add( &ret, strmake( "-I%s", make->include_paths.str[i] ));
- strarray_add( &ret, get_crt_define( make ));
}
strarray_addall( &ret, make->define_args );
strarray_addall( &ret, get_expanded_file_local_var( make, obj, "EXTRADEFS" ));
@@ -2412,9 +2403,7 @@
output_filename( tools_path( make, "winebuild" ));
}
output_filenames( target_flags[arch] );
- if (arch) return;
- output_filename( "-mno-cygwin" );
- output_filenames( lddll_flags );
+ if (!arch) output_filenames( lddll_flags );
}
@@ -2816,6 +2805,7 @@
struct strarray multiarch_targets[MAX_ARCHS] = { empty_strarray };
const char *dest;
unsigned int i, arch;
+ int multiarch;
if (find_include_file( make, strmake( "%s.h", obj ))) source->file->flags |= FLAG_IDL_HEADER;
if (!source->file->flags) return;
@@ -2839,9 +2829,10 @@
for (i = 0; i < ARRAY_SIZE(idl_outputs); i++)
{
if (!(source->file->flags & idl_outputs[i].flag)) continue;
+ multiarch = (make->use_msvcrt && archs.count > 1);
for (arch = 0; arch < archs.count; arch++)
{
- if (!is_multiarch( arch )) continue;
+ if (!arch != !multiarch) continue;
if (make->disabled[arch]) continue;
dest = strmake( "%s%s%s", arch_dirs[arch], obj, idl_outputs[i].ext );
if (!find_src_file( make, dest )) strarray_add( &make->clean_files, dest );
@@ -3152,13 +3143,13 @@
if (arch)
{
if (source->file->flags & FLAG_C_UNIX) return;
- if (!is_using_msvcrt( make ) && !make->staticlib && !(source->file->flags & FLAG_C_IMPLIB)) return;
+ if (!make->use_msvcrt && !make->staticlib && !(source->file->flags & FLAG_C_IMPLIB)) return;
}
else if (source->file->flags & FLAG_C_UNIX)
{
if (!unix_lib_supported) return;
}
- else if (archs.count > 1 && is_using_msvcrt( make ))
+ else if (archs.count > 1 && make->use_msvcrt)
{
if (!so_dll_supported) return;
if (!(source->file->flags & FLAG_C_IMPLIB) && (!make->staticlib || make->extlib)) return;
@@ -3349,6 +3340,12 @@
strarray_addall( &all_libs, add_import_libs( make, &dep_libs, default_imports, IMPORT_TYPE_DEFAULT, arch ) );
if (!arch) strarray_addall( &all_libs, libs );
+ if (!make->use_msvcrt)
+ {
+ strarray_addall( &all_libs, get_expanded_make_var_array( make, "UNIX_LIBS" ));
+ strarray_addall( &all_libs, libs );
+ }
+
if (delay_load_flags[arch])
{
for (i = 0; i < make->delayimports.count; i++)
@@ -3541,7 +3538,7 @@
output( ": %s", obj_dir_path( make, testmodule ));
if (parent)
{
- char *parent_module = arch_module_name( make->testdll, arch );
+ char *parent_module = arch_module_name( make->testdll, parent->use_msvcrt ? arch : 0 );
output_filename( obj_dir_path( parent, parent_module ));
if (parent->unixlib) output_filename( obj_dir_path( parent, parent->unixlib ));
}
@@ -3792,11 +3789,15 @@
}
else if (make->module)
{
- for (arch = 0; arch < archs.count; arch++)
+ if (!make->use_msvcrt) output_module( make, 0 );
+ else
{
- if (is_multiarch( arch )) output_module( make, arch );
- if (make->importlib && (is_multiarch( arch ) || !is_native_arch_disabled( make )))
- output_import_lib( make, arch );
+ for (arch = 0; arch < archs.count; arch++)
+ {
+ if (is_multiarch( arch )) output_module( make, arch );
+ if (make->importlib && (is_multiarch( arch ) || !is_native_arch_disabled( make )))
+ output_import_lib( make, arch );
+ }
}
if (make->unixlib) output_unix_lib( make );
if (make->is_exe && !make->is_win16 && unix_lib_supported && strendswith( make->module, ".exe" ))
@@ -4236,9 +4237,13 @@
}
make->is_win16 = strarray_exists( &make->extradllflags, "-m16" );
make->data_only = strarray_exists( &make->extradllflags, "-Wb,--data-only" );
+ make->use_msvcrt = (make->module || make->testdll || make->is_win16) &&
+ !strarray_exists( &make->extradllflags, "-mcygwin" );
make->is_exe = strarray_exists( &make->extradllflags, "-mconsole" ) ||
strarray_exists( &make->extradllflags, "-mwindows" );
+ if (make->use_msvcrt) strarray_add_uniq( &make->extradllflags, "-mno-cygwin" );
+
if (make->module)
{
/* add default install rules if nothing was specified */
@@ -4296,6 +4301,8 @@
add_generated_sources( make );
+ if (make->use_msvcrt) strarray_add( &make->define_args, get_crt_define( make ));
+
LIST_FOR_EACH_ENTRY( file, &make->includes, struct incl_file, entry ) parse_file( make, file, 0 );
LIST_FOR_EACH_ENTRY( file, &make->sources, struct incl_file, entry ) get_dependencies( file, file );