Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,34 @@ ocaml/Makefile:
# - We override OCAML_OS_TYPE since configure just hardcodes it to "Unix".
OCAML_CFLAGS=$(FREESTANDING_CFLAGS) -I$(TOP)/openlibm/include -I$(TOP)/openlibm/src

# We should specify $(SYSTEM) strictly for aarch32
ifeq ($(OCAML_BUILD_ARCH),arm)
HOST="--host=$(BUILD_ARCH)-unknown-linux-gnueabihf"
UNDEF_SDL=echo '\#undef SUPPORT_DYNAMIC_LINKING' >> ocaml/runtime/caml/s.h
# TODO: This is not a good way to pass the TARGET_XX and SYS_XX check in ./build/ocaml/runtime/signals_osdep.h
DROP_TARGET=sed -i -e 's/(TARGET_arm)/(TARGET)/' ocaml/runtime/signals_osdep.h
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine for the current OCaml releases, but we (@mirage/core) should upstream a cleanup of OCaml's configure and signals_osdep.h ifdef chain so we don't have to specify linux-gnueabihf and sed -i -e in the OCaml distribution.

else
HOST="--host=$(BUILD_ARCH)-unknown-none"
UNDEF_SDL=
DROP_TARGET=
endif

ocaml/Makefile.config: ocaml/Makefile
cd ocaml && \
CC="cc $(OCAML_CFLAGS) -nostdlib" \
AS="as" \
ASPP="cc $(OCAML_CFLAGS) -c" \
LD="ld" \
CPPFLAGS="$(OCAML_CFLAGS)" \
./configure --host=$(BUILD_ARCH)-unknown-none
./configure $(HOST)
echo "ARCH=$(OCAML_BUILD_ARCH)" >> ocaml/Makefile.config
echo '#define HAS_GETTIMEOFDAY' >> ocaml/runtime/caml/s.h
echo '#define HAS_SECURE_GETENV' >> ocaml/runtime/caml/s.h
echo '#define HAS_TIMES' >> ocaml/runtime/caml/s.h
echo '#undef OCAML_OS_TYPE' >> ocaml/runtime/caml/s.h
echo '#define OCAML_OS_TYPE "None"' >> ocaml/runtime/caml/s.h
$(UNDEF_SDL)
$(DROP_TARGET)

ocaml/runtime/caml/version.h: ocaml/Makefile.config
ocaml/tools/make-version-header.sh > $@
Expand Down
97 changes: 97 additions & 0 deletions config.in/Makefile.Linux.arm
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# generated by ./configure
CONFIGURE_ARGS=
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
LIBDIR=$(PREFIX)/lib/ocaml
STUBLIBDIR=$(LIBDIR)/stublibs
MANDIR=$(PREFIX)/man
MANEXT=1
RANLIB=ranlib
RANLIBCMD=ranlib
ARCMD=ar
HASHBANGSCRIPTS=true
UNIX_OR_WIN32=unix
UNIXLIB=unix
GRAPHLIB=graph
BNG_ARCH=generic
BNG_ASM_LEVEL=0
PTHREAD_LINK=-lpthread
PTHREAD_CAML_LINK=-cclib -lpthread
X11_INCLUDES=not found
X11_LINK=not found
LIBBFD_LINK=
LIBBFD_INCLUDE=
BYTECC=gcc
BYTECCCOMPOPTS=-std=gnu99 -O2 -fno-strict-aliasing -fwrapv -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
BYTECCLINKOPTS= -Wl,-E
BYTECCLIBS= -lm -ldl -lcurses -lpthread
BYTECCRPATH=-Wl,-rpath,
EXE=
SUPPORTS_SHARED_LIBRARIES=true
SHAREDCCCOMPOPTS=-fPIC
MKSHAREDLIBRPATH=-Wl,-rpath,
NATDYNLINKOPTS=-Wl,-E
SYSLIB=-l$(1)
#ml let syslib x = "-l"^x;;

