Add support for Solaris 2.6 on sun4m builds

It is an excellent platform for catching bugs: big-endian, slow enough
that a context switch in the middle of an operation becomes a regular
occurrence, and all that on a SMP box.  Or: I just wanted to see if it
would work.

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2019-07-05 23:15:41 +02:00 committed by eboasson
parent 47920df65c
commit fda285e2f5
52 changed files with 1266 additions and 4197 deletions

View file

@ -0,0 +1,40 @@
# Solaris 2.6 / sun4m port
Building for Solaris 2.6 / sun4m, e.g., a Sun Microsystems SPARCStation 20 running Solaris 2.6,
firstly involves getting a sufficiently modern gcc onto the machine (gcc-4.3.x with GNU binutils
certainly works, but it is very well possible that older versions and/or using the Sun assembler and
linker work fine, too) and a sufficiently new gmake (3.81 should do).
Secondly, because the port relies on a custom makefile rather than "cmake", and that makefile
doesn't build the Java-based IDL preprocessor to avoid pulling in tons of dependencies, you will
need to do a build on a "normal" platform first. The makefile assumes that the required parts of
that build process are available in a "build" directory underneath the project root. Note that only
the CMake generate export.h and the ddsperf-related IDL preprocessor output is required (if other
applications are to be be built, they may require additional files).
The results are stored in a directory named "gen". After a successful build, there will be
libddsc.so and ddsperf in that directory. No attempts are made at tracking header file
dependencies. It seems unlikely that anyone would want to use such a machine as a development
machine.
The makefile expects to be run from the project root directory.
E.g., on a regular supported platform:
```
# mkdir build && cd build
# cmake ../src
# make
# cd ..
# git archive -o cdds.zip HEAD
# find build -name '*.[ch]' | xargs zip -9r cdds.zip
```
copy cdds.zip to the Solaris box, log in and:
```
# mkdir cdds && cd cdds
# unzip .../cdds.zip
# make -f ports/solaris2.6/makefile -j4
# gen/ddsperf -D20 sub & gen/ddsperf -D20 pub &
```
It takes about 10 minutes to do the build on a quad 100MHz HyperSPARC.

264
ports/solaris2.6/config.mk Normal file
View file

