Commit 2374cd52 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

winegcc: Set the LDDLLFLAGS according to the target platform.

parent 810ec233
......@@ -712,7 +712,6 @@ LDD
LDRPATH_LOCAL
LDRPATH_INSTALL
IMPLIBEXT
LDDLLFLAGS
DLLFLAGS
DLLEXT
CPP
......@@ -6411,8 +6410,6 @@ DLLEXT=""
DLLFLAGS="-D_REENTRANT"
LDDLLFLAGS=""
IMPLIBEXT="def"
LDRPATH_INSTALL=""
......@@ -6699,7 +6696,6 @@ clean::
DLLEXT=".so"
LIBEXT="dylib"
DLLFLAGS="$DLLFLAGS -fPIC"
LDDLLFLAGS="-bundle -multiply_defined suppress"
LIBWINE_LDFLAGS="-multiply_defined suppress"
LDRPATH_INSTALL="-Wl,-rpath,@loader_path/\`\$(RELPATH) \$(bindir) \$(libdir)\`"
LDRPATH_LOCAL="-Wl,-rpath,@loader_path/\$(top_builddir)/libs/wine"
......@@ -6807,10 +6803,6 @@ done
LIBS="$ac_save_LIBS"
fi
case $host_cpu in
*powerpc*)
LDDLLFLAGS="$LDDLLFLAGS -read_only_relocs warning" ;;
esac
if test "$ac_cv_header_QuickTime_ImageCompression_h" = "yes"
then
QUICKTIMELIB="-framework QuickTime -framework ApplicationServices -framework CoreVideo"
......@@ -6907,57 +6899,6 @@ clean::
linux-android*)
DLLFLAGS="$DLLFLAGS -fPIC"
DLLEXT=".so"
LDDLLFLAGS="-shared -Wl,-Bsymbolic"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -fPIC -shared -Wl,-Bsymbolic,-z,defs" >&5
$as_echo_n "checking whether the compiler supports -fPIC -shared -Wl,-Bsymbolic,-z,defs... " >&6; }
if ${ac_cv_cflags__fPIC__shared__Wl__Bsymbolic__z_defs+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_wine_try_cflags_saved=$CFLAGS
CFLAGS="$CFLAGS -fPIC -shared -Wl,-Bsymbolic,-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__fPIC__shared__Wl__Bsymbolic__z_defs=yes
else
ac_cv_cflags__fPIC__shared__Wl__Bsymbolic__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__fPIC__shared__Wl__Bsymbolic__z_defs" >&5
$as_echo "$ac_cv_cflags__fPIC__shared__Wl__Bsymbolic__z_defs" >&6; }
if test $ac_cv_cflags__fPIC__shared__Wl__Bsymbolic__z_defs = yes; then :
LDDLLFLAGS="$LDDLLFLAGS,-z,defs"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -fPIC -shared -Wl,-Bsymbolic,-init,__wine_spec_init,-fini,__wine_spec_fini" >&5
$as_echo_n "checking whether the compiler supports -fPIC -shared -Wl,-Bsymbolic,-init,__wine_spec_init,-fini,__wine_spec_fini... " >&6; }
if ${ac_cv_cflags__fPIC__shared__Wl__Bsymbolic__init___wine_spec_init__fini___wine_spec_fini+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_wine_try_cflags_saved=$CFLAGS
CFLAGS="$CFLAGS -fPIC -shared -Wl,-Bsymbolic,-init,__wine_spec_init,-fini,__wine_spec_fini"
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__fPIC__shared__Wl__Bsymbolic__init___wine_spec_init__fini___wine_spec_fini=yes
else
ac_cv_cflags__fPIC__shared__Wl__Bsymbolic__init___wine_spec_init__fini___wine_spec_fini=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__fPIC__shared__Wl__Bsymbolic__init___wine_spec_init__fini___wine_spec_fini" >&5
$as_echo "$ac_cv_cflags__fPIC__shared__Wl__Bsymbolic__init___wine_spec_init__fini___wine_spec_fini" >&6; }
if test $ac_cv_cflags__fPIC__shared__Wl__Bsymbolic__init___wine_spec_init__fini___wine_spec_fini = yes; then :
LDDLLFLAGS="$LDDLLFLAGS,-init,__wine_spec_init,-fini,__wine_spec_fini"
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 :
......@@ -7144,7 +7085,6 @@ $as_echo "$ac_cv_c_dll_gnuelf" >&6; }
if test "$ac_cv_c_dll_gnuelf" = "yes"
then
LDSHARED="\$(CC) -shared"
LDDLLFLAGS="-shared -Wl,-Bsymbolic"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -fPIC -shared -Wl,-soname,confest.so.1" >&5
$as_echo_n "checking whether the compiler supports -fPIC -shared -Wl,-soname,confest.so.1... " >&6; }
if ${ac_cv_cflags__fPIC__shared__Wl__soname_confest_so_1+:} false; then :
......@@ -7197,58 +7137,6 @@ if test $ac_cv_cflags__fPIC__shared__Wl__h_confest_so_1 = yes; then :
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -fPIC -shared -Wl,-Bsymbolic,-z,defs" >&5
$as_echo_n "checking whether the compiler supports -fPIC -shared -Wl,-Bsymbolic,-z,defs... " >&6; }
if ${ac_cv_cflags__fPIC__shared__Wl__Bsymbolic__z_defs+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_wine_try_cflags_saved=$CFLAGS
CFLAGS="$CFLAGS -fPIC -shared -Wl,-Bsymbolic,-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__fPIC__shared__Wl__Bsymbolic__z_defs=yes
else
ac_cv_cflags__fPIC__shared__Wl__Bsymbolic__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__fPIC__shared__Wl__Bsymbolic__z_defs" >&5
$as_echo "$ac_cv_cflags__fPIC__shared__Wl__Bsymbolic__z_defs" >&6; }
if test $ac_cv_cflags__fPIC__shared__Wl__Bsymbolic__z_defs = yes; then :
LDDLLFLAGS="$LDDLLFLAGS,-z,defs"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -fPIC -shared -Wl,-Bsymbolic,-init,__wine_spec_init,-fini,__wine_spec_fini" >&5
$as_echo_n "checking whether the compiler supports -fPIC -shared -Wl,-Bsymbolic,-init,__wine_spec_init,-fini,__wine_spec_fini... " >&6; }
if ${ac_cv_cflags__fPIC__shared__Wl__Bsymbolic__init___wine_spec_init__fini___wine_spec_fini+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_wine_try_cflags_saved=$CFLAGS
CFLAGS="$CFLAGS -fPIC -shared -Wl,-Bsymbolic,-init,__wine_spec_init,-fini,__wine_spec_fini"
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__fPIC__shared__Wl__Bsymbolic__init___wine_spec_init__fini___wine_spec_fini=yes
else
ac_cv_cflags__fPIC__shared__Wl__Bsymbolic__init___wine_spec_init__fini___wine_spec_fini=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__fPIC__shared__Wl__Bsymbolic__init___wine_spec_init__fini___wine_spec_fini" >&5
$as_echo "$ac_cv_cflags__fPIC__shared__Wl__Bsymbolic__init___wine_spec_init__fini___wine_spec_fini" >&6; }
if test $ac_cv_cflags__fPIC__shared__Wl__Bsymbolic__init___wine_spec_init__fini___wine_spec_fini = yes; then :
LDDLLFLAGS="$LDDLLFLAGS,-init,__wine_spec_init,-fini,__wine_spec_fini"
fi
echo '{ global: *; };' >conftest.map
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -fPIC -shared -Wl,--version-script=conftest.map" >&5
$as_echo_n "checking whether the compiler supports -fPIC -shared -Wl,--version-script=conftest.map... " >&6; }
......@@ -7493,7 +7381,6 @@ $as_echo "$ac_cv_c_dll_unixware" >&6; }
if test "$ac_cv_c_dll_unixware" = "yes"
then
LDSHARED="\$(CC) -Wl,-G,-h,libwine.so.\$(SOVERSION)"
LDDLLFLAGS="-Wl,-G,-B,symbolic"
fi
fi
LIBWINE_RULES="
......
......@@ -677,7 +677,6 @@ dnl **** Check for working dll ****
AC_SUBST(DLLEXT,"")
AC_SUBST(DLLFLAGS,"-D_REENTRANT")
AC_SUBST(LDDLLFLAGS,"")
AC_SUBST(IMPLIBEXT,"def")
AC_SUBST(LDRPATH_INSTALL,"")
AC_SUBST(LDRPATH_LOCAL,"")
......@@ -738,7 +737,6 @@ clean::
DLLEXT=".so"
LIBEXT="dylib"
DLLFLAGS="$DLLFLAGS -fPIC"
LDDLLFLAGS="-bundle -multiply_defined suppress"
LIBWINE_LDFLAGS="-multiply_defined suppress"
LDRPATH_INSTALL="-Wl,-rpath,@loader_path/\`\$(RELPATH) \$(bindir) \$(libdir)\`"
LDRPATH_LOCAL="-Wl,-rpath,@loader_path/\$(top_builddir)/libs/wine"
......@@ -803,11 +801,6 @@ clean::
AC_CHECK_FUNCS(IOHIDManagerCreate)
LIBS="$ac_save_LIBS"
fi
case $host_cpu in
*powerpc*)
LDDLLFLAGS="$LDDLLFLAGS -read_only_relocs warning" dnl FIXME
;;
esac
if test "$ac_cv_header_QuickTime_ImageCompression_h" = "yes"
then
AC_SUBST(QUICKTIMELIB,"-framework QuickTime -framework ApplicationServices -framework CoreVideo")
......@@ -877,11 +870,6 @@ clean::
linux-android*)
DLLFLAGS="$DLLFLAGS -fPIC"
DLLEXT=".so"
LDDLLFLAGS="-shared -Wl,-Bsymbolic"
WINE_TRY_CFLAGS([-fPIC -shared -Wl,-Bsymbolic,-z,defs],
[LDDLLFLAGS="$LDDLLFLAGS,-z,defs"])
WINE_TRY_CFLAGS([-fPIC -shared -Wl,-Bsymbolic,-init,__wine_spec_init,-fini,__wine_spec_fini],
[LDDLLFLAGS="$LDDLLFLAGS,-init,__wine_spec_init,-fini,__wine_spec_fini"])
WINE_TRY_CFLAGS([-fPIC -Wl,--export-dynamic],
[AC_SUBST(LDEXECFLAGS,["-Wl,--export-dynamic"])])
WINE_TRY_CFLAGS([-fPIC -Wl,--rpath,\$ORIGIN/../lib],
......@@ -927,17 +915,11 @@ clean::
if test "$ac_cv_c_dll_gnuelf" = "yes"
then
LDSHARED="\$(CC) -shared"
LDDLLFLAGS="-shared -Wl,-Bsymbolic"
WINE_TRY_CFLAGS([-fPIC -shared -Wl,-soname,confest.so.1],
[LDSHARED="\$(CC) -shared -Wl,-soname,libwine.so.\$(SOVERSION)"],
[WINE_TRY_CFLAGS([-fPIC -shared -Wl,-h,confest.so.1],
[LDSHARED="\$(CC) -shared -Wl,-h,libwine.so.\$(SOVERSION)"])])
WINE_TRY_CFLAGS([-fPIC -shared -Wl,-Bsymbolic,-z,defs], [LDDLLFLAGS="$LDDLLFLAGS,-z,defs"])
WINE_TRY_CFLAGS([-fPIC -shared -Wl,-Bsymbolic,-init,__wine_spec_init,-fini,__wine_spec_fini],
[LDDLLFLAGS="$LDDLLFLAGS,-init,__wine_spec_init,-fini,__wine_spec_fini"])
echo '{ global: *; };' >conftest.map
WINE_TRY_CFLAGS([-fPIC -shared -Wl,--version-script=conftest.map],
[LDSHARED="$LDSHARED -Wl,--version-script=\$(srcdir)/wine.map"])
......@@ -979,7 +961,6 @@ clean::
if test "$ac_cv_c_dll_unixware" = "yes"
then
LDSHARED="\$(CC) -Wl,-G,-h,libwine.so.\$(SOVERSION)"
LDDLLFLAGS="-Wl,-G,-B,symbolic"
fi
fi
AC_SUBST(LIBWINE_RULES,["
......
......@@ -3,7 +3,6 @@ DEFS = \
-DDLLDIR="\"$(dlldir)\"" \
-DLIBDIR="\"$(libdir)\"" \
-DDLLFLAGS="\"@DLLFLAGS@\"" \
-DLDDLLFLAGS="\"@LDDLLFLAGS@\"" \
-DCC="\"$(CC)\"" \
-DCPP="\"@CPPBIN@\"" \
-DCXX="\"@CXX@\"" \
......
......@@ -297,7 +297,7 @@ file_type get_lib_type(enum target_platform platform, strarray* path, const char
return file_na;
}
void spawn(const strarray* prefix, const strarray* args, int ignore_errors)
int spawn(const strarray* prefix, const strarray* args, int ignore_errors)
{
unsigned int i;
int status;
......@@ -343,4 +343,5 @@ void spawn(const strarray* prefix, const strarray* args, int ignore_errors)
free(prog);
strarray_free(arr);
return status;
}
......@@ -78,6 +78,6 @@ void create_file(const char* name, int mode, const char* fmt, ...);
file_type get_file_type(const char* filename);
file_type get_lib_type(enum target_platform platform, strarray* path, const char *library,
const char *suffix, char** file);
void spawn(const strarray* prefix, const strarray* arr, int ignore_errors);
int spawn(const strarray* prefix, const strarray* arr, int ignore_errors);
extern int verbose;
......@@ -330,6 +330,72 @@ static const strarray* get_translator(struct options *opts)
return ret;
}
static int try_link( const strarray *prefix, const strarray *link_tool, const char *cflags )
{
const char *in = get_temp_file( "try_link", ".c" );
const char *out = get_temp_file( "try_link", ".out" );
strarray *link = strarray_dup( link_tool );
int ret;
create_file( in, 0644, "int main(void){return 1;}" );
strarray_add( link, "-o" );
strarray_add( link, out );
strarray_addall( link, strarray_fromstring( cflags, " " ) );
strarray_add( link, in );
ret = spawn( prefix, link, 1 );
strarray_free( link );
return ret;
}
static const strarray* get_lddllflags( const struct options *opts, const strarray *link_tool )
{
strarray *flags = strarray_alloc();
switch (opts->target_platform)
{
case PLATFORM_APPLE:
strarray_add( flags, "-bundle" );
strarray_add( flags, "-multiply_defined" );
strarray_add( flags, "suppress" );
if (opts->target_cpu == CPU_POWERPC)
{
strarray_add( flags, "-read_only_relocs" );
strarray_add( flags, "warning" );
}
break;
case PLATFORM_SOLARIS:
strarray_add( flags, "-Wl,-G,-B,symbolic" );
break;
case PLATFORM_UNSPECIFIED:
strarray_add( flags, "-shared" );
strarray_add( flags, "-Wl,-Bsymbolic" );
/* Try all options first - this is likely to succeed on modern compilers */
if (!try_link( opts->prefix, link_tool, "-fPIC -shared -Wl,-Bsymbolic "
"-Wl,-z,defs -Wl,-init,__wine_spec_init,-fini,_wine_spec_fini" ))
{
strarray_add( flags, "-Wl,-z,defs" );
strarray_add( flags, "-Wl,-init,__wine_spec_init,-fini,__wine_spec_fini" );
}
else /* otherwise figure out which ones are allowed */
{
if (!try_link( opts->prefix, link_tool, "-fPIC -shared -Wl,-Bsymbolic -Wl,-z,defs" ))
strarray_add( flags, "-Wl,-z,defs" );
if (!try_link( opts->prefix, link_tool, "-fPIC -shared -Wl,-Bsymbolic "
"-Wl,-init,__wine_spec_init,-fini,_wine_spec_fini" ))
strarray_add( flags, "-Wl,-init,__wine_spec_init,-fini,__wine_spec_fini" );
}
break;
default:
assert(0);
}
return flags;
}
/* check that file is a library for the correct platform */
static int check_platform( struct options *opts, const char *file )
{
......@@ -1008,7 +1074,7 @@ static void build(struct options* opts)
/* link everything together now */
strarray_addall(link_args, get_translator(opts));
strarray_addall(link_args, strarray_fromstring(LDDLLFLAGS, " "));
strarray_addall(link_args, get_lddllflags(opts, link_args));
strarray_add(link_args, "-o");
strarray_add(link_args, strmake("%s.so", output_file));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment