Posix Simulator for Mac OS X 10.7.5

This forum is about you. Feel free to discuss anything is related to embedded and electronics, your awesome projects, your ideas, your announcements, not necessarily related to ChibiOS but to embedded in general. This forum is NOT for support.
inca
Posts: 37
Joined: Mon Apr 22, 2013 12:08 am

Posix Simulator for Mac OS X 10.7.5

Postby inca » Mon Jun 17, 2013 4:14 am

I was having trouble with i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00). Here are the relevant errors that were show stoppers for me:

Code: Select all

ChibiOS/demos/Posix-GCC # make HOST_OSX=yes all                         22:51
gcc -c -ggdb -O2 -fomit-frame-pointer --std=gnu99 -Wall -Wextra -Wstrict-prototypes -fverbose-asm -DSIMULATOR -DSHELL_USE_IPRINTF=FALSE   -isysroot /Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.3 -arch i386 -I/usr/include -MD -MP -MF .dep/testmbox.o.d -I . -I../../os/ports/GCC/SIMIA32 -I../../os/kernel/include -I../../test -I../../os/hal/include -I../../os/hal/platforms/Posix -I../../boards/simulator -I../../os/various ../../test/testmbox.c -o ../../test/testmbox.o
gcc -c -ggdb -O2 -fomit-frame-pointer --std=gnu99 -Wall -Wextra -Wstrict-prototypes -fverbose-asm -DSIMULATOR -DSHELL_USE_IPRINTF=FALSE   -isysroot /Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.3 -arch i386 -I/usr/include -MD -MP -MF .dep/testqueues.o.d -I . -I../../os/ports/GCC/SIMIA32 -I../../os/kernel/include -I../../test -I../../os/hal/include -I../../os/hal/platforms/Posix -I../../boards/simulator -I../../os/various ../../test/testqueues.c -o ../../test/testqueues.o
../../test/testmbox.c:60: error: initializer element is not constant
../../test/testmbox.c:60: error: (near initialization for ‘mb1.mb_top’)
../../test/testmbox.c:60: warning: missing initializer
../../test/testmbox.c:60: warning: (near initialization for ‘mb1.mb_fullsem’)
make: *** [../../test/testmbox.o] Error 1
make: *** Waiting for unfinished jobs....
../../test/testqueues.c:66: error: initializer element is not constant
../../test/testqueues.c:66: error: (near initialization for ‘iq.q_top’)
../../test/testqueues.c:67: error: initializer element is not constant
../../test/testqueues.c:67: error: (near initialization for ‘oq.q_top’)
make: *** [../../test/testqueues.o] Error 1

In the relevant code, I read that these did not need to be static initializers, but were so to test the macros. Well the macros looked fine to me so I really had no clue why the compiler was dying on this so I decided to try cc (clang). It worked. Tests passed, all that. Some of the gcc options need to go though in the makefile, such as the "-Wa..." stuff. -Wl gets ignored safely.

I also had to add -I/usr/include to get the stdlib headers which oddly were not working at first. Here is the full Makefile which could probably still use some improvement:

Code: Select all

#
#       !!!! Do NOT edit this makefile with an editor which replace tabs by spaces !!!!
#
##############################################################################################
#
# On command line:
#
# make all = Create project
#
# make clean = Clean project files.
#
# To rebuild project do "make clean" and "make all".
#

##############################################################################################
# Start of default section
#

TRGT =
CC   = $(TRGT)cc
AS   = $(TRGT)cc -x assembler-with-cpp

# List all default C defines here, like -D_DEBUG=1
DDEFS = -DSIMULATOR -DSHELL_USE_IPRINTF=FALSE

# List all default ASM defines here, like -D_DEBUG=1
DADEFS =

# List all default directories to look for include files here
DINCDIR =

# List the default directory to look for the libraries here
DLIBDIR =

# List all default libraries here
DLIBS =

#
# End of default section
##############################################################################################

##############################################################################################
# Start of user section
#

# Define project name here
PROJECT = ch

# Define linker script file here
LDSCRIPT =

# List all user C define here, like -D_DEBUG=1
UDEFS =

# Define ASM defines here
UADEFS =

# Imported source files
CHIBIOS = ../..
include $(CHIBIOS)/boards/simulator/board.mk
include ${CHIBIOS}/os/hal/hal.mk
include ${CHIBIOS}/os/hal/platforms/Posix/platform.mk
include ${CHIBIOS}/os/ports/GCC/SIMIA32/port.mk
include ${CHIBIOS}/os/kernel/kernel.mk
include ${CHIBIOS}/test/test.mk

# List C source files here
SRC  = ${PORTSRC} \
       ${KERNSRC} \
       ${TESTSRC} \
       ${HALSRC} \
       ${PLATFORMSRC} \
       $(BOARDSRC) \
       ${CHIBIOS}/os/various/shell.c \
       ${CHIBIOS}/os/various/chprintf.c \
       main.c

# List ASM source files here
ASRC =

# List all user directories here
UINCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
          $(HALINC) $(PLATFORMINC) $(BOARDINC) \
          ${CHIBIOS}/os/various

# List the user directory to look for the libraries here
ULIBDIR =

# List all user libraries here
ULIBS =

# Define optimisation level here
OPT = -ggdb -O2 -fomit-frame-pointer --std=gnu99

#
# End of user defines
##############################################################################################

INCDIR  = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
LIBDIR  = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
DEFS    = $(DDEFS) $(UDEFS)
ADEFS   = $(DADEFS) $(UADEFS)
OBJS    = $(ASRC:.s=.o) $(SRC:.c=.o)
LIBS    = $(DLIBS) $(ULIBS)

ASFLAGS = $(ADEFS)
#-Wa,-amhls=$(<:.s=.lst)

CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm $(DEFS)

ifeq ($(HOST_OSX),yes)
  ifeq ($(OSX_SDK),)
    OSX_SDK = /Developer/SDKs/MacOSX10.7.sdk
  endif
  ifeq ($(OSX_ARCH),)
    OSX_ARCH = -mmacosx-version-min=10.3 -arch i386
  endif

  CPFLAGS += -isysroot $(OSX_SDK) $(OSX_ARCH) -I/usr/include
  LDFLAGS =
  #-Wl -Map=$(PROJECT).map,-syslibroot,$(OSX_SDK),$(LIBDIR)
  LIBS += $(OSX_ARCH)
else
  # Linux, or other
  CPFLAGS += -m32 -Wa,-alms=$(<:.c=.lst)
  LDFLAGS = -m32 -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
endif

# Generate dependency information
CPFLAGS += -MD -MP -MF .dep/$(@F).d

#
# makefile rules
#

all: $(OBJS) $(PROJECT)

%.o : %.c
   $(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@

%.o : %.s
   $(AS) -c $(ASFLAGS) $< -o $@

$(PROJECT): $(OBJS)
   $(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@

gcov:
   -mkdir gcov
   $(COV) -u $(subst /,\,$(SRC))
   -mv *.gcov ./gcov

clean:                                     
   -rm -f $(OBJS)
   -rm -f $(PROJECT)
   -rm -f $(PROJECT).map
   -rm -f $(SRC:.c=.c.bak)
   -rm -f $(SRC:.c=.lst)
   -rm -f $(ASRC:.s=.s.bak)
   -rm -f $(ASRC:.s=.lst)
   -rm -fR .dep

#
# Include the dependency files, should be the last of the makefile
#
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)

# *** EOF ***


Cheers

Return to “User Projects”

Who is online

Users browsing this forum: No registered users and 2 guests