@ -0,0 +1,264 @@
ifeq "$(CONFIG)" ""
override CONFIG := $(shell $(dir $(lastword $(MAKEFILE_LIST)))/guess-config)
ifeq "$(CONFIG)" ""
$(error "Failed to guess config")
endif
endif
OS := $(shell echo $(CONFIG) | sed -e 's/^[^.]*\.//' -e 's/^\([^-_]*\)[-_].*/\1/')
PROC := $(shell echo $(CONFIG) | sed -e 's/^\([^.]*\)\..*/\1/')
ifeq "$(OS)" "darwin"
DDSRT = $(OS) posix
RULES = darwin
CC = clang
LD = $(CC)
OPT = -fsanitize=address #-O3 -DNDEBUG
PROF =
CPPFLAGS += -Wall -g $(OPT) $(PROF)
CFLAGS += $(CPPFLAGS) #-fno-inline
LDFLAGS += -g $(OPT) $(PROF)
X =
O = .o
A = .a
SO = .dylib
LIBPRE = lib
endif
ifeq "$(OS)" "solaris2.6"
DDSRT = $(OS) posix
RULES = unix
CC = gcc -std=gnu99 -mcpu=v8
LD = $(CC)
OPT = -O2 -DNDEBUG
PROF =
CPPFLAGS += -Wall -g $(OPT) $(PROF) -D_REENTRANT -D__EXTENSIONS__ -D__SunOS_5_6 -I$(PWD)/ports/solaris2.6/include
CFLAGS += $(CPPFLAGS)
LDFLAGS += -g $(OPT) $(PROF)
LDLIBS += -lposix4 -lsocket -lnsl -lc
X =
O = .o
A = .a
SO = .so
LIBPRE = lib
endif
ifeq "$(OS)" "linux"
DDSRT = posix
RULES = unix
CC = gcc-6.2 -std=gnu99 -fpic -mcx16
OPT = #-fsanitize=address
# CC = gcc-6.2 -std=gnu99 -fpic -mcx16
# OPT = -O3 -DNDEBUG -flto
LD = $(CC)
PROF =
CPPFLAGS += -Wall -g $(OPT) $(PROF)
CFLAGS += $(CPPFLAGS) #-fno-inline
LDFLAGS += -g $(OPT) $(PROF)
X =
O = .o
A = .a
SO = .so
LIBPRE = lib
endif
ifeq "$(OS)" "win32"
DDSRT = windows
RULES = windows
CC = cl
LD = link
# OPT = -O2 -DNDEBUG
OPT = -MDd
PROF =
CPPFLAGS = -Zi -W3 $(OPT) $(PROF) -TC # -bigobj
CFLAGS += $(CPPFLAGS)
LDFLAGS += -nologo -incremental:no -subsystem:console -debug
X = .exe
O = .obj
A = .lib
SO = .dll
LIBPRE =
# VS_VERSION=12.0
# ifeq "$(VS_VERSION)" "12.0" # This works for VS2013 + Windows 10
# VS_HOME=/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 12.0
# WINDOWSSDKDIR=/cygdrive/c/Program Files (x86)/Windows Kits/8.1
# else # This works for VS2010 + Windows 7
# VS_HOME=/cygdrive/C/Program Files (x86)/Microsoft Visual Studio 10.0
# WINDOWSSDKDIR=/cygdrive/C/Program Files (x86)/Microsoft SDKs/Windows/v7.0A
# endif
endif
ifeq "$(OS)" "wine"
export WINEDEBUG=-all
DDSRT = windows
RULES = wine
GEN = gen.wine
CC = wine cl
LD = wine link
CPPFLAGS = -nologo -W3 -TC -analyze -D_WINNT=0x0604 -Drestrict=
CFLAGS += $(CPPFLAGS)
LDFLAGS += -nologo -incremental:no -subsystem:console -debug
X = .exe
O = .obj
A = .lib
SO = .dll
LIBPRE =
endif
# use $(DDSRT) as a proxy for $(CONFIG) not matching anything
ifeq "$(DDSRT)" ""
$(error "$(CONFIG): unsupported config")
endif
# We're assuming use of cygwin, which means Windows path names can be
# obtained using "cygpath". With "-m" we get slashes (rather than
# backslashes), which all of MS' tools accept and which are far less
# troublesome in make.
ifeq "$(CC)" "cl"
N_PWD := $(shell cygpath -m '$(PWD)')
#N_VS_HOME := $(shell cygpath -m '$(VS_HOME)')
#N_WINDOWSSDKDIR := $(shell cygpath -m '$(WINDOWSSDKDIR)')
else # not Windows
N_PWD := $(PWD)
endif
# More machine- and platform-specific matters.
ifeq "$(CC)" "cl" # Windows
ifeq "$(PROC)" "x86_64"
MACHINE = -machine:X64
endif
LDFLAGS += $(MACHINE)
OBJ_OFLAG = -Fo
EXE_OFLAG = -out:
SHLIB_OFLAG = -out:
CPPFLAGS += -D_CRT_SECURE_NO_WARNINGS
# ifeq "$(VS_VERSION)" "12.0" # This works for VS2013 + Windows 10
# CPPFLAGS += '-I$(N_VS_HOME)/VC/include' '-I$(N_WINDOWSSDKDIR)/Include/um' '-I$(N_WINDOWSSDKDIR)/Include/shared'
# ifeq "$(PROC)" "x86_64"
# LDFLAGS += '-libpath:$(N_VS_HOME)/VC/lib/amd64' '-libpath:$(N_WINDOWSSDKDIR)/lib/winv6.3/um/x64'
# else
# LDFLAGS += '-libpath:$(N_VS_HOME)/VC/lib' '-libpath:$(N_WINDOWSSDKDIR)/lib/winv6.3/um/x86'
# endif
# else # This works for VS2010 + Windows 7
# CPPFLAGS += '-I$(N_VS_HOME)/VC/include' '-I$(N_WINDOWSSDKDIR)/Include'
# ifeq "$(PROC)" "x86_64"
# LDFLAGS += '-libpath:$(N_VS_HOME)/VC/lib/amd64' '-libpath:$(N_WINDOWSSDKDIR)/lib/x64'
# else
# LDFLAGS += '-libpath:$(N_VS_HOME)/VC/lib' '-libpath:$(N_WINDOWSSDKDIR)/lib'
# endif
# endif
else
ifeq "$(CC)" "wine cl"
OBJ_OFLAG =-Fo
EXE_OFLAG = -out:
SHLIB_OFLAG = -out:
CPPFLAGS += -D_CRT_SECURE_NO_WARNINGS
else # not Windows (-like)
OBJ_OFLAG = -o
EXE_OFLAG = -o
SHLIB_OFLAG = -o
ifeq "$(PROC)" "x86"
CFLAGS += -m32
LDFLAGS += -m32
endif
ifeq "$(PROC)" "x86_64"
CFLAGS += -m64
LDFLAGS += -m64
endif
endif
endif
ifeq "$(CC)" "cl"
LDFLAGS += -libpath:$(N_PWD)/gen
LIBDEP_SYS = kernel32 ws2_32
else
ifeq "$(CC)" "wine cl"
else
LDFLAGS += -L$(N_PWD)/gen
LIBDEP_SYS = kernel32 ws2_32
endif
endif
getabspath=$(abspath $1)
ifeq "$(RULES)" "darwin"
ifneq "$(findstring clang, $(CC))" ""
define make_exe
$(LD) $(LDFLAGS) $(patsubst -L%, -rpath %, $(filter -L%, $(LDFLAGS))) $(EXE_OFLAG)$@ $^ $(LDLIBS)
endef
define make_shlib
$(LD) $(LDFLAGS) $(patsubst -L%, -rpath %, $(filter -L%, $(LDFLAGS))) -dynamiclib -install_name @rpath/$(notdir $@) $(SHLIB_OFLAG)$@ $^ $(LDLIBS)
endef
else # assume gcc
comma=,
define make_exe
$(LD) $(LDFLAGS) $(patsubst -L%, -Wl$(comma)-rpath$(comma)%, $(filter -L%, $(LDFLAGS))) $(EXE_OFLAG)$@ $^ $(LDLIBS)
endef
define make_shlib
$(LD) $(LDFLAGS) $(patsubst -L%, -Wl$(comma)-rpath$(comma)%, $(filter -L%, $(LDFLAGS))) -dynamiclib -Wl,-install_name,@rpath/$(notdir $@) $(SHLIB_OFLAG)$@ $^ $(LDLIBS)
endef
endif
define make_archive
ar -ru $@ $?
endef
define make_dep
$(CC) -M $(CPPFLAGS) $< | sed 's|[a-zA-Z0-9_-]*\.o|gen/&|' > $@ || { rm $@ ; exit 1 ; }
endef
else
ifeq "$(RULES)" "unix"
LDLIBS += -lpthread
comma=,
define make_exe
$(LD) $(LDFLAGS) $(patsubst -L%,-Wl$(comma)-rpath$(comma)%, $(filter -L%, $(LDFLAGS))) $(EXE_OFLAG)$@ $^ $(LDLIBS)
endef
define make_shlib
$(LD) $(LDFLAGS) -Wl$(comma)--no-allow-shlib-undefined $(patsubst -L%,-Wl$(comma)-rpath$(comma)%, $(filter -L%, $(LDFLAGS))) -shared $(SHLIB_OFLAG)$@ $^ $(LDLIBS)
endef
define make_archive
ar -ru $@ $?
endef
define make_dep
$(CC) -M $(CPPFLAGS) $< | sed 's|[a-zA-Z0-9_-]*\.o|gen/&|' > $@ || { rm $@ ; exit 1 ; }
endef
else
ifeq "$(RULES)" "windows"
define make_exe
$(LD) $(LDFLAGS) $(EXE_OFLAG)$@ $^ $(LDLIBS)
endef
define make_shlib
$(LD) $(LDFLAGS) $(SHLIB_OFLAG)$@ $^ $(LDLIBS)
endef
define make_archive
lib $(MACHINE) /out:$@ $^
endef
define make_dep
$(CC) -E $(CPPFLAGS) $(CPPFLAGS) $< | grep "^#line.*\\\\vdds\\\\" | cut -d '"' -f 2 | sort -u | sed -e 's@\([A-Za-z]\)\:@ /cygdrive/\1@' -e 's@\\\\@/@g' -e '$$!s@$$@ \\@' -e '1s@^@$*$O: @' >$@
endef
else
ifeq "$(RULES)" "wine"
COMPILE_MANY_ATONCE=true
getabspath=$1
lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))
FAKEPWD = $(call lc,z:$(subst /,\\\\,$(PWD)))
define make_exe
$(LD) $(LDFLAGS) $(EXE_OFLAG)$@ $^ $(LDLIBS)
endef
define make_shlib
$(LD) $(LDFLAGS) $(SHLIB_OFLAG)$@ $^ $(LDLIBS)
endef
define make_archive
lib $(MACHINE) /out:$@ $^
endef
define make_dep
$(CC) -E $(CPPFLAGS) $(CPPFLAGS) $< | grep "^#line.*\\\\vdds\\\\" | cut -d '"' -f 2 | sort -u | sed -e 's@$(FAKEPWD)\(\\\\\)*@ @' -e 's@\\\\@/@g' -e '$$!s@$$@ \\@' -e '1s@^@$*$O: @' >$@
endef
else
$(error "$(OS) not covered by build macros for")
endif
endif
endif
endif
ifeq "$(GEN)" ""
GEN = gen
endif
%$O:
%$X:
%$(SO):
%.d:

