Jacek Caban : makedep: Use -Wl,-delayload on cross targets when supported by linker.
Alexandre Julliard
julliard at winehq.org
Wed Nov 13 16:01:12 CST 2019
Module: wine
Branch: master
Commit: 3d19efae72bf0f10acad7db6fea183b10017dc58
URL: https://source.winehq.org/git/wine.git/?a=commit;h=3d19efae72bf0f10acad7db6fea183b10017dc58
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Nov 13 17:49:42 2019 +0100
makedep: Use -Wl,-delayload on cross targets when supported by linker.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
Makefile.in | 1 +
configure | 28 ++++++++++++++++++++++++++++
configure.ac | 2 ++
tools/makedep.c | 22 +++++++++++++++++-----
4 files changed, 48 insertions(+), 5 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 193ecc59a4..dfe1c56c06 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -70,6 +70,7 @@ CROSSTARGET = @CROSSTARGET@
SUBDIRS = @SUBDIRS@
RUNTESTFLAGS = -q -P wine
MAKEDEP = $(TOOLSDIR)/tools/makedep$(TOOLSEXT)
+DELAYLOADFLAG = @DELAYLOADFLAG@
PACKAGE_VERSION = @PACKAGE_VERSION@
SED_CMD = LC_ALL=C sed -e 's, at bindir\@,${bindir},g' -e 's, at dlldir\@,${dlldir},g' -e 's, at srcdir\@,${srcdir},g' -e 's, at PACKAGE_STRING\@, at PACKAGE_STRING@,g' -e 's, at PACKAGE_VERSION\@, at PACKAGE_VERSION@,g'
LDRPATH_INSTALL = @LDRPATH_INSTALL@
diff --git a/configure b/configure
index e40850201b..f447e4ca07 100755
--- a/configure
+++ b/configure
@@ -706,6 +706,7 @@ X_PRE_LIBS
X_CFLAGS
XMKMF
PTHREAD_LIBS
+DELAYLOADFLAG
EXTRACROSSCFLAGS
CROSSCFLAGS
CROSSCC
@@ -10420,6 +10421,33 @@ fi ;;
esac
done
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -Wl,-delayload,autoconftest.dll" >&5
+$as_echo_n "checking whether the compiler supports -Wl,-delayload,autoconftest.dll... " >&6; }
+if ${ac_cv_cflags__Wl__delayload_autoconftest_dll+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_wine_try_cflags_saved=$CFLAGS
+CFLAGS="$CFLAGS -Wl,-delayload,autoconftest.dll"
+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__delayload_autoconftest_dll=yes
+else
+ ac_cv_cflags__Wl__delayload_autoconftest_dll=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__delayload_autoconftest_dll" >&5
+$as_echo "$ac_cv_cflags__Wl__delayload_autoconftest_dll" >&6; }
+if test "x$ac_cv_cflags__Wl__delayload_autoconftest_dll" = xyes; then :
+ DELAYLOADFLAG="-Wl,-delayload,"
+
+fi
+
if test "x$enable_maintainer_mode" = xyes
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the cross-compiler supports -Werror" >&5
diff --git a/configure.ac b/configure.ac
index c7768db9f9..64721e9644 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1085,6 +1085,8 @@ then
esac
done
+ WINE_TRY_CFLAGS([-Wl,-delayload,autoconftest.dll], [AC_SUBST(DELAYLOADFLAG,["-Wl,-delayload,"])])
+
if test "x$enable_maintainer_mode" = xyes
then
WINE_TRY_CROSSCFLAGS([-Werror])
diff --git a/tools/makedep.c b/tools/makedep.c
index 65b36146ed..27b33eb276 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -164,6 +164,7 @@ static const char *dlltool;
static const char *msgfmt;
static const char *ln_s;
static const char *sed_cmd;
+static const char *delay_load_flag;
struct makefile
{
@@ -2110,14 +2111,17 @@ static struct makefile *get_parent_makefile( struct makefile *make )
*/
static int needs_cross_lib( const struct makefile *make )
{
+ const char *name;
if (!crosstarget) return 0;
- if (make->importlib) return strarray_exists( &cross_import_libs, make->importlib );
- if (make->staticlib)
+ if (make->importlib) name = make->importlib;
+ else if (make->staticlib)
{
- const char *name = replace_extension( make->staticlib, ".a", "" );
+ name = replace_extension( make->staticlib, ".a", "" );
if (!strncmp( name, "lib", 3 )) name += 3;
- return strarray_exists( &cross_import_libs, name );
}
+ else return 0;
+ if (strarray_exists( &cross_import_libs, name )) return 1;
+ if (delay_load_flag && strarray_exists( &delay_import_libs, name )) return 1;
return 0;
}
@@ -2127,6 +2131,7 @@ static int needs_cross_lib( const struct makefile *make )
*/
static int needs_delay_lib( const struct makefile *make )
{
+ if (delay_load_flag) return 0;
if (*dll_ext && !crosstarget) return 0;
if (!make->importlib) return 0;
return strarray_exists( &delay_import_libs, make->importlib );
@@ -2207,7 +2212,7 @@ static struct strarray add_import_libs( const struct makefile *make, struct stra
if (lib)
{
- if (delay) lib = replace_extension( lib, ".a", ".delay.a" );
+ if (delay && !delay_load_flag) lib = replace_extension( lib, ".a", ".delay.a" );
else if (make->is_cross) lib = replace_extension( lib, ".a", ".cross.a" );
lib = top_obj_dir_path( make, lib );
strarray_add( deps, lib );
@@ -3212,6 +3217,12 @@ static void output_module( struct makefile *make )
if (make->is_cross)
{
+ if (delay_load_flag)
+ {
+ for (i = 0; i < make->delayimports.count; i++)
+ strarray_add( &all_libs, strmake( "%s%s%s", delay_load_flag, make->delayimports.str[i],
+ strchr( make->delayimports.str[i], '.' ) ? "" : ".dll" ));
+ }
strarray_add( &make->all_targets, strmake( "%s", make->module ));
add_install_rule( make, make->module, strmake( "%s", make->module ),
strmake( "c$(dlldir)/%s", make->module ));
@@ -4357,6 +4368,7 @@ int main( int argc, char *argv[] )
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" );
More information about the wine-cvs
mailing list