This MR improves configuration scheme when using clang as cross compiler: - it fixes test for dwarf (-4) support (current test is failing as ldd emits a warning when generating the long section names for the dwarf section, that configure.ac treats as an error), - it fixes --enable-build-id option with clang (clang linker uses -build-id option, while gcc uses --build-id /mind the extra '-'/) - it adds support in winegcc for a generic build-id linker option.
(extracted from draft MR!6715)
-- v3: configure.ac: Don't add -Wl,--build-id linker option to CFLAGS. configure.ac: Properly detect build-id support for clang. winegcc: Remap build-id linker option for clang. configure.ac: Properly test clang for dwarf support.
From: Eric Pouech epouech@codeweavers.com
clang emits a warning when linking the dwarf's long sections names, which lets the configuration test fail.
Signed-off-by: Eric Pouech epouech@codeweavers.com --- configure.ac | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac index de80d65b240..1f01e5380c0 100644 --- a/configure.ac +++ b/configure.ac @@ -1004,7 +1004,10 @@ This is an error since --enable-archs=$wine_arch was requested.])]) if test "x$ac_debug_format_seen" = x then case $wine_crossdebug in - *dwarf) WINE_TRY_PE_CFLAGS([-gdwarf-4]) ;; + *dwarf) dnl clang emits a warning without -Wl,-debug:dwarf, so ensure linker option is present + WINE_TRY_PE_CFLAGS([-Wl,-debug:dwarf],[AS_VAR_APPEND([${wine_arch}_LDFLAGS],[" -Wl,-debug:dwarf"]) + CFLAGS="$CFLAGS -Wl,-debug:dwarf"]) + WINE_TRY_PE_CFLAGS([-gdwarf-4]) ;; pdb) WINE_TRY_PE_CFLAGS([-gcodeview]) ;; esac fi
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- tools/winegcc/winegcc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index 60cc6148158..80b85822e07 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -178,6 +178,7 @@ struct options int strip; int pic; int no_default_config; + int build_id; const char* wine_objdir; const char* winebuild; const char* output_name; @@ -427,6 +428,9 @@ static struct strarray get_link_args( struct options *opts, const char *output_n if (opts->debug_file && strendswith(opts->debug_file, ".pdb")) strarray_add(&link_args, strmake("-Wl,--pdb=%s", opts->debug_file));
+ if (opts->build_id) + strarray_add( &link_args, "-Wl,--build-id"); + if (opts->out_implib) strarray_add(&link_args, strmake("-Wl,--out-implib,%s", opts->out_implib));
@@ -466,6 +470,9 @@ static struct strarray get_link_args( struct options *opts, const char *output_n else if (!opts->strip) strarray_add(&link_args, "-Wl,-debug:dwarf");
+ if (opts->build_id) + strarray_add( &link_args, "-Wl,-build-id"); + if (opts->out_implib) strarray_add(&link_args, strmake("-Wl,-implib:%s", opts->out_implib)); else @@ -487,6 +494,9 @@ static struct strarray get_link_args( struct options *opts, const char *output_n break; }
+ if (opts->build_id) + strarray_add( &link_args, "-Wl,--build-id"); + /* generic Unix shared library flags */
strarray_add( &link_args, "-shared" ); @@ -1843,6 +1853,11 @@ int main(int argc, char **argv) opts.out_implib = xstrdup( Wl.str[++j] ); continue; } + if (!strcmp( Wl.str[j], "--build-id" )) + { + opts.build_id = 1; + continue; + } if (!strcmp(Wl.str[j], "-static")) linking = -1; strarray_add(&opts.linker_args, strmake("-Wl,%s",Wl.str[j])); }
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac index 1f01e5380c0..53f195e5ea0 100644 --- a/configure.ac +++ b/configure.ac @@ -1014,9 +1014,9 @@ This is an error since --enable-archs=$wine_arch was requested.])]) AS_VAR_SET([${wine_arch}_DEBUG],[$wine_crossdebug])
test "x$enable_werror" != xyes || WINE_TRY_PE_CFLAGS([-Werror]) - test "x$enable_build_id" != xyes || WINE_TRY_PE_CFLAGS([-Wl,--build-id], - [AS_VAR_APPEND([${wine_arch}_CFLAGS],[" -Wl,--build-id"]) - AS_VAR_APPEND([${wine_arch}_LDFLAGS],[" -Wl,--build-id"])]) + dnl clang for PE target wants -build-id (and not --build-id as gcc/mingw or clang in unix target) + dnl don't bother testing flags, compilation will fail afterwards + test "x$enable_build_id" != xyes || AS_VAR_APPEND([${wine_arch}_LDFLAGS],[" -Wl,--build-id"])
done
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- configure.ac | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/configure.ac b/configure.ac index 53f195e5ea0..ac710721ae6 100644 --- a/configure.ac +++ b/configure.ac @@ -1997,11 +1997,7 @@ int a(int b, ...) { __builtin_ms_va_list list; __builtin_ms_va_start(list,b); }] then WINE_TRY_CFLAGS([-Werror]) fi - if test "x$enable_build_id" = "xyes" - then - WINE_TRY_CFLAGS([-Wl,--build-id], [CFLAGS="$CFLAGS -Wl,--build-id" - LDFLAGS="$LDFLAGS -Wl,--build-id"]) - fi + test "x$enable_build_id" != xyes || WINE_TRY_CFLAGS([-Wl,--build-id], [LDFLAGS="$LDFLAGS -Wl,--build-id"]) fi
dnl **** Disable Fortify, it has too many false positives
On Tue Dec 3 08:15:44 2024 +0000, Jacek Caban wrote:
Unless I'm missing something, with your change to command line parser, we no longer store it in `linker_args`, so we don't pass it to the linker.
yes, I forgot that one.
V4 pushed: - re-add -Wl,--build-id in winegcc for unix compilation - added another change to not add -wl,--build-id to CFLAGS (clang when used for Unix compilation is generating a warning in that case)
pipeline build failure with clang is unrelated (sent [MR!6946](https://gitlab.winehq.org/wine/wine/-/merge_requests/6946 ) to fix it)
This merge request was approved by Jacek Caban.