public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Statically link libwinpthread-1.dll in gdbserver
@ 2022-05-02 12:11 Claude Robitaille
  2022-05-02 13:27 ` Pedro Alves
  0 siblings, 1 reply; 8+ messages in thread
From: Claude Robitaille @ 2022-05-02 12:11 UTC (permalink / raw)
  To: gdb

Hi,

I am trying to produce a statically linked gdbserver (except the distribution DLL from Windows). I have everything in except for libwinpthread-1.dll. I
guess gdbserver should be linked with libwinpthread.a but how to tell the build system to do so?

I am using this command line to configure:
../binutils-gdb/configure --enable-static --with-static-standard-libraries --disable-gdb --host=x86_64-w64-mingw32

and then followed by
make

Using objdump, I see that the following DLL are needed by the binary
KERNEL32.dll
msvcrt.dll
libwinpthread-1.dll
USER32.dll
WS2_32.dll

As you can see from the command line, I am using mingw-w64. I am using the stock Ubuntu 20.04 package for it, which includes the following library files for pthread
-rw-r--r-- 1 root root 388692 Nov 15  2019 libpthread.a
-rw-r--r-- 1 root root  88994 Nov 15  2019 libpthread.dll.a
-rwxr-xr-x 1 root root 621013 Nov 15  2019 libwinpthread-1.dll
-rw-r--r-- 1 root root 388692 Nov 15  2019 libwinpthread.a
-rw-r--r-- 1 root root  88994 Nov 15  2019 libwinpthread.dll.a



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Statically link libwinpthread-1.dll in gdbserver
  2022-05-02 12:11 Statically link libwinpthread-1.dll in gdbserver Claude Robitaille
@ 2022-05-02 13:27 ` Pedro Alves
  2022-05-02 13:33   ` Claude Robitaille
  0 siblings, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2022-05-02 13:27 UTC (permalink / raw)
  To: Claude Robitaille, gdb

On 2022-05-02 13:11, Claude Robitaille via Gdb wrote:
> Hi,
> 
> I am trying to produce a statically linked gdbserver (except the distribution DLL from Windows). I have everything in except for libwinpthread-1.dll. I
> guess gdbserver should be linked with libwinpthread.a but how to tell the build system to do so?
> 
> I am using this command line to configure:
> ../binutils-gdb/configure --enable-static --with-static-standard-libraries --disable-gdb --host=x86_64-w64-mingw32
> 
> and then followed by
> make
> 
> Using objdump, I see that the following DLL are needed by the binary
> KERNEL32.dll
> msvcrt.dll
> libwinpthread-1.dll
> USER32.dll
> WS2_32.dll
> 
> As you can see from the command line, I am using mingw-w64. I am using the stock Ubuntu 20.04 package for it, which includes the following library files for pthread
> -rw-r--r-- 1 root root 388692 Nov 15  2019 libpthread.a
> -rw-r--r-- 1 root root  88994 Nov 15  2019 libpthread.dll.a
> -rwxr-xr-x 1 root root 621013 Nov 15  2019 libwinpthread-1.dll
> -rw-r--r-- 1 root root 388692 Nov 15  2019 libwinpthread.a
> -rw-r--r-- 1 root root  88994 Nov 15  2019 libwinpthread.dll.a
> 
> 

Have you tried passing "-static" in CFLAGS/CXXFLAGS?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Statically link libwinpthread-1.dll in gdbserver
  2022-05-02 13:27 ` Pedro Alves
@ 2022-05-02 13:33   ` Claude Robitaille
  2022-05-02 13:37     ` Pedro Alves
  0 siblings, 1 reply; 8+ messages in thread
From: Claude Robitaille @ 2022-05-02 13:33 UTC (permalink / raw)
  To: Pedro Alves, gdb

No. I did not try.

But, if I do this on the top level configure command line, wouldn't then everything be statically linked? Is it possible to pass this falg only to the gdbserver configure command?
________________________________
From: Pedro Alves <pedro@palves.net>
Sent: May 2, 2022 9:27 AM
To: Claude Robitaille <claude-robitaille@hotmail.com>; gdb@sourceware.org <gdb@sourceware.org>
Subject: Re: Statically link libwinpthread-1.dll in gdbserver

On 2022-05-02 13:11, Claude Robitaille via Gdb wrote:
> Hi,
>
> I am trying to produce a statically linked gdbserver (except the distribution DLL from Windows). I have everything in except for libwinpthread-1.dll. I
> guess gdbserver should be linked with libwinpthread.a but how to tell the build system to do so?
>
> I am using this command line to configure:
> ../binutils-gdb/configure --enable-static --with-static-standard-libraries --disable-gdb --host=x86_64-w64-mingw32
>
> and then followed by
> make
>
> Using objdump, I see that the following DLL are needed by the binary
> KERNEL32.dll
> msvcrt.dll
> libwinpthread-1.dll
> USER32.dll
> WS2_32.dll
>
> As you can see from the command line, I am using mingw-w64. I am using the stock Ubuntu 20.04 package for it, which includes the following library files for pthread
> -rw-r--r-- 1 root root 388692 Nov 15  2019 libpthread.a
> -rw-r--r-- 1 root root  88994 Nov 15  2019 libpthread.dll.a
> -rwxr-xr-x 1 root root 621013 Nov 15  2019 libwinpthread-1.dll
> -rw-r--r-- 1 root root 388692 Nov 15  2019 libwinpthread.a
> -rw-r--r-- 1 root root  88994 Nov 15  2019 libwinpthread.dll.a
>
>

