makefiles: Don't use winegcc to build native Unix libraries.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-09-22 10:34:07 +02:00
parent ae06f74828
commit 5e0479c497
6 changed files with 130 additions and 49 deletions

View File

@ -47,6 +47,8 @@ MSVCRTFLAGS = @MSVCRTFLAGS@
TARGETFLAGS = @TARGETFLAGS@
LDDLLFLAGS = @LDDLLFLAGS@
LDEXECFLAGS = @LDEXECFLAGS@
UNIXDLLFLAGS = @UNIXDLLFLAGS@
UNIXLDFLAGS = @UNIXLDFLAGS@
LIBS = @LIBS@
BISON = @BISON@
FLEX = @FLEX@

58
configure vendored
View File

@ -751,6 +751,8 @@ WINEPRELOADER_LDFLAGS
WINELOADER_LDFLAGS
TOP_INSTALL_DEV
TOP_INSTALL_LIB
UNIXLDFLAGS
UNIXDLLFLAGS
LDEXECFLAGS
LDDLLFLAGS
DLLFLAGS
@ -7940,6 +7942,10 @@ LDDLLFLAGS=""
LDEXECFLAGS=""
UNIXDLLFLAGS="-fPIC"
UNIXLDFLAGS="-shared -Wl,-Bsymbolic -Wl,-soname,\$(UNIXLIB)"
TOP_INSTALL_LIB=""
TOP_INSTALL_DEV=""
@ -9118,6 +9124,7 @@ fi
LIBS="$ac_save_LIBS"
fi
UNIXLDFLAGS="-dynamiclib -install_name @loader_path/\$(UNIXLIB)"
LIBWINE_SHAREDLIB="libwine.$libwine_version.dylib"
LIBWINE_LDFLAGS="-dynamiclib -install_name @rpath/libwine.$libwine_soversion.dylib -Wl,-rpath,@loader_path/ -compatibility_version $libwine_soversion -current_version $libwine_version"
@ -9132,6 +9139,31 @@ fi
LDDLLFLAGS="-fPIC"
LDEXECFLAGS="-Wl,-pie"
enable_wineandroid_drv=${enable_wineandroid_drv:-yes}
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -Wl,-z,defs" >&5
$as_echo_n "checking whether the compiler supports -Wl,-z,defs... " >&6; }
if ${ac_cv_cflags__Wl__z_defs+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_wine_try_cflags_saved=$CFLAGS
CFLAGS="$CFLAGS -Wl,-z,defs"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int main(int argc, char **argv) { return 0; }
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_cflags__Wl__z_defs=yes
else
ac_cv_cflags__Wl__z_defs=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$ac_wine_try_cflags_saved
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cflags__Wl__z_defs" >&5
$as_echo "$ac_cv_cflags__Wl__z_defs" >&6; }
if test "x$ac_cv_cflags__Wl__z_defs" = xyes; then :
UNIXLDFLAGS="$UNIXLDFLAGS -Wl,-z,defs"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -fPIC -Wl,--export-dynamic" >&5
$as_echo_n "checking whether the compiler supports -fPIC -Wl,--export-dynamic... " >&6; }
if ${ac_cv_cflags__fPIC__Wl___export_dynamic+:} false; then :
@ -9346,6 +9378,31 @@ if test "x$ac_cv_cflags__shared__Wl___version_script_conftest_map" = xyes; then
fi
rm -f conftest.map
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -Wl,-z,defs" >&5
$as_echo_n "checking whether the compiler supports -Wl,-z,defs... " >&6; }
if ${ac_cv_cflags__Wl__z_defs+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_wine_try_cflags_saved=$CFLAGS
CFLAGS="$CFLAGS -Wl,-z,defs"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int main(int argc, char **argv) { return 0; }
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_cflags__Wl__z_defs=yes
else
ac_cv_cflags__Wl__z_defs=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$ac_wine_try_cflags_saved
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cflags__Wl__z_defs" >&5
$as_echo "$ac_cv_cflags__Wl__z_defs" >&6; }
if test "x$ac_cv_cflags__Wl__z_defs" = xyes; then :
UNIXLDFLAGS="$UNIXLDFLAGS -Wl,-z,defs"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -Wl,--export-dynamic" >&5
$as_echo_n "checking whether the compiler supports -Wl,--export-dynamic... " >&6; }
if ${ac_cv_cflags__Wl___export_dynamic+:} false; then :
@ -17828,6 +17885,7 @@ if test "$ac_cv_c_cfi_support" = "yes"
then
DLLFLAGS="$DLLFLAGS -fasynchronous-unwind-tables"
LDDLLFLAGS="$LDDLLFLAGS -fasynchronous-unwind-tables"
UNIXDLLFLAGS="$UNIXDLLFLAGS -fasynchronous-unwind-tables"
else
if test "x$enable_win64" = "xyes"
then

