Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
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