Have you tried passing "-static" in CFLAGS/CXXFLAGS?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Statically link libwinpthread-1.dll in gdbserver
  2022-05-02 13:33   ` Claude Robitaille
@ 2022-05-02 13:37     ` Pedro Alves
  2022-05-02 17:12       ` Claude Robitaille
  0 siblings, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2022-05-02 13:37 UTC (permalink / raw)
  To: Claude Robitaille, gdb

On 2022-05-02 14:33, Claude Robitaille wrote:
> Pedro Alves wrote:
> Have you tried passing "-static" in CFLAGS/CXXFLAGS?
>
> No. I did not try.
> 
> But, if I do this on the top level configure command line, wouldn't then everything be statically linked? Is it possible to pass this falg only to the gdbserver configure command?

No, but you can use --disable-foo / --disable-foo to control which top level components
you want to build, and/or use "make all-gdbserver" to build just gdbserver.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Statically link libwinpthread-1.dll in gdbserver
  2022-05-02 13:37     ` Pedro Alves
@ 2022-05-02 17:12       ` Claude Robitaille
  2022-05-02 17:18         ` Pedro Alves
  0 siblings, 1 reply; 8+ messages in thread
From: Claude Robitaille @ 2022-05-02 17:12 UTC (permalink / raw)
  To: Pedro Alves, gdb

"make all-gdbserver" fails. But just make works, albeit a little longer...

So, I now have a solution thanks.

Just curious. --disable-foo is nice but the problem is to get a list of foo. Is there anyway other than sifting the script and metadata files?

./configure --help or ./configure --help-recursive are not that helpful.

________________________________
From: Pedro Alves <pedro@palves.net>
Sent: May 2, 2022 9:37 AM
To: Claude Robitaille <claude-robitaille@hotmail.com>; gdb@sourceware.org <gdb@sourceware.org>
Subject: Re: Statically link libwinpthread-1.dll in gdbserver

On 2022-05-02 14:33, Claude Robitaille wrote:
> Pedro Alves wrote:
> Have you tried passing "-static" in CFLAGS/CXXFLAGS?
>
> No. I did not try.
>
> But, if I do this on the top level configure command line, wouldn't then everything be statically linked? Is it possible to pass this falg only to the gdbserver configure command?

No, but you can use --disable-foo / --disable-foo to control which top level components
you want to build, and/or use "make all-gdbserver" to build just gdbserver.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Statically link libwinpthread-1.dll in gdbserver
  2022-05-02 17:12       ` Claude Robitaille
@ 2022-05-02 17:18         ` Pedro Alves
  2022-05-02 17:54           ` Claude Robitaille
  0 siblings, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2022-05-02 17:18 UTC (permalink / raw)
  To: Claude Robitaille, gdb

On 2022-05-02 18:12, Claude Robitaille wrote:
> "make all-gdbserver" fails. But just make works, albeit a little longer...

"make all-gdbserver" failing is really strange.  How did it fail?  Note that should
be issued at the top level.

> 
> So, I now have a solution thanks.
> 
> Just curious. --disable-foo is nice but the problem is to get a list of foo. Is there anyway other than sifting the script and metadata files?
> 
> ./configure --help or ./configure --help-recursive are not that helpful.

I'm now aware of a way to get that list.  I think all component names match their corresponding top level directory
names, at least.  There are more directories than components, though.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Statically link libwinpthread-1.dll in gdbserver
  2022-05-02 17:18         ` Pedro Alves
@ 2022-05-02 17:54           ` Claude Robitaille
  2022-05-02 18:39             ` Pedro Alves
  0 siblings, 1 reply; 8+ messages in thread
From: Claude Robitaille @ 2022-05-02 17:54 UTC (permalink / raw)
  To: Pedro Alves, gdb

This is what I get with make all-gdbserver

  CXX    alloc.o
In file included from ../../binutils-gdb/gdbserver/../gdbsupport/common-defs.h:197,
                 from ../../binutils-gdb/gdbserver/../gdb/alloc.c:37:
../../binutils-gdb/gdbserver/../gdbsupport/gdb_locale.h:27:11: fatal error: libintl.h: No such file or directory
   27 | # include <libintl.h>
      |           ^~~~~~~~~~~
compilation terminated.

This is the complete configuration command line I was using