View File

@ -701,6 +701,8 @@ dnl **** Check for working dll ****
AC_SUBST(DLLFLAGS,"")
AC_SUBST(LDDLLFLAGS,"")
AC_SUBST(LDEXECFLAGS,"")
AC_SUBST(UNIXDLLFLAGS,"-fPIC")
AC_SUBST(UNIXLDFLAGS,["-shared -Wl,-Bsymbolic -Wl,-soname,\$(UNIXLIB)"])
AC_SUBST(TOP_INSTALL_LIB,"")
AC_SUBST(TOP_INSTALL_DEV,"")
AC_SUBST(WINELOADER_LDFLAGS,"")
@ -862,6 +864,7 @@ case $host_os in
LIBS="$ac_save_LIBS"
fi
UNIXLDFLAGS="-dynamiclib -install_name @loader_path/\$(UNIXLIB)"
AC_SUBST(LIBWINE_SHAREDLIB,"libwine.$libwine_version.dylib")
AC_SUBST(LIBWINE_LDFLAGS,["-dynamiclib -install_name @rpath/libwine.$libwine_soversion.dylib -Wl,-rpath,@loader_path/ -compatibility_version $libwine_soversion -current_version $libwine_version"])
AC_SUBST(WINELOADER_DEPENDS,"wine_info.plist")
@ -873,8 +876,8 @@ case $host_os in
LDDLLFLAGS="-fPIC"
LDEXECFLAGS="-Wl,-pie"
enable_wineandroid_drv=${enable_wineandroid_drv:-yes}
WINE_TRY_CFLAGS([-fPIC -Wl,--export-dynamic],
[WINELOADER_LDFLAGS="-Wl,--export-dynamic"])
WINE_TRY_CFLAGS([-Wl,-z,defs],[UNIXLDFLAGS="$UNIXLDFLAGS -Wl,-z,defs"])
WINE_TRY_CFLAGS([-fPIC -Wl,--export-dynamic],[WINELOADER_LDFLAGS="-Wl,--export-dynamic"])
WINEPRELOADER_LDFLAGS="-static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7d400000"
WINE_CHECK_SONAME(EGL,eglGetProcAddress)
@ -909,8 +912,8 @@ case $host_os in
[LIBWINE_LDFLAGS="$LIBWINE_LDFLAGS -Wl,--version-script=\$(srcdir)/wine.map"])
rm -f conftest.map
WINE_TRY_CFLAGS([-Wl,--export-dynamic],
[WINELOADER_LDFLAGS="-Wl,--export-dynamic"])
WINE_TRY_CFLAGS([-Wl,-z,defs],[UNIXLDFLAGS="$UNIXLDFLAGS -Wl,-z,defs"])
WINE_TRY_CFLAGS([-Wl,--export-dynamic],[WINELOADER_LDFLAGS="-Wl,--export-dynamic"])
WINEPRELOADER_LDFLAGS="-static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7d400000"
case $host_cpu in
@ -2101,6 +2104,7 @@ if test "$ac_cv_c_cfi_support" = "yes"
then
DLLFLAGS="$DLLFLAGS -fasynchronous-unwind-tables"
LDDLLFLAGS="$LDDLLFLAGS -fasynchronous-unwind-tables"
UNIXDLLFLAGS="$UNIXDLLFLAGS -fasynchronous-unwind-tables"
else
if test "x$enable_win64" = "xyes"
then