52
ports/solaris2.6/guess-config Executable file
View file

@ -0,0 +1,52 @@
#!/bin/sh
s=`uname -s`
case "$s" in
[Dd]arwin)
# default to G4 for now
m=`uname -m`
case "$m" in
x86_64)
cfg="x86_64.darwin"
;;
*)
echo "guess-config: darwin: didn't recognize machine type $m - please fix" 2>&1
;;
esac
;;
[Ll]inux)
m=`uname -m`
case "$m" in
arm*)
cfg=arm.linux.6
;;
x86_64)
cfg=x86_64.linux.6
;;
*)
cfg=x86.linux.6
;;
esac
;;
[Ss]un[Oo][Ss]|[Ss]olaris)
m=`uname -m`:`uname -r`
#should check OS rev
case "$m" in
sun4m:5.6)
cfg="sparc.solaris2.6"
;;
sun4u:*)
cfg="sparcv9.solaris"
;;
*)
cfg="x86_64.solaris"
;;
esac
;;
*)
echo "guess-config: didn't recognize system type $s - please fix" 2>&1
;;
esac
[ -z "$cfg" ] && cfg="asjemenou"
echo $cfg

View file

@ -0,0 +1,8 @@
#ifndef DDSRT_FIXUP_INTTYPES_H
#define DDSRT_FIXUP_INTTYPES_H
#include_next "inttypes.h"
#define PRIuPTR "lu"
#define PRIxPTR "lx"
#endif /* DDSRT_FIXUP_INTTYPES_H */

