Page 1 of 1

Where did the Posix-GCC demo go?

Posted: Tue Oct 11, 2016 3:56 pm
by inca
Subject is the message.

Cheers

Re: Where did the Posix-GCC demo go?

Posted: Tue Oct 11, 2016 4:00 pm
by Giovanni
Hi,

It has not been ported yet past 2.6.x. It could be ported easily enough but there are always more urgent things to do...

Giovanni

Re: Where did the Posix-GCC demo go?

Posted: Sun Mar 12, 2017 7:19 am
by inca
Patch for stable_2.4.x Posix-GCC on OS X:

Code: Select all

diff --git i/demos/Posix-GCC/Makefile w/demos/Posix-GCC/Makefile
index 58a18f8..c90dc05 100644
--- i/demos/Posix-GCC/Makefile
+++ w/demos/Posix-GCC/Makefile
@@ -108,14 +108,14 @@ CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm $(DEFS)
 
 ifeq ($(HOST_OSX),yes)
   ifeq ($(OSX_SDK),)
-    OSX_SDK = /Developer/SDKs/MacOSX10.7.sdk
+    OSX_SDK = $(shell xcrun --show-sdk-path)
   endif
   ifeq ($(OSX_ARCH),)
-    OSX_ARCH = -mmacosx-version-min=10.3 -arch i386
+    OSX_ARCH = -mmacosx-version-min=$(shell sw_vers -productVersion | perl -pe 's/([0-9].?).([0-9].?).*/\1.\2/g') -arch i386
   endif
 
-  CPFLAGS += -isysroot $(OSX_SDK) $(OSX_ARCH)
-  LDFLAGS = -Wl -Map=$(PROJECT).map,-syslibroot,$(OSX_SDK),$(LIBDIR)
+  CPFLAGS += $(OSX_ARCH)
+  LDFLAGS = -Wl,-map,$(PROJECT).map
   LIBS += $(OSX_ARCH)
 else
   # Linux, or other
diff --git i/os/ports/GCC/SIMIA32/chcore.c w/os/ports/GCC/SIMIA32/chcore.c
index c1aaf17..96cccae 100644
--- i/os/ports/GCC/SIMIA32/chcore.c
+++ w/os/ports/GCC/SIMIA32/chcore.c
@@ -55,6 +55,18 @@ static void __dummy(Thread *ntp, Thread *otp) {
                 ".globl port_switch                             \n\t"
                 "port_switch:"
 #endif
+#if defined(__amd64__)
+                "push    %rbp                                   \n\t"
+                "push    %rsi                                   \n\t"
+                "push    %rdi                                   \n\t"
+                "push    %rbx                                   \n\t"
+                "mov     %rsp, 12(%rdx)                         \n\t"
+                "mov     12(%rcx), %rsp                         \n\t"
+                "pop     %rbx                                   \n\t"
+                "pop     %rdi                                   \n\t"
+                "pop     %rsi                                   \n\t"
+                "pop     %rbp                                   \n\t"
+#else // 32-bit
                 "push    %ebp                                   \n\t"
                 "push    %esi                                   \n\t"
                 "push    %edi                                   \n\t"
@@ -65,6 +77,7 @@ static void __dummy(Thread *ntp, Thread *otp) {
                 "pop     %edi                                   \n\t"
                 "pop     %esi                                   \n\t"
                 "pop     %ebp                                   \n\t"
+#endif
                 "ret");
 }
 

Re: Where did the Posix-GCC demo go?

Posted: Sun Mar 12, 2017 7:23 am
by Giovanni
Hi,

The demo has been reintroduced in the repository code and will be released in 17.3. It would be a good idea to patch the recent version, 2.4 is very old.

Giovanni

Re: Where did the Posix-GCC demo go?

Posted: Sun Mar 12, 2017 7:27 am
by inca
stable_2.6.x Posix-GCC

Code: Select all

diff --git i/demos/Posix-GCC/Makefile w/demos/Posix-GCC/Makefile
index c35a5f7..a3b6bde 100644
--- i/demos/Posix-GCC/Makefile
+++ w/demos/Posix-GCC/Makefile
@@ -109,14 +109,14 @@ CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm $(DEFS)

 ifeq ($(HOST_OSX),yes)
   ifeq ($(OSX_SDK),)
-    OSX_SDK = /Developer/SDKs/MacOSX10.7.sdk
+    OSX_SDK = $(shell xcrun --show-sdk-path)
   endif
   ifeq ($(OSX_ARCH),)
-    OSX_ARCH = -mmacosx-version-min=10.3 -arch i386
+    OSX_ARCH = -mmacosx-version-min=$(shell sw_vers -productVersion | perl -pe 's/([0-9].?).([0-9].?).*/\1.\2/g') -arch i386
   endif

-  CPFLAGS += -isysroot $(OSX_SDK) $(OSX_ARCH)
-  LDFLAGS = -Wl -Map=$(PROJECT).map,-syslibroot,$(OSX_SDK),$(LIBDIR)
+  CPFLAGS += $(OSX_ARCH)
+  LDFLAGS = -Wl,-map,$(PROJECT).map
   LIBS += $(OSX_ARCH)
 else
   # Linux, or other


