From 7f1ffd3d31917a65d296f856a841b3255ff0d143 Mon Sep 17 00:00:00 2001 From: patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> Date: Tue, 17 Jan 2012 17:42:31 +0000 Subject: [PATCH] Add support for building 32-bit simulation on a 64-bit target git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4307 42af7a65-404d-4744-a932-0658087f49c3 --- ChangeLog | 2 ++ TODO | 19 ++----------------- arch/sim/src/Makefile | 10 ++++------ configs/sim/README.txt | 11 ++++++++--- configs/sim/mount/Make.defs | 23 ++++++++++++++++++++--- configs/sim/nettest/Make.defs | 23 ++++++++++++++++++++--- configs/sim/nsh/Make.defs | 23 ++++++++++++++++++++--- configs/sim/nsh2/Make.defs | 23 ++++++++++++++++++++--- configs/sim/nx/Make.defs | 23 ++++++++++++++++++++--- configs/sim/nxffs/Make.defs | 23 ++++++++++++++++++++--- configs/sim/ostest/Make.defs | 23 ++++++++++++++++++++--- configs/sim/pashello/Make.defs | 24 +++++++++++++++++++++--- 12 files changed, 177 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8531c341d6..dfc703183b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2374,3 +2374,5 @@ one APB2 timer. * arch/mips/src/pic32mx/pic32mx-ethernet.c: The PIC32 Ethernet driver is code complete, but still untested. + * confgs/sim/*/Make.defs and arch/sim/src/Makefile: Add support for building + a 32-bit executable on a 64-bit Linux target. diff --git a/TODO b/TODO index 29ac94ce6d..f4a154a23f 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -NuttX TODO List (Last updated January 3, 2012) +NuttX TODO List (Last updated January 17, 2012) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This file summarizes known NuttX bugs, limitations, inconsistencies with @@ -21,7 +21,7 @@ nuttx/ (1) Pascal add-on (pcode/) (1) Documentation (Documentation/) (7) Build system / Toolchains - (6) Linux/Cywgin simulation (arch/sim) + (5) Linux/Cywgin simulation (arch/sim) (4) ARM (arch/arm/) (1) ARM/C5471 (arch/arm/src/c5471/) (3) ARM/DM320 (arch/arm/src/dm320/) @@ -752,21 +752,6 @@ o Linux/Cywgin simulation (arch/sim) Status: Open Priority: Low (because the simulator is only a test/development platform) - Title: SIMULATOR BUILD ON 64-BIT MACHINES - Description: Simulator does not build correctly on 64-bit machines. Two - issues: - 1) It saves addresses in 32-bit types and these fail when cast - to pointers on a 64-bit host. - 2) up_setjmp.S does not build - Status: Open - Priority: Medium and increasing (as 32-bit hosts gradually disappear). NOTE - is it possible to work-around this limitation by building the sim - target for 32-bit operation on a 64-bit platform. Modify the - Make.defs file in the appropriate places so that -m32 is included - in the CFLAGS and -m32 and -melf_386 are included in the LDFLAGS. - See the patch 0001-Quick-hacks-to-build-sim-nsh-ostest-on-x86_64-as-32-.patch - that can be found at http://tech.groups.yahoo.com/group/nuttx/files. - Title: SIMULATOR NETWORKING SUPPORT Description: I never did get networking to work on the sim Linux target. On Linux, it tries to use the tap device (/dev/net/tun) to emulate an Ethernet diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile index bf26b32a9c..9189a2165d 100644 --- a/arch/sim/src/Makefile +++ b/arch/sim/src/Makefile @@ -1,8 +1,8 @@ ############################################################################ # arch/sim/src/Makefile # -# Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# Copyright (C) 2007, 2008, 2011-2012 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -87,8 +87,6 @@ HOSTOBJS = $(HOSTSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) $(HOSTSRCS) OBJS = $(AOBJS) $(COBJS) $(HOSTOBJS) -LDFLAGS = $(ARCHSCRIPT) - # Determine which standard libraries will need to be linked in ifeq ($(CONFIG_SIM_X11FB),y) @@ -173,7 +171,7 @@ Cygwin-names.dat: nuttx-names.dat nuttx.rel : libarch$(LIBEXT) board/libboard$(LIBEXT) $(HOSTOS)-names.dat $(LINKOBJS) @echo "LD: nuttx.rel" - @$(LD) -r $(LDFLAGS) $(LDPATHS) -o $@ $(REQUIREDOBJS) --start-group $(LDLIBS) --end-group $(EXTRA_LIBS) + @$(LD) -r $(LDLINKFLAGS) $(LDPATHS) -o $@ $(REQUIREDOBJS) --start-group $(LDLIBS) --end-group $(EXTRA_LIBS) @$(OBJCOPY) --redefine-syms=$(HOSTOS)-names.dat $@ # Generate the final NuttX binary by linking the host-specific objects with the NuttX @@ -181,7 +179,7 @@ nuttx.rel : libarch$(LIBEXT) board/libboard$(LIBEXT) $(HOSTOS)-names.dat $(LINKO nuttx$(EXEEXT): cleanrel nuttx.rel $(HOSTOBJS) @echo "LD: nuttx$(EXEEXT)" - @$(CC) $(LDFLAGS) $(LDPATHS) -o $(TOPDIR)/$@ nuttx.rel $(HOSTOBJS) $(DRVLIB) $(STDLIBS) + @$(CC) $(CCLINKFLAGS) $(LDPATHS) -o $(TOPDIR)/$@ nuttx.rel $(HOSTOBJS) $(DRVLIB) $(STDLIBS) @$(NM) $(TOPDIR)/$@ | \ grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ sort > $(TOPDIR)/System.map diff --git a/configs/sim/README.txt b/configs/sim/README.txt index b5c057e05e..c7005271cf 100644 --- a/configs/sim/README.txt +++ b/configs/sim/README.txt @@ -97,10 +97,15 @@ addresses should not be retained in uint32_t types but rather in uintptr_t types to avoid issues just like this. The workaround on 64-bit machines for now is to build for a 32-bit target on the -64-bit machine. This workaround involves modifying the Make.defs file in the +64-bit machine. The workaround for this issue has been included in NuttX 6.15 and +beyond. For thoses versions, you must add CONFIG_SIM_M32=y to the .config file in +order to enable building a 32-bit image on a 64-bit platform. + +For older versions of NuttX, a patch also exists. The patch the Make.defs file in the appropriate places so that -m32 is included in the CFLAGS and -m32 and -melf_386 -are included in the LDFLAGS. See the patch 0001-Quick-hacks-to-build-sim-nsh-ostest-on-x86_64-as-32-.patch -that can be found at http://tech.groups.yahoo.com/group/nuttx/files. +are included in the LDFLAGS. See the patch +0001-Quick-hacks-to-build-sim-nsh-ostest-on-x86_64-as-32-.patch that can be found at +http://tech.groups.yahoo.com/group/nuttx/files. Stack Size Issues ----------------- diff --git a/configs/sim/mount/Make.defs b/configs/sim/mount/Make.defs index 498291077d..e3e1a8576a 100644 --- a/configs/sim/mount/Make.defs +++ b/configs/sim/mount/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # configs/sim/mount/Make.defs # -# Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2008, 2011-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -53,6 +53,11 @@ ARCHINCLUDES = -I. -isystem $(TOPDIR)/include ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx ARCHSCRIPT = +ifeq ($(CONFIG_SIM_M32),y) + ARCHCPUFLAGS += -m32 + ARCHCPUFLAGSXX += -m32 +endif + CROSSDEV = CC = $(CROSSDEV)gcc CXX = $(CROSSDEV)g++ @@ -79,8 +84,20 @@ else EXEEXT = endif -ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") - LDFLAGS += -g +LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD) +CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC) +LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDLINKFLAGS += -g + CCLINKFLAGS += -g + LDFLAGS += -g +endif + +ifeq ($(CONFIG_SIM_M32),y) + LDLINKFLAGS += -melf_i386 + CCLINKFLAGS += -m32 + LDFLAGS += -m32 endif define PREPROCESS diff --git a/configs/sim/nettest/Make.defs b/configs/sim/nettest/Make.defs index cf0134b9b0..a1052492a4 100644 --- a/configs/sim/nettest/Make.defs +++ b/configs/sim/nettest/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # configs/sim/Make.defs # -# Copyright (C) 2007-2008, 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2007-2008, 2011-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -53,6 +53,11 @@ ARCHINCLUDES = -I. -isystem $(TOPDIR)/include ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx ARCHSCRIPT = +ifeq ($(CONFIG_SIM_M32),y) + ARCHCPUFLAGS += -m32 + ARCHCPUFLAGSXX += -m32 +endif + CROSSDEV = CC = $(CROSSDEV)gcc CXX = $(CROSSDEV)g++ @@ -79,8 +84,20 @@ else EXEEXT = endif -ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") - LDFLAGS += -g +LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD) +CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC) +LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDLINKFLAGS += -g + CCLINKFLAGS += -g + LDFLAGS += -g +endif + +ifeq ($(CONFIG_SIM_M32),y) + LDLINKFLAGS += -melf_i386 + CCLINKFLAGS += -m32 + LDFLAGS += -m32 endif define PREPROCESS diff --git a/configs/sim/nsh/Make.defs b/configs/sim/nsh/Make.defs index 1330ade1e0..83bc35d76b 100644 --- a/configs/sim/nsh/Make.defs +++ b/configs/sim/nsh/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # configs/sim/nsh/Make.defs # -# Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2008, 2011-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -53,6 +53,11 @@ ARCHINCLUDES = -I. -isystem $(TOPDIR)/include ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx ARCHSCRIPT = +ifeq ($(CONFIG_SIM_M32),y) + ARCHCPUFLAGS += -m32 + ARCHCPUFLAGSXX += -m32 +endif + CROSSDEV = CC = $(CROSSDEV)gcc CXX = $(CROSSDEV)g++ @@ -79,8 +84,20 @@ else EXEEXT = endif -ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") - LDFLAGS += -g +LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD) +CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC) +LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDLINKFLAGS += -g + CCLINKFLAGS += -g + LDFLAGS += -g +endif + +ifeq ($(CONFIG_SIM_M32),y) + LDLINKFLAGS += -melf_i386 + CCLINKFLAGS += -m32 + LDFLAGS += -m32 endif define PREPROCESS diff --git a/configs/sim/nsh2/Make.defs b/configs/sim/nsh2/Make.defs index 39b33dc7dc..7fba83b726 100644 --- a/configs/sim/nsh2/Make.defs +++ b/configs/sim/nsh2/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # configs/sim/nsh2/Make.defs # -# Copyright (C) Gregory Nutt. All rights reserved. +# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -54,6 +54,11 @@ ARCHINCLUDES = -I. -isystem $(TOPDIR)/include ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx ARCHSCRIPT = +ifeq ($(CONFIG_SIM_M32),y) + ARCHCPUFLAGS += -m32 + ARCHCPUFLAGSXX += -m32 +endif + CROSSDEV = CC = $(CROSSDEV)gcc CXX = $(CROSSDEV)g++ @@ -80,8 +85,20 @@ else EXEEXT = endif -ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") - LDFLAGS += -g +LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD) +CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC) +LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDLINKFLAGS += -g + CCLINKFLAGS += -g + LDFLAGS += -g +endif + +ifeq ($(CONFIG_SIM_M32),y) + LDLINKFLAGS += -melf_i386 + CCLINKFLAGS += -m32 + LDFLAGS += -m32 endif define PREPROCESS diff --git a/configs/sim/nx/Make.defs b/configs/sim/nx/Make.defs index 70f6066e19..91e42acedf 100644 --- a/configs/sim/nx/Make.defs +++ b/configs/sim/nx/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # configs/sim/nx/Make.defs # -# Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2008, 2011-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -53,6 +53,11 @@ ARCHINCLUDES = -I. -isystem $(TOPDIR)/include ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx ARCHSCRIPT = +ifeq ($(CONFIG_SIM_M32),y) + ARCHCPUFLAGS += -m32 + ARCHCPUFLAGSXX += -m32 +endif + CROSSDEV = CC = $(CROSSDEV)gcc CXX = $(CROSSDEV)g++ @@ -79,8 +84,20 @@ else EXEEXT = endif -ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") - LDFLAGS += -g +LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD) +CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC) +LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDLINKFLAGS += -g + CCLINKFLAGS += -g + LDFLAGS += -g +endif + +ifeq ($(CONFIG_SIM_M32),y) + LDLINKFLAGS += -melf_i386 + CCLINKFLAGS += -m32 + LDFLAGS += -m32 endif define PREPROCESS diff --git a/configs/sim/nxffs/Make.defs b/configs/sim/nxffs/Make.defs index 9010d2bb46..e7d5b6d50f 100644 --- a/configs/sim/nxffs/Make.defs +++ b/configs/sim/nxffs/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # configs/sim/nxffs/Make.defs # -# Copyright (C) 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -53,6 +53,11 @@ ARCHINCLUDES = -I. -isystem $(TOPDIR)/include ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx ARCHSCRIPT = +ifeq ($(CONFIG_SIM_M32),y) + ARCHCPUFLAGS += -m32 + ARCHCPUFLAGSXX += -m32 +endif + CROSSDEV = CC = $(CROSSDEV)gcc CXX = $(CROSSDEV)g++ @@ -79,8 +84,20 @@ else EXEEXT = endif -ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") - LDFLAGS += -g +LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD) +CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC) +LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDLINKFLAGS += -g + CCLINKFLAGS += -g + LDFLAGS += -g +endif + +ifeq ($(CONFIG_SIM_M32),y) + LDLINKFLAGS += -melf_i386 + CCLINKFLAGS += -m32 + LDFLAGS += -m32 endif define PREPROCESS diff --git a/configs/sim/ostest/Make.defs b/configs/sim/ostest/Make.defs index cf0134b9b0..a1052492a4 100644 --- a/configs/sim/ostest/Make.defs +++ b/configs/sim/ostest/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # configs/sim/Make.defs # -# Copyright (C) 2007-2008, 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2007-2008, 2011-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -53,6 +53,11 @@ ARCHINCLUDES = -I. -isystem $(TOPDIR)/include ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx ARCHSCRIPT = +ifeq ($(CONFIG_SIM_M32),y) + ARCHCPUFLAGS += -m32 + ARCHCPUFLAGSXX += -m32 +endif + CROSSDEV = CC = $(CROSSDEV)gcc CXX = $(CROSSDEV)g++ @@ -79,8 +84,20 @@ else EXEEXT = endif -ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") - LDFLAGS += -g +LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD) +CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC) +LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDLINKFLAGS += -g + CCLINKFLAGS += -g + LDFLAGS += -g +endif + +ifeq ($(CONFIG_SIM_M32),y) + LDLINKFLAGS += -melf_i386 + CCLINKFLAGS += -m32 + LDFLAGS += -m32 endif define PREPROCESS diff --git a/configs/sim/pashello/Make.defs b/configs/sim/pashello/Make.defs index 40dc5acb15..6f662adc03 100644 --- a/configs/sim/pashello/Make.defs +++ b/configs/sim/pashello/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # configs/sim/pashello/Make.defs # -# Copyright (C) 2007-2008, 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2007-2008, 2011-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -53,6 +53,11 @@ ARCHINCLUDES = -I. -isystem $(TOPDIR)/include ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx ARCHSCRIPT = +ifeq ($(CONFIG_SIM_M32),y) + ARCHCPUFLAGS += -m32 + ARCHCPUFLAGSXX += -m32 +endif + CROSSDEV = CC = $(CROSSDEV)gcc CXX = $(CROSSDEV)g++ @@ -79,9 +84,22 @@ else EXEEXT = endif -ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") - LDFLAGS += -g +LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD) +CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC) +LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDLINKFLAGS += -g + CCLINKFLAGS += -g + LDFLAGS += -g endif + +ifeq ($(CONFIG_SIM_M32),y) + LDLINKFLAGS += -melf_i386 + CCLINKFLAGS += -m32 + LDFLAGS += -m32 +endif + EXTRA_LIBS = -lm define PREPROCESS -- GitLab