You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/03/27 05:04:53 UTC

[incubator-nuttx] 06/07: sim: MODULE definitions for macOS

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 748777e3f5f61ccadefac19c0e32b25c13475e44
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Mar 26 11:28:08 2020 +0900

    sim: MODULE definitions for macOS
---
 boards/sim/sim/sim/configs/cxxtest/Make.defs | 12 ++++++++++++
 boards/sim/sim/sim/configs/nsh2/Make.defs    | 12 ++++++++++++
 boards/sim/sim/sim/scripts/Make.defs         | 12 ++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/boards/sim/sim/sim/configs/cxxtest/Make.defs b/boards/sim/sim/sim/configs/cxxtest/Make.defs
index 633eed8..dfab860 100644
--- a/boards/sim/sim/sim/configs/cxxtest/Make.defs
+++ b/boards/sim/sim/sim/configs/cxxtest/Make.defs
@@ -86,6 +86,18 @@ else
   LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld
 endif
 
+# NuttX modules are ELF binaries.
+# Non-ELF platforms like macOS need to use a separate ELF toolchain.
+ifeq ($(CONFIG_HOST_MACOS),y)
+  # eg. brew install x86_64-elf-gcc
+  MODULECC = x86_64-elf-gcc
+  MODULELD = x86_64-elf-ld
+  # It seems macOS/x86_64 loads the program text around 00000001_xxxxxxxx.
+  # The gcc default (-mcmodel=small) would produce out-of-range 32-bit
+  # relocations.
+  CMODULEFLAGS += -mcmodel=large
+endif
+
 # ELF module definitions
 
 CELFFLAGS = $(CFLAGS)
diff --git a/boards/sim/sim/sim/configs/nsh2/Make.defs b/boards/sim/sim/sim/configs/nsh2/Make.defs
index 21e67fc..4b18758 100644
--- a/boards/sim/sim/sim/configs/nsh2/Make.defs
+++ b/boards/sim/sim/sim/configs/nsh2/Make.defs
@@ -82,6 +82,18 @@ else
   LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld
 endif
 
+# NuttX modules are ELF binaries.
+# Non-ELF platforms like macOS need to use a separate ELF toolchain.
+ifeq ($(CONFIG_HOST_MACOS),y)
+  # eg. brew install x86_64-elf-gcc
+  MODULECC = x86_64-elf-gcc
+  MODULELD = x86_64-elf-ld
+  # It seems macOS/x86_64 loads the program text around 00000001_xxxxxxxx.
+  # The gcc default (-mcmodel=small) would produce out-of-range 32-bit
+  # relocations.
+  CMODULEFLAGS += -mcmodel=large
+endif
+
 # ELF module definitions
 
 CELFFLAGS = $(CFLAGS)
diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs
index c49735e..c338812 100644
--- a/boards/sim/sim/sim/scripts/Make.defs
+++ b/boards/sim/sim/sim/scripts/Make.defs
@@ -88,6 +88,18 @@ else
   LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld
 endif
 
+# NuttX modules are ELF binaries.
+# Non-ELF platforms like macOS need to use a separate ELF toolchain.
+ifeq ($(CONFIG_HOST_MACOS),y)
+  # eg. brew install x86_64-elf-gcc
+  MODULECC = x86_64-elf-gcc
+  MODULELD = x86_64-elf-ld
+  # It seems macOS/x86_64 loads the program text around 00000001_xxxxxxxx.
+  # The gcc default (-mcmodel=small) would produce out-of-range 32-bit
+  # relocations.
+  CMODULEFLAGS += -mcmodel=large
+endif
+
 # ELF module definitions
 
 CELFFLAGS = $(CFLAGS)