View file

@ -0,0 +1,22 @@
#ifndef DDSRT_FIXUP_MATH_H
#define DDSRT_FIXUP_MATH_H
#include_next "math.h"
/* INFINITY, HUGE_VALF, HUGE_VALL are all standard C99, but Solaris 2.6
antedates that by a good margin and GCC's fixed-up headers don't
define it, so we do it here */
#undef HUGE_VAL
#ifdef __GNUC__
# define INFINITY (__builtin_inff ())
# define HUGE_VAL (__builtin_huge_val ())
# define HUGE_VALF (__builtin_huge_valf ())
# define HUGE_VALL (__builtin_huge_vall ())
#else
# define INFINITY 1e10000
# define HUGE_VAL 1e10000
# define HUGE_VALF 1e10000f
# define HUGE_VALL 1e10000L
#endif
#endif /* DDSRT_FIXUP_MATH_H */

View file

@ -0,0 +1,10 @@
#ifndef DDSRT_FIXUP_NETINET_IN_H
#define DDSRT_FIXUP_NETINET_IN_H
#include_next "netinet/in.h"
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16
#endif
#endif /* DDSRT_FIXUP_NETINET_IN_H */

View file

@ -0,0 +1,11 @@
#ifndef DDSRT_FIXUP_STDINT_H
#define DDSRT_FIXUP_STDINT_H
#include <sys/int_types.h>
#include <limits.h>
#ifndef UINT32_C
#define UINT32_C(v) (v ## U)
#endif
#endif /* DDSRT_FIXUP_STDINT_H */

View file