### How to build a static library
MKLIB=ar rc $(1) $(2); ranlib $(1)
#ml let mklib out files opts = (* "" *)
#ml Printf.sprintf "ar rc %s %s %s; ranlib %s"
#ml out opts files out;;
ARCH=arm
MODEL=default
SYSTEM=unknown
NATIVECC=gcc
NATIVECCCOMPOPTS=-std=gnu99 -O2 -fno-strict-aliasing -fwrapv -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
NATIVECCPROFOPTS=
NATIVECCLINKOPTS=
NATIVECCRPATH=-Wl,-rpath,
NATIVECCLIBS= -lm -ldl
ASM=as
ASPP=gcc -c
ASPPPROFFLAGS=-DPROFILING
PROFILING=noprof
DYNLINKOPTS= -ldl
OTHERLIBRARIES=unix str num dynlink bigarray systhreads threads
CC_PROFILE=-pg
SYSTHREAD_SUPPORT=true
PARTIALLD=ld -r
PACKLD=$(PARTIALLD) $(NATIVECCLINKOPTS) -o\
DLLCCCOMPOPTS=
IFLEXDIR=
O=o
A=a
SO=so
EXT_OBJ=.o
EXT_ASM=.s
EXT_LIB=.a
EXT_DLL=.so
EXTRALIBS=
CCOMPTYPE=cc
TOOLCHAIN=cc
NATDYNLINK=true
CMXS=cmxs
MKEXE=$(BYTECC)
MKEXEDEBUGFLAG=-g
MKDLL=gcc -shared
MKMAINDLL=gcc -shared
RUNTIMED=noruntimed
SHARED=shared
RUNTIMEI=false
WITH_DEBUGGER=ocamldebugger
WITH_OCAMLDOC=ocamldoc
ASM_CFI_SUPPORTED=true
WITH_FRAME_POINTERS=false
WITH_SPACETIME=false
LIBUNWIND_AVAILABLE=false
LIBUNWIND_INCLUDE_FLAGS=
LIBUNWIND_LINK_FLAGS=
PROFINFO_WIDTH=26
WITH_CPLUGINS=false
WITH_FPIC=false
TARGET=arm-linux-gnueabihf
HOST=arm-linux-gnueabihf
FLAMBDA=false
SAFE_STRING=false
MAX_TESTSUITE_DIR_RETRIES=0
Copy link
Member

@hannesm hannesm Jun 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these files (Makefile.Linux.arm and m.arm.h) should not be needed, but fully generated by our execution of OCaml's configure.

15 changes: 15 additions & 0 deletions config.in/m.arm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#define ARCH_SIXTYFOUR
#define SIZEOF_INT 4
#define SIZEOF_LONG 4
#define SIZEOF_PTR 4
#define SIZEOF_SHORT 2
#define SIZEOF_LONGLONG 8
#define ARCH_INT64_TYPE long long
#define ARCH_UINT64_TYPE unsigned long long
#define ARCH_INT64_PRINTF_FORMAT "lld"
#undef ARCH_BIG_ENDIAN
#undef ARCH_ALIGN_DOUBLE
#undef ARCH_ALIGN_INT64
#define ASM_CFI_SUPPORTED
#define PROFINFO_WIDTH 26
#define INT64_LITERAL(s) s ## LL
8 changes: 8 additions & 0 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ case "${BUILD_ARCH}" in
aarch64)
OCAML_BUILD_ARCH="arm64"
;;
armv7l)
OCAML_BUILD_ARCH="arm"
;;
*)
echo "ERROR: Unsupported architecture: ${BUILD_ARCH}" 1>&2
exit 1
Expand All @@ -48,6 +51,11 @@ if [ "${BUILD_ARCH}" = "aarch64" ]; then
PKG_CONFIG_EXTRA_LIBS="$PKG_CONFIG_EXTRA_LIBS $(gcc -print-libgcc-file-name)" || exit 1
fi

# aarch32 with Solo5/spt will use an internal builtin library instead of libgcc
if [ "${BUILD_ARCH}" = "armv7l" ]; then
PKG_CONFIG_EXTRA_LIBS="$PKG_CONFIG_EXTRA_LIBS $(ocamlfind printconf path)/solo5-bindings-spt/libaeabi.a" || exit 1
fi

cat <<EOM >Makeconf
FREESTANDING_CFLAGS=${FREESTANDING_CFLAGS}
BUILD_ARCH=${BUILD_ARCH}
Expand Down
2 changes: 2 additions & 0 deletions nolibc/dtoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#if defined(__x86_64__) || defined(__aarch64__)
#define IEEE_8087
#define Long int
#elif defined(__arm__)
#define IEEE_8087 /* Considers only the little endian arm arch. */
#else
#error Unsupported architecture
#endif
Expand Down
3 changes: 3 additions & 0 deletions nolibc/include/limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#if defined(__x86_64__) || defined(__aarch64__)
#define LONG_MAX 0x7fffffffffffffffL
#define LLONG_MAX 0x7fffffffffffffffLL
#elif defined(__arm__)
#define LONG_MAX 0x7fffffffL
#define LLONG_MAX 0x7fffffffffffffffLL
#else
#error Unsupported architecture
#endif
Expand Down
2 changes: 1 addition & 1 deletion opam
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ conflicts: [
"solo5-kernel-muen"
]
available: [
((os = "linux" & (arch = "x86_64" | arch = "arm64"))
((os = "linux" & (arch = "x86_64" | arch = "arm32" | arch = "arm64"))
| (os = "freebsd" & arch = "x86_64")
| (os = "openbsd" & arch = "x86_64"))
]
Expand Down