View File

@ -4,7 +4,7 @@ UNIXLIB = ntdll.so
IMPORTLIB = ntdll
IMPORTS = winecrt0
EXTRAINCL = $(UNWIND_CFLAGS)
EXTRALIBS = -lwinecrt0 $(IOKIT_LIBS) $(COREFOUNDATION_LIBS) $(CORESERVICES_LIBS) $(RT_LIBS) $(PTHREAD_LIBS) $(UNWIND_LIBS) $(I386_LIBS) $(PROCSTAT_LIBS)
EXTRALIBS = -lwinecrt0 $(IOKIT_LIBS) $(COREFOUNDATION_LIBS) $(CORESERVICES_LIBS) $(RT_LIBS) $(PTHREAD_LIBS) $(UNWIND_LIBS) $(I386_LIBS) $(PROCSTAT_LIBS) -lm
EXTRADLLFLAGS = -nodefaultlibs -Wl,--image-base,0x7bc00000

View File

@ -1,7 +1,7 @@
MODULE = winepulse.drv
UNIXLIB = winepulse.so
IMPORTS = dxguid uuid winmm user32 advapi32 ole32
EXTRALIBS = $(PULSE_LIBS) $(PTHREAD_LIBS)
EXTRALIBS = $(PULSE_LIBS) $(PTHREAD_LIBS) -lm
EXTRAINCL = $(PULSE_CFLAGS)
C_SRCS = \

View File