@ -0,0 +1,14 @@
#ifndef DDSRT_FIXUP_SYS_SOCKET_H
#define DDSRT_FIXUP_SYS_SOCKET_H
#include "netinet/in.h"
#include_next "sys/socket.h"
typedef size_t socklen_t;
struct sockaddr_storage {
sa_family_t ss_family;
struct sockaddr_in stuff;
};
#endif /* DDSRT_FIXUP_SYS_SOCKET_H */

59
ports/solaris2.6/makefile Normal file
View file

@ -0,0 +1,59 @@
.PHONY: all clean
include $(dir $(lastword $(MAKEFILE_LIST)))/config.mk
CPPFLAGS += -Isrc/core/ddsc/src -Isrc/core/ddsc/include -Isrc/core/ddsi/include -Isrc/ddsrt/include
CPPFLAGS += $(addprefix -I, $(wildcard src/ddsrt/src/*/include))
CPPFLAGS += -Ibuild/core/include -Ibuild/ddsrt/include
CPPFLAGS += -DDDSI_INCLUDE_NETWORK_PARTITIONS # -DDDSI_INCLUDE_BANDWIDTH_LIMITING -DDDSI_INCLUDE_NETWORK_CHANNELS
SHLIBS = ddsc
EXES = ddsperf
all: $(SHLIBS:%=$(GEN)/$(LIBPRE)%$(SO)) $(EXES:%=$(GEN)/%$X)
lib: $(SHLIBS:%=$(GEN)/$(LIBPRE)%$(SO))
clean:
rm -rf $(GEN)/*
LIBCDDS_SRCDIRS := src/core/ddsi/src src/core/ddsc/src src/ddsrt/src $(DDSRT:%=src/ddsrt/src/*/%)
LIBCDDS_SRC := $(filter-out %/getopt.c, $(wildcard $(LIBCDDS_SRCDIRS:%=%/*.c)))
ifeq "$(words $(DDSRT))" "2" # max = 2 ...
pct=%
XX=$(filter src/ddsrt/src/%/$(word 1, $(DDSRT))/, $(dir $(LIBCDDS_SRC)))
YY=$(patsubst %/$(word 1, $(DDSRT))/, %/$(word 2, $(DDSRT))/, $(XX))
LIBCDDS_SRC := $(filter-out $(YY:%=%$(pct)), $(LIBCDDS_SRC))
endif
$(GEN)/$(LIBPRE)ddsc$(SO): CPPFLAGS += -Dddsc_EXPORTS
$(GEN)/$(LIBPRE)ddsc$(SO): CPPFLAGS += -fPIC
ifneq "$(COMPILE_MANY_ATONCE)" "true"
$(GEN)/$(LIBPRE)ddsc$(SO): $(LIBCDDS_SRC:%.c=$(GEN)/%$O)
$(make_shlib)
else # /Fo bit is MSVC specific
$(GEN)/$(LIBPRE)ddsc$(SO): $(LIBCDDS_SRC)
xs="" ;\
for x in $(foreach x, $^, $(call getabspath, $x)) ; do \
[ $$x -nt $(GEN)/`basename $$x .c`$O ] && xs="$$xs $$x" ; \
done ; \
echo "compile: $$xs" ; \
[ -z "$$xs" ] || $(CC) $(CPPFLAGS) -MP8 -Fo.\\$(GEN)\\ -c $$xs
$(LD) $(LDFLAGS) $(SHLIB_OFLAG)$@ $(LIBCDDS_SC:%=$(GEN)/%$O) $(LDLIBS)
endif
DDSPERF_SRCDIRS := src/tools/ddsperf build/tools/ddsperf
DDSPERF_SRC := $(wildcard $(DDSPERF_SRCDIRS:%=%/*.c))
$(GEN)/ddsperf$X: LDLIBS += -L. -lddsc
$(GEN)/ddsperf$X: CPPFLAGS += -Ibuild/tools/ddsperf
$(GEN)/ddsperf$X: $(DDSPERF_SRC:%.c=%.o) | $(GEN)/$(LIBPRE)ddsc$(SO)
$(make_exe)
$(GEN)/%.STAMP: ; @[ -d $(dir $@) ] || { mkdir -p $(dir $@) ; touch $@ ; }
$(GEN)/%$O: %.c $(GEN)/%.STAMP
$(CC) $(CPPFLAGS) $(OBJ_OFLAG)$@ -c $<
$(GEN)/%.d: %.c
$(make_dep)