* [PATCH] Fix ARM simulator build on Windows
@ 2021-12-09 14:02 Tom Tromey
2021-12-10 2:25 ` Mike Frysinger
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2021-12-09 14:02 UTC (permalink / raw)
To: gdb-patches; +Cc: Mike Frysinger, Tom Tromey
For a Windows-hosted build with arm-elf as the target, the sim build
fails like:
[...]sim-io.c:214:29: error: 'struct host_callback_struct' has no member named 'open'
The recent header reorganization seems to have caused this, because
now 'open' is redefined by the gnulib fcntl.h.
The fix is simple: remove the undef of 'open' from sim-io.c.
---
sim/common/sim-io.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/sim/common/sim-io.c b/sim/common/sim-io.c
index 8c40f7a0e73..8cc078c3cd2 100644
--- a/sim/common/sim-io.c
+++ b/sim/common/sim-io.c
@@ -37,8 +37,6 @@
#include "sim-io.h"
#include "sim/callback.h"
-#undef open
-
/* Define the rate at which the simulator should poll the host
for a quit. */
#ifndef POLL_QUIT_INTERVAL
--
2.31.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix ARM simulator build on Windows
2021-12-09 14:02 [PATCH] Fix ARM simulator build on Windows Tom Tromey
@ 2021-12-10 2:25 ` Mike Frysinger
2021-12-16 14:58 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Mike Frysinger @ 2021-12-10 2:25 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1768 bytes --]
On 09 Dec 2021 07:02, Tom Tromey wrote:
> For a Windows-hosted build with arm-elf as the target, the sim build
> fails like:
what is your --host ? guessing it's a mingw toolchain.
> [...]sim-io.c:214:29: error: 'struct host_callback_struct' has no member named 'open'
>
> The recent header reorganization seems to have caused this, because
> now 'open' is redefined by the gnulib fcntl.h.
yeah, i think that's why it started breaking.
> The fix is simple: remove the undef of 'open' from sim-io.c.
mmm, not that simple. the error you're seeing is because the open macro
rewrote the host_callback_struct structure. and then we tried to use it,
but they no longer matched.
include/sim/callback.h:
struct host_callback_struct {
int (*open) (host_callback *, const char*, int mode);
common/sim-io.c:
int sim_io_open (SIM_DESC sd, const char *name, int flags)
{
return STATE_CALLBACK (sd)->open (STATE_CALLBACK (sd), name, flags);
}
i'm not keen on relying on open being defined to a simple symbol name and thus
it will continue to compile. if it's defined to something more complicated, i
imagine it will still fail to compile.
#define open(args...) _foo_open(1234, ## args)
so i think it's better to move the undef between the system includes and the
local sim includes so it's undone for the header & source. this file doesn't
use actual open() call, so should be fine.
-mike
--- a/sim/common/sim-io.c
+++ b/sim/common/sim-io.c
@@ -33,12 +33,12 @@
#include <unistd.h>
#endif
+#undef open
+
#include "sim-main.h"
#include "sim-io.h"
#include "sim/callback.h"
-#undef open
-
/* Define the rate at which the simulator should poll the host
for a quit. */
#ifndef POLL_QUIT_INTERVAL
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix ARM simulator build on Windows
2021-12-10 2:25 ` Mike Frysinger
@ 2021-12-16 14:58 ` Tom Tromey
0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2021-12-16 14:58 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
>> For a Windows-hosted build with arm-elf as the target, the sim build
>> fails like:
Mike> what is your --host ? guessing it's a mingw toolchain.
Yeah: --host=i686-w64-mingw32
Mike> i'm not keen on relying on open being defined to a simple symbol name and thus
Mike> it will continue to compile. if it's defined to something more complicated, i
Mike> imagine it will still fail to compile.
Mike> #define open(args...) _foo_open(1234, ## args)
I'm not sure that's an allowable redefinition, but as long as the fix
works, it's fine by me. Thank you.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-16 14:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09 14:02 [PATCH] Fix ARM simulator build on Windows Tom Tromey
2021-12-10 2:25 ` Mike Frysinger
2021-12-16 14:58 ` Tom Tromey
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).