@ -137,6 +137,7 @@ enum install_rules { INSTALL_LIB, INSTALL_DEV, NB_INSTALL_RULES };
/* variables common to all makefiles */
static struct strarray linguas;
static struct strarray dll_flags;
static struct strarray unix_dllflags;
static struct strarray target_flags;
static struct strarray msvcrt_flags;
static struct strarray extra_cflags;
@ -2013,7 +2014,8 @@ static void add_generated_sources( struct makefile *make )
if (strendswith( objs.str[i], ".o" ))
{
file = add_generated_source( make, objs.str[i], replace_extension( objs.str[i], ".o", ".c" ));
if (make->module || make->staticlib) file->file->flags |= FLAG_C_UNIX;
file->file->flags |= FLAG_C_UNIX;
file->use_msvcrt = 0;
}
else if (strendswith( objs.str[i], ".res" ))
add_generated_source( make, replace_extension( objs.str[i], ".res", ".rc" ), NULL );
@ -3170,7 +3172,11 @@ static void output_source_default( struct makefile *make, struct incl_file *sour
output( "%s.o: %s\n", obj_dir_path( make, obj ), source->filename );
output( "\t%s$(CC) -c -o $@ %s", cmd_prefix( "CC" ), source->filename );
output_filenames( defines );
if (make->module || make->staticlib || make->sharedlib || make->testdll)
if (make->sharedlib || (make->staticlib && !make->module) || (source->file->flags & FLAG_C_UNIX))
{
output_filenames( unix_dllflags );
}
else if (make->module || make->staticlib || make->testdll)
{
output_filenames( dll_flags );
if (source->use_msvcrt) output_filenames( msvcrt_flags );
@ -3413,14 +3419,24 @@ static void output_module( struct makefile *make )
output( "%s:", obj_dir_path( make, make->unixlib ));
output_filenames_obj_dir( make, make->unixobj_files );
output_filenames( unix_deps );
if (!make->native_unix_lib) output_filename( tools_path( make, "winebuild" ));
output_filename( tools_path( make, "winegcc" ));
output( "\n" );
output_winegcc_command( make, 0 );
output_filename( "-munix" );
output_filename( "-shared" );
if (spec_file && !make->native_unix_lib) output_filename( spec_file );
if (strarray_exists( &make->extradllflags, "-nodefaultlibs" )) output_filename( "-nodefaultlibs" );
if (make->native_unix_lib)
{
output( "\n" );
output( "\t%s$(CC) -o $@", cmd_prefix( "CCLD" ));
output_filenames( get_expanded_make_var_array( make, "UNIXLDFLAGS" ));
}
else
{
output_filename( tools_path( make, "winebuild" ));
output_filename( tools_path( make, "winegcc" ));
output( "\n" );
output_winegcc_command( make, 0 );
output_filename( "-munix" );
output_filename( "-shared" );
if (spec_file) output_filename( spec_file );
if (strarray_exists( &make->extradllflags, "-nodefaultlibs" )) output_filename( "-nodefaultlibs" );
}
output_filenames_obj_dir( make, make->unixobj_files );
output_filenames( unix_libs );
output_filename( "$(LDFLAGS)" );
@ -3559,7 +3575,7 @@ static void output_shared_lib( struct makefile *make )
output_filenames_obj_dir( make, make->object_files );
output_filenames( dep_libs );
output( "\n" );
output( "\t%s$(CC) -o $@", cmd_prefix( "CC" ));
output( "\t%s$(CC) -o $@", cmd_prefix( "CCLD" ));
output_filenames_obj_dir( make, make->object_files );
output_filenames( all_libs );
output_filename( "$(LDFLAGS)" );
@ -4415,40 +4431,41 @@ int main( int argc, char *argv[] )
top_makefile = parse_makefile( NULL );
target_flags = get_expanded_make_var_array( top_makefile, "TARGETFLAGS" );
msvcrt_flags = get_expanded_make_var_array( top_makefile, "MSVCRTFLAGS" );
dll_flags = get_expanded_make_var_array( top_makefile, "DLLFLAGS" );
extra_cflags = get_expanded_make_var_array( top_makefile, "EXTRACFLAGS" );
target_flags = get_expanded_make_var_array( top_makefile, "TARGETFLAGS" );
msvcrt_flags = get_expanded_make_var_array( top_makefile, "MSVCRTFLAGS" );
dll_flags = get_expanded_make_var_array( top_makefile, "DLLFLAGS" );
extra_cflags = get_expanded_make_var_array( top_makefile, "EXTRACFLAGS" );
extra_cross_cflags = get_expanded_make_var_array( top_makefile, "EXTRACROSSCFLAGS" );
cpp_flags = get_expanded_make_var_array( top_makefile, "CPPFLAGS" );
lddll_flags = get_expanded_make_var_array( top_makefile, "LDDLLFLAGS" );
libs = get_expanded_make_var_array( top_makefile, "LIBS" );
enable_tests = get_expanded_make_var_array( top_makefile, "ENABLE_TESTS" );
delay_load_flag = get_expanded_make_variable( top_makefile, "DELAYLOADFLAG" );
top_install_lib = get_expanded_make_var_array( top_makefile, "TOP_INSTALL_LIB" );
top_install_dev = get_expanded_make_var_array( top_makefile, "TOP_INSTALL_DEV" );
unix_dllflags = get_expanded_make_var_array( top_makefile, "UNIXDLLFLAGS" );
cpp_flags = get_expanded_make_var_array( top_makefile, "CPPFLAGS" );
lddll_flags = get_expanded_make_var_array( top_makefile, "LDDLLFLAGS" );
libs = get_expanded_make_var_array( top_makefile, "LIBS" );
enable_tests = get_expanded_make_var_array( top_makefile, "ENABLE_TESTS" );
top_install_lib = get_expanded_make_var_array( top_makefile, "TOP_INSTALL_LIB" );
top_install_dev = get_expanded_make_var_array( top_makefile, "TOP_INSTALL_DEV" );
root_src_dir = get_expanded_make_variable( top_makefile, "srcdir" );
tools_dir = get_expanded_make_variable( top_makefile, "TOOLSDIR" );
tools_ext = get_expanded_make_variable( top_makefile, "TOOLSEXT" );
exe_ext = get_expanded_make_variable( top_makefile, "EXEEXT" );
man_ext = get_expanded_make_variable( top_makefile, "api_manext" );
dll_ext = (exe_ext && !strcmp( exe_ext, ".exe" )) ? "" : ".so";
host_cpu = get_expanded_make_variable( top_makefile, "host_cpu" );
crosstarget = get_expanded_make_variable( top_makefile, "CROSSTARGET" );
crossdebug = get_expanded_make_variable( top_makefile, "CROSSDEBUG" );
fontforge = get_expanded_make_variable( top_makefile, "FONTFORGE" );
convert = get_expanded_make_variable( top_makefile, "CONVERT" );
flex = get_expanded_make_variable( top_makefile, "FLEX" );
bison = get_expanded_make_variable( top_makefile, "BISON" );
ar = get_expanded_make_variable( top_makefile, "AR" );
ranlib = get_expanded_make_variable( top_makefile, "RANLIB" );
rsvg = get_expanded_make_variable( top_makefile, "RSVG" );
icotool = get_expanded_make_variable( top_makefile, "ICOTOOL" );
dlltool = get_expanded_make_variable( top_makefile, "DLLTOOL" );
msgfmt = get_expanded_make_variable( top_makefile, "MSGFMT" );
sed_cmd = get_expanded_make_variable( top_makefile, "SED_CMD" );
ln_s = get_expanded_make_variable( top_makefile, "LN_S" );
delay_load_flag = get_expanded_make_variable( top_makefile, "DELAYLOADFLAG" );
root_src_dir = get_expanded_make_variable( top_makefile, "srcdir" );
tools_dir = get_expanded_make_variable( top_makefile, "TOOLSDIR" );
tools_ext = get_expanded_make_variable( top_makefile, "TOOLSEXT" );
exe_ext = get_expanded_make_variable( top_makefile, "EXEEXT" );
man_ext = get_expanded_make_variable( top_makefile, "api_manext" );
dll_ext = (exe_ext && !strcmp( exe_ext, ".exe" )) ? "" : ".so";
host_cpu = get_expanded_make_variable( top_makefile, "host_cpu" );
crosstarget = get_expanded_make_variable( top_makefile, "CROSSTARGET" );
crossdebug = get_expanded_make_variable( top_makefile, "CROSSDEBUG" );
fontforge = get_expanded_make_variable( top_makefile, "FONTFORGE" );
convert = get_expanded_make_variable( top_makefile, "CONVERT" );
flex = get_expanded_make_variable( top_makefile, "FLEX" );
bison = get_expanded_make_variable( top_makefile, "BISON" );
ar = get_expanded_make_variable( top_makefile, "AR" );
ranlib = get_expanded_make_variable( top_makefile, "RANLIB" );
rsvg = get_expanded_make_variable( top_makefile, "RSVG" );
icotool = get_expanded_make_variable( top_makefile, "ICOTOOL" );
dlltool = get_expanded_make_variable( top_makefile, "DLLTOOL" );
msgfmt = get_expanded_make_variable( top_makefile, "MSGFMT" );
sed_cmd = get_expanded_make_variable( top_makefile, "SED_CMD" );
ln_s = get_expanded_make_variable( top_makefile, "LN_S" );
if (root_src_dir && !strcmp( root_src_dir, "." )) root_src_dir = NULL;
if (tools_dir && !strcmp( tools_dir, "." )) tools_dir = NULL;