export CFLAGS=-static; export CXXFLAGS=-static; ../binutils-gdb/configure --enable-static --with-static-standard-libraries --disable-gdb --host=x86_64-w64-mingw32

The binutils source I am using is
commit f0072f79e12d88ca361de04a52434430a10c5f0e (HEAD -> gdb-12-branch, origin/gdb-12-branch)

(about 2 weeks old).
________________________________
From: Pedro Alves <pedro@palves.net>
Sent: May 2, 2022 1:18 PM
To: Claude Robitaille <claude-robitaille@hotmail.com>; gdb@sourceware.org <gdb@sourceware.org>
Subject: Re: Statically link libwinpthread-1.dll in gdbserver

On 2022-05-02 18:12, Claude Robitaille wrote:
> "make all-gdbserver" fails. But just make works, albeit a little longer...

"make all-gdbserver" failing is really strange.  How did it fail?  Note that should
be issued at the top level.

>
> So, I now have a solution thanks.
>
> Just curious. --disable-foo is nice but the problem is to get a list of foo. Is there anyway other than sifting the script and metadata files?
>
> ./configure --help or ./configure --help-recursive are not that helpful.

I'm now aware of a way to get that list.  I think all component names match their corresponding top level directory
names, at least.  There are more directories than components, though.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Statically link libwinpthread-1.dll in gdbserver
  2022-05-02 17:54           ` Claude Robitaille
@ 2022-05-02 18:39             ` Pedro Alves
  0 siblings, 0 replies; 8+ messages in thread
From: Pedro Alves @ 2022-05-02 18:39 UTC (permalink / raw)
  To: Claude Robitaille, gdb

On 2022-05-02 18:54, Claude Robitaille wrote:
> This is what I get with make all-gdbserver
> 
>   CXX    alloc.o
> In file included from ../../binutils-gdb/gdbserver/../gdbsupport/common-defs.h:197,
>                  from ../../binutils-gdb/gdbserver/../gdb/alloc.c:37:
> ../../binutils-gdb/gdbserver/../gdbsupport/gdb_locale.h:27:11: fatal error: libintl.h: No such file or directory
>    27 | # include <libintl.h>
>       |           ^~~~~~~~~~~
> compilation terminated.
> 
> This is the complete configuration command line I was using
> 
> export CFLAGS=-static; export CXXFLAGS=-static; ../binutils-gdb/configure --enable-static --with-static-standard-libraries --disable-gdb --host=x86_64-w64-mingw32

Thanks.  I'm not setup to build gdb/gdbserver on mingw fully currently (Ubuntu 20.04's mingw gcc doesn't support
std::future), but I'm able to run that configure, and build alloc.o only, and I see the same:

$ make -C gdbserver alloc.o
make: Entering directory '/home/pedro/gdb/binutils-gdb/build-mingw-test/gdbserver'
  CXX    alloc.o
In file included from ../../src/gdbserver/../gdbsupport/common-defs.h:197,
                 from ../../src/gdbserver/../gdb/alloc.c:37:
../../src/gdbserver/../gdbsupport/gdb_locale.h:27:11: fatal error: libintl.h: No such file or directory
   27 | # include <libintl.h>
      |           ^~~~~~~~~~~
compilation terminated.
make: *** [Makefile:553: alloc.o] Error 1
make: Leaving directory '/home/pedro/gdb/binutils-gdb/build-mingw-test/gdbserver'


gdb_locale.h has:

 #ifdef ENABLE_NLS
 # include <libintl.h>
 # define _(String) gettext (String)
 # ifdef gettext_noop

so we should only include libint.h if ENABLE_NLS is defined.

I noticed that:

In build/intl/ I a fully built intl, including a intl/config.intl with the
expected values when using the in-tree intl:

 ...
 USE_NLS='yes'
 LIBINTL='-L${top_builddir}/../intl -lintl'
 LIBINTL_DEP='${top_builddir}/../intl/libintl.a'
 INCINTL='-I${top_builddir}/../intl'
 ...

however, gdbserver's Makefile ended up with the default/empty:

 # Where is the INTL library?  Typically in ../intl.
 INTL = 
 INTL_DEPS = 
 INTL_CFLAGS = 

Looking a bit deeper, I see I ended up with a mismatch between
gdbsupport and gdbserver, one thinks we're using intl, the other one doesn't:

 $ grep ENABLE_NLS gdbserver/config.h 
 /* #undef ENABLE_NLS */

 $ grep ENABLE_NLS gdbsupport/config.h 
 #define ENABLE_NLS 1

Sounds like that may be the problem.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-05-02 18:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 12:11 Statically link libwinpthread-1.dll in gdbserver Claude Robitaille
2022-05-02 13:27 ` Pedro Alves
2022-05-02 13:33   ` Claude Robitaille
2022-05-02 13:37     ` Pedro Alves
2022-05-02 17:12       ` Claude Robitaille
2022-05-02 17:18         ` Pedro Alves
2022-05-02 17:54           ` Claude Robitaille
2022-05-02 18:39             ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).