EDIT: smaller diff

Re: Where did the Posix-GCC demo go?

Posted: Sun Mar 12, 2017 7:31 am
by Giovanni
Sorry, I should have specified:

The latest code is here: https://svn.code.sf.net/p/chibios/svn/trunk

The organization changed significantly compared to old versions.

Giovanni

Re: Where did the Posix-GCC demo go?

Posted: Sun Mar 12, 2017 8:32 am
by inca
Thanks, G. I am backporting in stages. I seem to have lost some files somewhere in between 2.6 and the latest, so smaller steps for now. =)

Re: Where did the Posix-GCC demo go?

Posted: Sun Mar 12, 2017 8:50 pm
by inca
Note: Previous patches are likely slightly incomplete due to my inability to git late at night.

3.0.x stable backport (zipped, attached).

Re: Where did the Posix-GCC demo go?

Posted: Sun Mar 12, 2017 9:17 pm
by inca
G, I think this brings us up to date.

A (trunk@10080) patch for POSIX gcc (clang) on OS X:

Code: Select all

diff --git i/demos/various/RT-Posix-Simulator/Makefile w/demos/various/RT-Posix-Simulator/Makefile
index 9578952..93237c5 100755
--- i/demos/various/RT-Posix-Simulator/Makefile
+++ w/demos/various/RT-Posix-Simulator/Makefile
@@ -135,6 +135,8 @@ CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes
 # Define C++ warning options here
 CPPWARN = -Wall -Wextra -Wundef
 
+
+
 #
 # Compiler settings
 ##############################################################################
diff --git i/demos/various/RT-Posix-Simulator/readme.txt w/demos/various/RT-Posix-Simulator/readme.txt
index 0b81e84..38f115e 100755
--- i/demos/various/RT-Posix-Simulator/readme.txt
+++ w/demos/various/RT-Posix-Simulator/readme.txt
@@ -19,7 +19,8 @@ See demo.c for details.
 
 ** Build Procedure **
 
-The demo was built using GCC.
+The demo was built using GCC. The Makefile defaults to building for a Linux host.
+To build on OS X, use the following command: `make HOST_OSX=yes`
 
 ** Connect to the demo **
 
diff --git i/os/common/startup/SIMIA32/compilers/GCC/rules.mk w/os/common/startup/SIMIA32/compilers/GCC/rules.mk
index 54c27f0..420912e 100644
--- i/os/common/startup/SIMIA32/compilers/GCC/rules.mk
+++ w/os/common/startup/SIMIA32/compilers/GCC/rules.mk
@@ -10,11 +10,13 @@ COPT = $(USE_COPT)
 CPPOPT = $(USE_CPPOPT)
 
 # Garbage collection
-ifeq ($(USE_LINK_GC),yes)
-  OPT += -ffunction-sections -fdata-sections -fno-common
-  LDOPT := --gc-sections
-else
-  LDOPT := --no-gc-sections
+ifneq ($(HOST_OSX),yes) # Do not use GC on OS X. LD does not support it.
+  ifeq ($(USE_LINK_GC),yes)
+    OPT += -ffunction-sections -fdata-sections -fno-common
+    LDOPT := --gc-sections
+  else
+    LDOPT := --no-gc-sections
+  endif
 endif
 
 # Linker extra options
@@ -66,11 +68,19 @@ LIBS      = $(DLIBS) $(ULIBS)
 # Various settings
 MCFLAGS   =
 ODFLAGS     = -x --syms
-ASFLAGS   = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
-ASXFLAGS  = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.S=.lst)) $(ADEFS)
-CFLAGS    = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.c=.lst)) $(DEFS)
-CPPFLAGS  = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.cpp=.lst)) $(DEFS)
-LDFLAGS   = $(MCFLAGS) $(OPT) $(LLIBDIR) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,$(LDOPT)
+ifeq ($(HOST_OSX),yes)
+  ASFLAGS   = $(MCFLAGS) $(ADEFS)
+  ASXFLAGS  = $(MCFLAGS) $(ADEFS)
+  CFLAGS    = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) $(DEFS)
+  CPPFLAGS  = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) $(DEFS)
+  LDFLAGS   = $(MCFLAGS) $(OPT) $(LLIBDIR) -Wl,-map,$(BUILDDIR)/$(PROJECT).map,$(LDOPT)
+else
+  ASFLAGS   = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
+  ASXFLAGS  = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.S=.lst)) $(ADEFS)
+  CFLAGS    = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.c=.lst)) $(DEFS)
+  CPPFLAGS  = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.cpp=.lst)) $(DEFS)
+  LDFLAGS   = $(MCFLAGS) $(OPT) $(LLIBDIR) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,$(LDOPT)
+endif
 
 # Generate dependency information
 ASFLAGS  += -MD -MP -MF .dep/$(@F).d